[
https://issues.apache.org/jira/browse/BEAM-5921?focusedWorklogId=161708&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-161708
]
ASF GitHub Bot logged work on BEAM-5921:
----------------------------------------
Author: ASF GitHub Bot
Created on: 01/Nov/18 19:22
Start Date: 01/Nov/18 19:22
Worklog Time Spent: 10m
Work Description: amaliujia commented on a change in pull request #6913:
[BEAM-5921] [SQL] Support Joda types for UDF arguments
URL: https://github.com/apache/beam/pull/6913#discussion_r230166149
##########
File path:
sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/utils/CalciteUtils.java
##########
@@ -189,4 +192,19 @@ private static RelDataType toRelDataType(
return dataTypeFactory.createTypeWithNullability(type,
field.getNullable());
}
+
+ /**
+ * SQL-Java type mapping, with specified Beam rules: <br>
+ * 1. redirect {@link ReadableInstant} to {@link Date} so Calcite can
recognize it.
+ *
+ * @param rawType
+ * @return
+ */
+ public static RelDataType sqlTypeWithAutoCast(RelDataTypeFactory
typeFactory, Type rawType) {
+ //For Joda time types, return SQL type for java.util.Date.
+ if (rawType instanceof Class &&
ReadableInstant.class.isAssignableFrom((Class<?>) rawType)) {
Review comment:
If `Datetime` is Joda's `Datetime`, that `Datetime` implements
`ReadableInstant` interface already:
http://joda-time.sourceforge.net/apidocs/org/joda/time/DateTime.html
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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: 161708)
Time Spent: 1h 40m (was: 1.5h)
> [SQL] Support Joda types for UDF arguments
> ------------------------------------------
>
> Key: BEAM-5921
> URL: https://issues.apache.org/jira/browse/BEAM-5921
> Project: Beam
> Issue Type: Bug
> Components: dsl-sql
> Reporter: Anton Kedin
> Assignee: Xu Mingmin
> Priority: Major
> Time Spent: 1h 40m
> Remaining Estimate: 0h
>
> We call ScalarFunctionImpl.create() to register a UDF with Calcite schema in
> BeamSqlEnv. Internally it uses Calcite's internal mapping
> (JavaToSqlTypeConversionRules) to map Java types to SQL types to create a
> function signature that gets registered in the schema. Problem is that this
> logic is not extensible and doesn't include Joda types support (maybe others
> as well).
> We can work around this by constructing our own subclass of Function that
> gets registered in the schema instead of calling ScalarFunctionImpl.create().
> This logic can use our own custom mapping (or fall back to Calcite
> implementation if needed).
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)