tanclary commented on code in PR #3336:
URL: https://github.com/apache/calcite/pull/3336#discussion_r1272718062
##########
core/src/test/java/org/apache/calcite/sql/type/RelDataTypeSystemTest.java:
##########
@@ -153,6 +153,15 @@ private static final class CustomTypeSystem extends
RelDataTypeSystemImpl {
assertEquals(SqlTypeName.DOUBLE, dataType.getSqlTypeName());
}
+ @Test void testLeastRestrictiveUsesMeasureElementType() {
+ RelDataType innerType = TYPE_FACTORY.createSqlType(SqlTypeName.DOUBLE);
+ RelDataType operand1 = TYPE_FACTORY.createMeasureType(innerType);
+ RelDataType operand2 = TYPE_FACTORY.createSqlType(SqlTypeName.INTEGER);
+ RelDataType dataType = SqlLibraryOperators.IFNULL
+ .inferReturnType(TYPE_FACTORY, Lists.newArrayList(operand1, operand2));
+ assertEquals(dataType, operand1);
Review Comment:
I think it makes sense for the return type to be a `MEASURE`, for instance
if you had `IFNULL(AVG(x), 0)` and `AVG(x)` is not null, the return type should
be a `MEASURE<DOUBLE>`. This is reinforced by the fact that BigQuery throws an
error if you try to `GROUP BY` this expression because it identifies it as an
`AGGREGATE` and not just a `DOUBLE`. What do you think?
--
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]