Details
-
Bug
-
Status: Open
-
Not a Priority
-
Resolution: Unresolved
-
1.12.0
-
None
Description
Temporal Table Functions fail to be created if the history side `Table` is obtained through `StreamTableEnvironment.from`.
With:
CREATE VIEW datagen_history_v AS
SELECT
f_random_str,
COALESCE(ts, null) AS ts,
f_random + 1 AS f_random
FROM datagen_history
This will create a Temporal Table Function that fail while being queried later on:
Table historyTable = tEnv.from("datagen_history_v"); TemporalTableFunction temporalTable = historyTable.createTemporalTableFunction( $("ts"), $("f_random_str")); tEnv.registerFunction("datagen_ttf", temporalTable);
There is a simple workaround: If the view is obtained through a query referencing it, it will succeed later on:
Table historyTable = tEnv.sqlQuery("SELECT * FROM datagen_history_v"); TemporalTableFunction temporalTable = historyTable.createTemporalTableFunction( $("ts"), $("f_random_str")); tEnv.registerFunction("datagen_ttf", temporalTable);
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 being 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.