-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Join recursive cte to base #880
Conversation
Codecov Report
@@ Coverage Diff @@
## main #880 +/- ##
==========================================
+ Coverage 94.75% 94.83% +0.07%
==========================================
Files 108 108
Lines 8432 8580 +148
==========================================
+ Hits 7990 8137 +147
- Misses 442 443 +1
Continue to review full report at Codecov.
|
graphql_compiler/tests/integration_tests/test_backends_integration.py
Outdated
Show resolved
Hide resolved
graphql_compiler/tests/integration_tests/test_backends_integration.py
Outdated
Show resolved
Hide resolved
graphql_compiler/tests/integration_tests/test_backends_integration.py
Outdated
Show resolved
Hide resolved
graphql_compiler/tests/integration_tests/test_backends_integration.py
Outdated
Show resolved
Hide resolved
…tion.py Co-authored-by: Predrag Gruevski <[email protected]>
…tion.py Co-authored-by: Predrag Gruevski <[email protected]>
…piler into cte_join
@@ -743,7 +743,7 @@ def __init__(self, sql_schema_info: SQLAlchemySchemaInfo, ir: IrAndMetadata): | |||
self._relocate(ir.query_metadata_table.root_location) | |||
|
|||
# Mapping aliases to the column used to join into them. | |||
self._came_from: Dict[Alias, Column] = {} | |||
self._came_from: Dict[Union[Alias, ColumnRouter], Column] = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The mention of aliases
in the docstring is outdated. So is the entire _aliases
field, since it doesn't only contain aliases anymore. I'm working on fixing this in the next PR, and I created an issue #882
Co-authored-by: Predrag Gruevski <[email protected]>
Currently we generate queries that have the following from clause
FROM anon_1, anon_2
, whereanon_1
is the query before a recurse, andanon_2
is the recursive CTE. Since the two ctes are not joined, if outputs are selected from each, the result will be a cartesian product, which is incorrect.There's two possible solutions:
a) Never select outputs from
anon_1
, since the same values can be accessed fromanon_2
b) Join the ctes in the
FROM
clauseI went with option (b) since it makes it possible to implement recursion inside optional scope.
Note: When no outputs are selected from
anon_1
, there's no need to join, sinceanon_1
can be excluded from theFROM
clause completely. This optimization can be implemented later, and I'm not sure if it makes a difference in runtime.Changes in this PR:
@optional
semantics if the@recurse
is in optional scopeThis PR fixes #866