[
https://issues.apache.org/jira/browse/FLINK-41611?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Timo Theusner updated FLINK-41611:
----------------------------------
Summary: Fix column order of CREATE OR ALTER MATERIALIZED TABLE with a
column list (was: Write materialized table refresh results by column name)
> Fix column order of CREATE OR ALTER MATERIALIZED TABLE with a column list
> -------------------------------------------------------------------------
>
> Key: FLINK-41611
> URL: https://issues.apache.org/jira/browse/FLINK-41611
> Project: Flink
> Issue Type: Bug
> Components: Table SQL / Planner
> Reporter: Timo Theusner
> Assignee: Timo Theusner
> Priority: Major
> Labels: pull-request-available
>
> 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)