diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-05-03 09:12:24 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-05-03 09:12:24 +0000 |
commit | 98d5537435b2951b36c45f1fda667fa27c165794 (patch) | |
tree | d26b4dfa6cf91847100fe10a94a04dcc2ad36a86 /sqlglot/trie.py | |
parent | Adding upstream version 11.5.2. (diff) | |
download | sqlglot-upstream/11.7.1.tar.xz sqlglot-upstream/11.7.1.zip |
Adding upstream version 11.7.1.upstream/11.7.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sqlglot/trie.py')
-rw-r--r-- | sqlglot/trie.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/sqlglot/trie.py b/sqlglot/trie.py index f3b1c38..eba91b9 100644 --- a/sqlglot/trie.py +++ b/sqlglot/trie.py @@ -3,7 +3,7 @@ import typing as t key = t.Sequence[t.Hashable] -def new_trie(keywords: t.Iterable[key]) -> t.Dict: +def new_trie(keywords: t.Iterable[key], trie: t.Optional[t.Dict] = None) -> t.Dict: """ Creates a new trie out of a collection of keywords. @@ -16,11 +16,12 @@ def new_trie(keywords: t.Iterable[key]) -> t.Dict: Args: keywords: the keywords to create the trie from. + trie: a trie to mutate instead of creating a new one Returns: The trie corresponding to `keywords`. """ - trie: t.Dict = {} + trie = {} if trie is None else trie for key in keywords: current = trie |