[
https://issues.apache.org/jira/browse/FLINK-41678?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Timo Theusner updated FLINK-41678:
----------------------------------
Description:
A names-only column list in a different order than the query, e.g. {{CREATE
MATERIALIZED TABLE t (b, a) AS SELECT a, b FROM src}}, stores the table as
{{(b, a)}} but keeps the query unchanged. The refresh INSERT is positional, so
{{b}} receives {{a}}'s values and vice versa. {{alignQuery}} reorders the query
operation, but the stored expanded query is not aligned. FLIP-550 requires this
reorder to work as in CTAS.
Proposed Changes
* Rewrite the query's select list into the order of a names-only column list
and store its expanded text, as CTAS does
* Apply it on CREATE, CREATE OR ALTER and conversion of a table
* Reorder SELECT, WITH and set operations; remap ordinal ORDER BY items to the
moved columns
* Reject a query that can't be reordered (e.g. VALUES) with a hint to wrap it
in a SELECT
was:
A names-only column list in a different order than the query, e.g. {{CREATE
MATERIALIZED TABLE t (b, a) AS SELECT a, b FROM src}}, stores the table as
{{(b, a)}} but keeps the query unchanged. The refresh INSERT is positional, so
{{b}} receives {{a}}'s values and vice versa. {{alignQuery}} reorders the query
operation, but the stored expanded query is not aligned. FLIP-550 requires this
reorder to work as in CTAS.
Proposed Changes
* Rewrite the query's SELECT list into the table's persisted column order, as
{{SqlRewriterUtils}} does for INSERT with a column list, and store its expanded
text
* Apply it on CREATE, CREATE OR ALTER, ALTER ... AS and conversion in
{{MaterializedTableOperationFactory}}
* Apply it to schema-only alters that move any persisted column, by parsing and
rewriting the stored expanded query
* Run it independently of {{validateChanges}}, so the stored query matches
every table that is built
> Store a materialized table's query in the table's column order
> --------------------------------------------------------------
>
> Key: FLINK-41678
> URL: https://issues.apache.org/jira/browse/FLINK-41678
> Project: Flink
> Issue Type: Bug
> Components: Table SQL / Planner
> Reporter: Timo Theusner
> Assignee: Timo Theusner
> Priority: Major
> Labels: pull-request-available
>
> A names-only column list in a different order than the query, e.g. {{CREATE
> MATERIALIZED TABLE t (b, a) AS SELECT a, b FROM src}}, stores the table as
> {{(b, a)}} but keeps the query unchanged. The refresh INSERT is positional,
> so {{b}} receives {{a}}'s values and vice versa. {{alignQuery}} reorders the
> query operation, but the stored expanded query is not aligned. FLIP-550
> requires this reorder to work as in CTAS.
> Proposed Changes
> * Rewrite the query's select list into the order of a names-only column list
> and store its expanded text, as CTAS does
> * Apply it on CREATE, CREATE OR ALTER and conversion of a table
> * Reorder SELECT, WITH and set operations; remap ordinal ORDER BY items to
> the moved columns
> * Reject a query that can't be reordered (e.g. VALUES) with a hint to wrap it
> in a SELECT
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)