Switch to disable query sub-expansion #2380
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Mitigates: #2340
Query sub-expansion in
astTokenizer
adds columnAS col
suffixes via the additional stepsRemoveExtraAlias(strategy)(ExpandNestedQueries(SqlQuery(a)))
but these are not subject to the naming strategy as pointed out by #2340.Unfortunately this cannot be easily remedied by surrounding the query
a
with a CaseClass that has fields from it's quat because it is already surrounded by a tuple due to the Elaboration in materializeQueryMeta that happens before query expansion even starts. The in theastTokenizer
, the variablea
has the following value:Note that the end of it is wrapped into a tuple which we would probably need to peel off before accessing the Product-Quat in the actual query
querySchema("TestEntity").filter(t => t.s == "a")
. We could forcibly do this anyway just for this use-case but that feels hacky.Now in #2381 we are exploring the idea of removing tuple-elaboration completely. Tuple elaboration was originally introduced before Quats existed due to the limitations of ExpandNestedQuery because selection from arbitrary Identifiers
select x
could not be elaborated into a set of columnsselect x.name, x.age
since before Quats existed we had no idea thatx
was a product type with the fieldsname
andage
. Now that Quats exist this is no longer necessary.(Also note that in ProtoQuill there is also a elaboration mechanism but it elaborates into case-classes and not tuples. If this experiment succeeds and we can remove Tuple elaboration in favor of quats then we should probably do the same thing in protoquill).