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

Glauber M Dantas commented on FLINK-23307:
------------------------------------------

I'm facing the same issue while using the JDBC connector to enrich the stream 
data with data retrieved from an external database. I created a StackOverflow 
discussion with more details: 
[https://stackoverflow.com/questions/78485099/sedona-flink-sql-lookup-on-external-database-failing-when-using-for-system-time]

Using Flink 1.18.1.

> Rowtime attributes are not properly resolved for views
> ------------------------------------------------------
>
>                 Key: FLINK-23307
>                 URL: https://issues.apache.org/jira/browse/FLINK-23307
>             Project: Flink
>          Issue Type: Bug
>          Components: Table SQL / Planner
>    Affects Versions: 1.13.1
>            Reporter: Ingo Bürk
>            Assignee: Ingo Bürk
>            Priority: Major
>
> If a view is contains a rowtime attribute from an underlying table and is 
> then used in a temporal join, an error is thrown
> {quote}Temporal table join currently only supports 'FOR SYSTEM_TIME AS OF' 
> left table's time attribute field
> {quote}
> This does not happen with the generic in-memory catalog, because it copies 
> the schema as-is. However, if a catalog implementation is used which persists 
> the schema without the rowtime information (which is correct, since this is 
> defined by the underlying table and not the view itself), the catalog can 
> only return said schema for a view. This then causes this issue during 
> planning.
> Specifically, this happens in SqlCatalogViewTable#convertToRel. After the 
> call to context#expandView, the rowtime attribute is correctly present, but 
> the inserted cast from RelOptUtil#createCastRel throws this information away.
> The following SQL reproduces the issue. Again, please note that this does NOT 
> work with the default in-memory catalog:
> {code:java}
> CREATE TABLE A (
>     id INT,
>     ts TIMESTAMP(3),
>     WATERMARK FOR ts AS ts,
>     PRIMARY KEY (id) NOT ENFORCED
> ) WITH (
>     'connector' = 'datagen'
> );
> CREATE VIEW B AS SELECT * FROM A;
> SELECT * FROM B JOIN A FOR SYSTEM_TIME AS OF B.ts ON B.id = A.id;
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to