Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-20226

Temporal Table Functions cannot be created with a view reference

    XMLWordPrintableJSON

Details

    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.

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            BenoitParis Benoît Paris
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated: