-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[CALCITE-7246] UNNEST in Spark should convert to EXPLODE/POSEXPLODE #4601
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
base: main
Are you sure you want to change the base?
Conversation
0950d4d to
44a1875
Compare
| SqlUtil.unparseFunctionSyntax(SqlStdOperatorTable.POSITION, writer, call, false); | ||
| break; | ||
| case UNNEST: | ||
| if (call.getOperator() instanceof SqlUnnestOperator |
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.
Add two separate operators in SqlLibraryOperators: one for explode and one for posexplode
And use it like:
if (call.getOperator() instanceof SqlUnnestOperator && ((SqlUnnestOperator) call.getOperator()).withOrdinality ) {
SqlCall posexplodeCall = SqlLibraryOperators.POSEXPLODE
.createCall(SqlParserPos.ZERO, call.getOperandList());
super.unparseCall(writer, posexplodeCall, leftPrec, rightPrec);
} else {
SqlCall explodeCall = SqlLibraryOperators.EXPLODE
.createCall(SqlParserPos.ZERO, call.getOperandList());
super.unparseCall(writer, explodeCall, leftPrec, rightPrec);
}
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.
That is mostly useful if he wants to support it in input programs; here he wants to use it when outputting SQL.
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.
Is the unparse logic different from the unparse logic of other function operators? If not, then there’s no need to create own mechanism to unparse a function call
trigger CI build [CALCITE-7246] UNNEST in Spark should convert to EXPLODE/POSEXPLODE
140c21d to
c7f87cd
Compare
|
|
Also, you only covered the unparse part. It would be good to implement the parse part as well, so that |
| SqlUtil.unparseFunctionSyntax(SqlStdOperatorTable.POSITION, writer, call, false); | ||
| break; | ||
| case UNNEST: | ||
| if (call.getOperator() instanceof SqlUnnestOperator |
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.
That is mostly useful if he wants to support it in input programs; here he wants to use it when outputting SQL.
| case UNNEST: | ||
| if (call.getOperator() instanceof SqlUnnestOperator | ||
| && ((SqlUnnestOperator) call.getOperator()).withOrdinality) { | ||
| writer.keyword("POSEXPLODE"); |
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.
this one is actually more tricky: I think the ordinality argument is swapped with the data argument in spark, So doing this won't work. You really have to rewrite the plan. You will have to validate this using a real program with data on spark.
|
This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 90 days if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the [email protected] list. Thank you for your contributions. |



See: [CALCITE-6469]