my7ym commented on a change in pull request #1811: [CALCITE-3789] Support
validation of UNNEST multiple array columns like Presto
URL: https://github.com/apache/calcite/pull/1811#discussion_r403503969
##########
File path: core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java
##########
@@ -2047,8 +2047,15 @@ protected void convertFrom(
case AS:
call = (SqlCall) from;
- convertFrom(bb, call.operand(0));
- if (call.operandCount() > 2
+ SqlNode firstOperand = call.operand(0);
+
+ if (firstOperand.getKind() == SqlKind.UNNEST) {
+ convertUnnest(bb, (SqlCall) firstOperand, getFieldAliases(call));
+ } else {
+ convertFrom(bb, firstOperand);
+ }
Review comment:
Yea, I considered it. For example, for query
{code}
select d.deptno, e, k.empno\n"
+ "from dept_nested_expanded as d CROSS JOIN\n"
+ " UNNEST(d.admins, d.employees) as t(e, k)
{code}
After validation, it will become
{code}
select d.deptno, t.e, t.k.empno\n"
+ "from dept_nested_expanded as d CROSS JOIN\n"
+ " UNNEST(d.admins, d.employees) as t(e, k)
{code}
The failure comes from the Project. Since the rowtype of Uncollect is
already flattened, so Calcite could not find the path t.e and t.k.empo from the
input, which is the Uncollect RelNode.
So my change will keep them nested, as in SqlUnnestOperator, and I think
it's also aligned with the expected behavior, which is unnesting array but not
unbox the component struct.
Could you elaborate on your thoughts on AliasNamespace? And if possible,
could you provide an ideal logical plan looks like? Thanks!
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services