Skip to content

Commit 9eed876

Browse files
authored
Merge pull request #174 from UncoderIO/gis-8171
Improve filter_tokens in core tokenizer
2 parents d10cc06 + 90da0d7 commit 9eed876

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

uncoder-core/app/translator/core/parser.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from app.translator.core.models.platform_details import PlatformDetails
2929
from app.translator.core.models.query_container import RawQueryContainer, TokenizedQueryContainer
3030
from app.translator.core.models.query_tokens.field import Field
31+
from app.translator.core.models.query_tokens.field_field import FieldField
3132
from app.translator.core.models.query_tokens.field_value import FieldValue
3233
from app.translator.core.models.query_tokens.function_value import FunctionValue
3334
from app.translator.core.tokenizer import QueryTokenizer
@@ -68,6 +69,11 @@ def get_field_tokens(
6869
for token in query_tokens:
6970
if isinstance(token, FieldValue):
7071
field_tokens.append(token.field)
72+
elif isinstance(token, FieldField):
73+
if token.field_left:
74+
field_tokens.append(token.field_left)
75+
if token.field_right:
76+
field_tokens.append(token.field_right)
7177
elif isinstance(token, FunctionValue):
7278
field_tokens.extend(self.tokenizer.get_field_tokens_from_func_args([token.function]))
7379

uncoder-core/app/translator/core/tokenizer.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ def tokenize(self, query: str) -> list[QUERY_TOKEN_TYPE]:
338338
@staticmethod
339339
def filter_tokens(
340340
tokens: list[QUERY_TOKEN_TYPE],
341-
token_type: Union[type[FieldValue], type[Field], type[Keyword], type[Identifier]],
341+
token_type: Union[type[FieldValue], type[Field], type[FieldField], type[Keyword], type[Identifier]],
342342
) -> list[QUERY_TOKEN_TYPE]:
343343
return [token for token in tokens if isinstance(token, token_type)]
344344

@@ -363,7 +363,9 @@ def get_field_tokens_from_func_args( # noqa: PLR0912
363363
result.extend(self.get_field_tokens_from_func_args(args=arg.args))
364364
result.extend(self.get_field_tokens_from_func_args(args=arg.by_clauses))
365365
result.extend(self.get_field_tokens_from_func_args(args=[arg.filter_]))
366-
elif isinstance(arg, (JoinFunction, UnionFunction)):
366+
elif isinstance(arg, JoinFunction):
367+
result.extend(self.get_field_tokens_from_func_args(args=arg.condition))
368+
elif isinstance(arg, UnionFunction):
367369
continue
368370
elif isinstance(arg, Function):
369371
result.extend(self.get_field_tokens_from_func_args(args=arg.args))

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy