docete commented on a change in pull request #10268: 
[Flink-14599][table-planner-blink] Support precision of TimestampType in blink 
planner
URL: https://github.com/apache/flink/pull/10268#discussion_r349484762
 
 

 ##########
 File path: 
flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/planner/expressions/converter/ExpressionConverter.java
 ##########
 @@ -135,8 +138,24 @@ public RexNode visit(ValueLiteralExpression valueLiteral) 
{
                                return 
relBuilder.getRexBuilder().makeTimeLiteral(TimeString.fromCalendarFields(
                                                
valueAsCalendar(extractValue(valueLiteral, java.sql.Time.class))), 0);
                        case TIMESTAMP_WITHOUT_TIME_ZONE:
-                               return 
relBuilder.getRexBuilder().makeTimestampLiteral(TimestampString.fromCalendarFields(
-                                               
valueAsCalendar(extractValue(valueLiteral, java.sql.Timestamp.class))), 3);
+                               TimestampType timestampType = (TimestampType) 
type;
+                               Class<?> clazz = 
valueLiteral.getOutputDataType().getConversionClass();
+                               LocalDateTime datetime = null;
+                               if (clazz == LocalDateTime.class) {
+                                       datetime = extractValue(valueLiteral, 
LocalDateTime.class);
+                               } else if (clazz == Timestamp.class) {
+                                       datetime = extractValue(valueLiteral, 
Timestamp.class).toLocalDateTime();
+                               } else {
+                                       throw new 
TableException(String.format("Invalid literal of %s.", 
clazz.getCanonicalName()));
+                               }
+                               return 
relBuilder.getRexBuilder().makeTimestampLiteral(
+                                       new TimestampString(
 
 Review comment:
   The only place which can hold such a util should be SqlDateTimeUtils, but 
it's in runtime module and don't recognize TimestampString( which in Calcite 
Core). So, let it go at that.

----------------------------------------------------------------
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]


With regards,
Apache Git Services

Reply via email to