[
https://issues.apache.org/jira/browse/BEAM-10633?focusedWorklogId=466465&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-466465
]
ASF GitHub Bot logged work on BEAM-10633:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 04/Aug/20 21:29
Start Date: 04/Aug/20 21:29
Worklog Time Spent: 10m
Work Description: 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]
Issue Time Tracking
-------------------
Worklog Id: (was: 466465)
Time Spent: 50m (was: 40m)
> UdfImpl when returns java.util.List will hit a NPE
> --------------------------------------------------
>
> Key: BEAM-10633
> URL: https://issues.apache.org/jira/browse/BEAM-10633
> Project: Beam
> Issue Type: Improvement
> Components: dsl-sql
> Reporter: Rui Wang
> Assignee: Rui Wang
> Priority: P2
> Time Spent: 50m
> Remaining Estimate: 0h
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)