You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flink.apache.org by "Benoît Paris (Jira)" <ji...@apache.org> on 2020/11/18 19:10:00 UTC

[jira] [Created] (FLINK-20226) Temporal Table Functions cannot be created with a view reference

Benoît Paris created FLINK-20226:
------------------------------------

             Summary: Temporal Table Functions cannot be created with a view reference
                 Key: FLINK-20226
                 URL: https://issues.apache.org/jira/browse/FLINK-20226
             Project: Flink
          Issue Type: Bug
          Components: Table SQL / Planner
    Affects Versions: 1.12.0
            Reporter: Benoît Paris
         Attachments: flink-test-temporal-table-function-from.zip

Temporal Table Functions fail to be created if the history side `Table` is obtained through `StreamTableEnvironment.from`.

With:

 
{code:java}
CREATE VIEW datagen_history_v AS
SELECT 
 f_random_str,
 COALESCE(ts, null) AS ts,
 f_random + 1 AS f_random
FROM datagen_history{code}
 

This will create a Temporal Table Function that fail while being queried later on:
{code:java}
Table historyTable = tEnv.from("datagen_history_v");

TemporalTableFunction temporalTable = historyTable.createTemporalTableFunction( $("ts"), $("f_random_str"));
tEnv.registerFunction("datagen_ttf", temporalTable);{code}
 

There is a simple workaround: If the view is obtained through a query referencing it, it will succeed later on:

 
{code:java}
Table historyTable = tEnv.sqlQuery("SELECT * FROM datagen_history_v");

TemporalTableFunction temporalTable = historyTable.createTemporalTableFunction( $("ts"), $("f_random_str"));
tEnv.registerFunction("datagen_ttf", temporalTable);{code}
 
----
Included for reproduction: a pom.xml, one succeeding java case, one failing java case, and the associated failing stacktrace.

It seems to be that the view reference has been made physical as a side effect of the query; as opposed to still be a view reference when `from` has been used.

Calcite's `Relbuilder` will need an `ExpandingPreparingTable` that is a `QueryOperationCatalogViewTable`, and instead is getting a `SqlCatalogViewTable`.

Now, as to knowing where and how the runtime could operate that conversion, I wouldn't know.

 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)