Github user vvysotskyi commented on a diff in the pull request:
https://github.com/apache/drill/pull/1138#discussion_r172630422
--- Diff:
exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/SqlConverter.java
---
@@ -277,6 +279,25 @@ public String deriveAlias(
return SqlValidatorUtil.getAlias(node, ordinal);
}
+ /**
+ * Checks that specified expression is not implicit column and
+ * adds is to a select list, ensuring that its alias does not
+ * clash with any existing expressions on the list.
+ */
+ @Override
+ protected void addToSelectList(
--- End diff --
Added comment into Javadoc, which describes when and why this method is
used.
As for Avro and Dynamic tables, the key point is the result of
`RelDataType.isDynamicStruct()` method.
For `AvroDrillTable` we use `ExtendableRelDataType` whose
`isDynamicStruct()` method returns `false`, but for `DynamicDrillTable` we use
`RelDataTypeDrillImpl` whose `isDynamicStruct()` method returns `true`.
In such way, Calcites `SqlValidatorImpl` determines whether columns should
be added.
---