Timo Theusner created FLINK-41611:
-------------------------------------

             Summary: Write materialized table refresh results by column name
                 Key: FLINK-41611
                 URL: https://issues.apache.org/jira/browse/FLINK-41611
             Project: Flink
          Issue Type: Bug
          Components: Table SQL / Planner
            Reporter: Timo Theusner


When CREATE OR ALTER MATERIALIZED TABLE declares a column list and the new 
query reorders columns or adds one mid-list, the stored schema keeps its order 
and appends new columns at the end. The refresh statements map the query's 
columns by position (INSERT INTO t <query>, INSERT OVERWRITE t SELECT * FROM 
(<query>)), so values land in the wrong columns, silently for same-typed 
columns. The refresh job should map the query's columns to the table's 
persisted columns by name.

Proposed Changes
 - Project the persisted columns in table order in 
DefaultMaterializedTableExecutor#getInsertStatement: INSERT INTO t SELECT 
<columns> FROM (<query>)
 - Replace SELECT * with the same projection in 
DefaultMaterializedTableExecutor#getRefreshStatement



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to