-
Notifications
You must be signed in to change notification settings - Fork 139
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
Make explain of ProjectOperator with alias show both name and alias info #2911
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Heng Qian <[email protected]>
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.
Thanks for the changes!
@@ -60,6 +60,6 @@ public <T, C> T accept(ExpressionNodeVisitor<T, C> visitor, C context) { | |||
|
|||
@Override | |||
public String toString() { | |||
return getNameOrAlias(); | |||
return Strings.isNullOrEmpty(alias) ? name : name + " AS " + alias; |
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.
Looks like you should add a new method getNameWithAlias()
in this class similar to getNameOrAlias()
.
And I have some concerns when to use getNameOrAlias()
and when to use getNameWithAlias()
?
Could you deep dive in it?
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.
getNameOrAlias
are used to get the field name to use in other operator. While in its toString
, I just want to add more info than the field name, and it won't break the usage since it's just for explanation, no execution affection.
I think we don't need to add such a new function as it will only be used in this toString
method if added, we should add it unless it can be reused in other places as well.
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.
we should add it unless it can be reused in other places as well.
I doubt are there any other places to replace to getNameWithAlias
either as toString
does. Can you help to confirm them?
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.
Having scanned over all the usage of getNameOrAlias
, I don't see any other places need to be replaced. They are all related to execution.
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.
Thanks @qianheng-aws . @dai-chen Can u help to double confirm it since u are the author of this class?
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.
Sorry I can't recall the specific details. I think it should be safe to change the toString
method only.
|
||
String result = | ||
explainQuery( | ||
String.format("SELECT (age + 1) AS agePlusOne FROM %s LIMIT 10", TEST_INDEX_ACCOUNT)); |
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.
Could you overwrite some more complex cases:
- SELECT <field-list> <alias-list> (compound)
- SELECT field as alias1, alias1 as alias2, alias2 as alias3 (nested alias)
- SELECT 1 as existing-field from t (override)
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.
- Does SQL support such syntax? Or do you mean
filed1 as alias1, filed2 as alias2
? - Seems SQL don't support nested alias.
- ditto.
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.
- Compound case means not only contains pure fields but also contains fields with alias
- It should be a bug if it's unsupported. Translate to PPL, it should be a multiple-rename pipeline.
- Same as above.
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.
- I see. We have such cases in UT. Maybe make this IT be the compound case as well.
- yeah. PPL supports while SQL doesn't.
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.
For 2 and 3, could you create two issues for that?
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.
Sure, but I think they may be the same cause. It's because we only use ProjectOperator instead of EvalOperator for SQL, while project don't support update and evaluate nested fields like eval.
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.
Create a new issue to bring out this problem here: #2933
Signed-off-by: Heng Qian <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2911 +/- ##
=========================================
Coverage 94.49% 94.50%
- Complexity 5230 5236 +6
=========================================
Files 514 515 +1
Lines 14771 14791 +20
Branches 978 978
=========================================
+ Hits 13958 13978 +20
Misses 772 772
Partials 41 41
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Description
Add name information as well in the explain of ProjectOperator with alias, so user can identify whether the field in his plan comes from the right source.
Related Issues
Resolves #2901
Check List
--signoff
.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.