Github user hsuanyi commented on a diff in the pull request: https://github.com/apache/drill/pull/397#discussion_r56527238 --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/SqlConverter.java --- @@ -364,4 +401,35 @@ private static SchemaPlus rootSchema(SchemaPlus schema) { } } + private static class DrillRexBuilder extends RexBuilder { + private DrillRexBuilder(RelDataTypeFactory typeFactory) { + super(typeFactory); + } + + @Override + public RexNode ensureType( + RelDataType type, + RexNode node, + boolean matchNullability) { + RelDataType targetType = type; + if (matchNullability) { + targetType = matchNullability(type, node); + } + if (targetType.getSqlTypeName() == SqlTypeName.ANY) { + return node; + } + if (!node.getType().equals(targetType)) { + if(!targetType.isStruct()) { + final RelDataType anyType = TypeInferenceUtils.createCalciteTypeWithNullability( --- End diff -- As you can see line 418, if one side is ANY, then even if the types are different, Calcite would not complain, nor fail. Here, what we want to do is "not letting Calcite doing anything" even when the types are not matched. So I think we should borrow the solution in line 418.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---