[ 
https://issues.apache.org/jira/browse/FLINK-24422?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17487099#comment-17487099
 ] 

Marios Trivyzas commented on FLINK-24422:
-----------------------------------------

Did some debugging, so my findings are that this is currently allowed because 
even though *LocalDateTime* is not a valid input class for 
{*}LocalZonedTimestampType{*}, in 
*ValuesOperationFactory#convertToExpectedType* we resort to the final block

 
{noformat}
if (supportsExplicitCast(sourceLogicalType.copy(true), 
targetLogicalType.copy(true))) {
    return Optional.of(postResolverFactory.cast(sourceExpression, 
targetDataType));
} else {
    return Optional.empty();
}{noformat}
 

 

which succeeds in casting the *LocalDateTime/TIMESTAMP()* literal input value 
to {*}Instant/TIMESTAMP_LTZ(){*}.

So now I have second thoughts if we should actually fix this, maybe by just 
rejecting this exact conversion?

 

[~slinkydeveloper] [~twalthr] What do you think?

> When creating a TIMESTAMP_LTZ only allow Instant
> ------------------------------------------------
>
>                 Key: FLINK-24422
>                 URL: https://issues.apache.org/jira/browse/FLINK-24422
>             Project: Flink
>          Issue Type: Sub-task
>            Reporter: Marios Trivyzas
>            Assignee: Francesco Guardiani
>            Priority: Major
>
> Currently we also accept *LocalDateTime* objects:
> *.from(TIMESTAMP_LTZ(), 
> LocalDateTime.parse("2021-09-24T12:34:56.123456")).resultsIn(LocalDate.of(2021,
>  9, 24))*



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to