zachjsh commented on code in PR #16223:
URL: https://github.com/apache/druid/pull/16223#discussion_r1567563395
##########
sql/src/main/java/org/apache/druid/sql/calcite/planner/DruidSqlValidator.java:
##########
@@ -475,18 +476,27 @@ private RelDataType validateTargetType(
continue;
}
SqlTypeName sqlTypeName = SqlTypeName.get(definedCol.sqlStorageType());
- RelDataType relType = typeFactory.createSqlType(sqlTypeName);
- if (NullHandling.replaceWithDefault() &&
!SqlTypeFamily.STRING.contains(relType)) {
- fields.add(Pair.of(
- colName,
- relType
- ));
+ RelDataType relType;
+ if (sqlTypeName != null) {
+ relType = typeFactory.createSqlType(sqlTypeName);
} else {
- fields.add(Pair.of(
- colName,
- typeFactory.createTypeWithNullability(relType, true)
- ));
+ ColumnType columnType =
ColumnType.fromString(definedCol.sqlStorageType());
+ if (columnType != null &&
columnType.getType().equals(ValueType.COMPLEX)) {
+ relType = RowSignatures.makeComplexType(typeFactory, columnType,
sourceField.getType().isNullable());
+ } else {
+ relType = RowSignatures.columnTypeToRelDataType(
+ typeFactory,
+ columnType,
+ // this nullability is ignored for complex types for some
reason, hence the check for complex above.
+ sourceField.getType().isNullable()
+ );
+ }
}
Review Comment:
Good call, fixed
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]