Skip to content
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

Migrate SelectListItemAliasRewriter to PartiqlAst.VisitorTransform #298

Merged

Conversation

dlurton
Copy link
Member

@dlurton dlurton commented Oct 1, 2020

Also:

  • Includes some infrastructure needed to allow all of the AstRewriterBase implementations to be migrated one by one, namely: RewriterTransformBridge.
  • Includes some bug-fixes that were related to the .toAstStatement() extension function not copying metas over correctly. This caused some negative unit test failures because line & column numbers of the errors were not being included.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@dlurton dlurton changed the base branch from master to visitor-transforms October 1, 2020 01:37
@codecov-commenter
Copy link

codecov-commenter commented Oct 1, 2020

Codecov Report

Merging #298 into visitor-transforms will decrease coverage by 0.04%.
The diff coverage is 81.66%.

Impacted file tree graph

@@                   Coverage Diff                    @@
##             visitor-transforms     #298      +/-   ##
========================================================
- Coverage                 82.49%   82.44%   -0.05%     
  Complexity                 1218     1218              
========================================================
  Files                       157      159       +2     
  Lines                      9264     9290      +26     
  Branches                   1513     1519       +6     
========================================================
+ Hits                       7642     7659      +17     
- Misses                     1170     1176       +6     
- Partials                    452      455       +3     
Flag Coverage Δ Complexity Δ
#CLI 18.11% <ø> (ø) 19.00 <ø> (ø)
#EXAMPLES 76.01% <ø> (ø) 27.00 <ø> (ø)
#LANG 85.12% <81.66%> (-0.07%) 1015.00 <5.00> (ø)
#PTS 100.00% <ø> (ø) 0.00 <ø> (ø)
#TEST_SCRIPT 79.68% <ø> (ø) 157.00 <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ Complexity Δ
...ng/src/org/partiql/lang/ast/StatementToExprNode.kt 96.12% <ø> (ø) 0.00 <0.00> (ø)
...ng/src/org/partiql/lang/eval/ExprNodeExtensions.kt 87.50% <ø> (-6.25%) 0.00 <0.00> (ø)
lang/src/org/partiql/lang/domains/util.kt 25.00% <14.28%> (-75.00%) 0.00 <0.00> (ø)
lang/src/org/partiql/lang/eval/CompileOptions.kt 81.81% <50.00%> (ø) 5.00 <0.00> (ø)
.../src/org/partiql/lang/eval/PartiqlAstExtensions.kt 75.00% <75.00%> (ø) 0.00 <0.00> (?)
...ng/src/org/partiql/lang/ast/ExprNodeToStatement.kt 93.01% <94.11%> (ø) 0.00 <0.00> (ø)
...partiql/lang/ast/passes/RewriterTransformBridge.kt 100.00% <100.00%> (ø) 2.00 <2.00> (?)
lang/src/org/partiql/lang/ast/passes/Rewriters.kt 90.00% <100.00%> (ø) 0.00 <0.00> (ø)
...ng/src/org/partiql/lang/eval/EvaluatingCompiler.kt 83.59% <100.00%> (ø) 151.00 <1.00> (+1.00)
...al/visitors/SelectListItemAliasVisitorTransform.kt 100.00% <100.00%> (ø) 2.00 <2.00> (?)
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e073653...65d01c8. Read the comment docs.

* FROM bar AS b
* ```
*
* If provided with a query with all of the select list aliases are already specified, an exact clone is returned.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's open an issue to opt-out when we have a query that already has AS aliases defined.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not clear to me who is doing the opting out. The partiql service? Or should the VisitorTransform implementation itself detect if there is work to be done? Detecting if there is work to be done for all input queries may be more expensive than just doing the rewrite... However, if the user knows they've supplied a query with all of the AS aliases specified then is your suggestion to provide a way for the user to cause this transform to be skipped?

Copy link
Contributor

@therapon therapon Oct 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not blocking. I am not sure about your statement "Detecting if there is work to be done for all input queries may be more expensive than just doing the rewrite". Wouldn't it be cheaper to grab all select nodes and check that each input has an AS name rather than copying trees?

Another idea is to add to our parser the task to keep track of aliases in select clauses and pass a flag as metadata on the root node.

@dlurton dlurton merged commit 95843fd into visitor-transforms Oct 7, 2020
alancai98 pushed a commit that referenced this pull request Dec 7, 2020
)

Also add some of the basic infrastructure that will be used by the new transforms until they area all migrated.
@dlurton dlurton deleted the visitor-transforms-select-list-item-alias branch April 22, 2021 02:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants