[CALCITE-7246] UNNEST in Spark should convert to EXPLODE/POSEXPLODE#4601
[CALCITE-7246] UNNEST in Spark should convert to EXPLODE/POSEXPLODE#4601xiaochen-zhou wants to merge 1 commit intoapache:mainfrom
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.
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.
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.
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.
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.
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 dev@calcite.apache.org list. Thank you for your contributions. |



See: [CALCITE-6469]