zzwqqq commented on code in PR #5180:
URL: https://github.com/apache/calcite/pull/5180#discussion_r3788097984
##########
core/src/main/java/org/apache/calcite/rel/core/Collect.java:
##########
@@ -184,6 +187,32 @@ public RelNode copy(RelTraitSet traitSet, RelNode input) {
return new Collect(getCluster(), traitSet, input, rowType());
}
+ @Override public boolean isValid(Litmus litmus, @Nullable Context context) {
+ final RelDataTypeFactory typeFactory = getCluster().getTypeFactory();
+ final RelDataType inputRow = getInput().getRowType();
+ if (getCollectionType() == SqlTypeName.MAP && inputRow.getFieldCount() !=
2) {
+ return litmus.fail("MAP requires an input with exactly two fields;"
+ + " input row type is {}", inputRow);
+ }
+ final RelDataType derived =
+ deriveRowType(typeFactory, getCollectionType(), getFieldName(),
inputRow);
+ if (rowType().equals(derived)) {
+ return super.isValid(litmus, context);
+ }
+ if (getCollectionType() != SqlTypeName.MAP && inputRow.getFieldCount() ==
1) {
+ // ARRAY or MULTISET over an input row with a single column: the type of
+ // the column should match the type of the array element
+ final RelDataType derivedFromColumn =
Review Comment:
Yes, thanks. This is what I had in mind.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]