[
https://issues.apache.org/jira/browse/FLINK-41611?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Timo Theusner updated FLINK-41611:
----------------------------------
Description: {{CREATE OR ALTER}} and {{ALTER ... AS}} accept a query that
inserts a column and reorders existing ones: {{SELECT a, b, c}} → {{SELECT a,
x, c, b}} stores {{(a, c, b, x)}} while the positional refresh writes {{(a, x,
c, b)}}, so values land in wrong columns. {{validateAndExtractColumnChanges}}
compares positions on different scales, and {{validateChanges}} checks each
change alone. FLIP-492 and FLIP-546 allow only appending at the end. (was:
{{CREATE OR ALTER}} and {{ALTER ... AS}} accept a query that inserts a column
and reorders existing ones: {{SELECT a, b, c}} → {{SELECT a, x, c, b}} stores
{{(a, c, b, x)}} while the positional refresh writes {{(a, x, c, b)}}, so
values land in wrong columns. {{validateAndExtractColumnChanges}} compares
positions on different scales, and {{validateChanges}} checks each change
alone. FLIP-492 and FLIP-546 allow only appending at the end.
Proposed Changes
* Rank only persisted columns in
{{MaterializedTableSchemaUtils#validateAndExtractColumnChanges}}, with and
without a column list, so the emitted changes always produce the query's column
order
* Replace the per-change check in
{{AlterMaterializedTableChangeOperation#validateChanges}} with one rule: the
old persisted columns lead the new ones, in their old order
* Keep the rule in {{validateChanges}} only; the emitted changes stay exact for
every query, including ones the rule rejects
* Keep the existing "Column mismatch at position N" message
* Remove the executor projection that wrote refresh results by column name)
> Allow only appending columns at the end when a materialized table's query
> changes
> ---------------------------------------------------------------------------------
>
> 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
>
> {{CREATE OR ALTER}} and {{ALTER ... AS}} accept a query that inserts a column
> and reorders existing ones: {{SELECT a, b, c}} → {{SELECT a, x, c, b}} stores
> {{(a, c, b, x)}} while the positional refresh writes {{(a, x, c, b)}}, so
> values land in wrong columns. {{validateAndExtractColumnChanges}} compares
> positions on different scales, and {{validateChanges}} checks each change
> alone. FLIP-492 and FLIP-546 allow only appending at the end.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)