amaliujia commented on a change in pull request #12461:
URL: https://github.com/apache/beam/pull/12461#discussion_r465341297
##########
File path:
sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/utils/CalciteUtils.java
##########
@@ -285,16 +286,23 @@ private static RelDataType toRelDataType(
* SQL-Java type mapping, with specified Beam rules: <br>
* 1. redirect {@link AbstractInstant} to {@link Date} so Calcite can
recognize it.
*
- * @param rawType
+ * @param type
* @return
*/
- public static RelDataType sqlTypeWithAutoCast(RelDataTypeFactory
typeFactory, Type rawType) {
+ public static RelDataType sqlTypeWithAutoCast(RelDataTypeFactory
typeFactory, Type type) {
// For Joda time types, return SQL type for java.util.Date.
- if (rawType instanceof Class &&
AbstractInstant.class.isAssignableFrom((Class<?>) rawType)) {
+ if (type instanceof Class &&
AbstractInstant.class.isAssignableFrom((Class<?>) type)) {
return typeFactory.createJavaType(Date.class);
- } else if (rawType instanceof Class &&
ByteString.class.isAssignableFrom((Class<?>) rawType)) {
+ } else if (type instanceof Class &&
ByteString.class.isAssignableFrom((Class<?>) type)) {
return typeFactory.createJavaType(byte[].class);
+ } else if (type instanceof ParameterizedType
+ && java.util.List.class.isAssignableFrom(
+ (Class<?>) ((ParameterizedType) type).getRawType())) {
+ ParameterizedType parameterizedType = (ParameterizedType) type;
+ Class<?> genericType = (Class<?>)
parameterizedType.getActualTypeArguments()[0];
+ RelDataType collectionElementType =
typeFactory.createJavaType(genericType);
+ return typeFactory.createArrayType(collectionElementType, -1L);
Review comment:
Nice catch! Made the suggested change.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]