You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Sergey Nuyanzin (Jira)" <ji...@apache.org> on 2026/06/05 15:35:00 UTC

[jira] [Commented] (FLINK-39799) Preserve user-typed query text for materialized table and view definitions

    [ https://issues.apache.org/jira/browse/FLINK-39799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18086410#comment-18086410 ] 

Sergey Nuyanzin commented on FLINK-39799:
-----------------------------------------

Merged as [80189e470f462ec02ee6aeafca31b8ac15efd439|https://github.com/apache/flink/commit/80189e470f462ec02ee6aeafca31b8ac15efd439]

> Preserve user-typed query text for materialized table and view definitions
> --------------------------------------------------------------------------
>
>                 Key: FLINK-39799
>                 URL: https://issues.apache.org/jira/browse/FLINK-39799
>             Project: Flink
>          Issue Type: Bug
>          Components: Table SQL / API
>            Reporter: Ramin Gharib
>            Assignee: Ramin Gharib
>            Priority: Major
>              Labels: pull-request-available
>
> When a {{{}CREATE MATERIALIZED TABLE … AS …{}}}, {{{}ALTER MATERIALIZED TABLE … AS …{}}}, or {{CREATE VIEW … AS …}} statement is converted to a catalog object, the persisted {{originalQuery}} is currently produced by re-rendering the parsed {{SqlNode}} via {{SqlNode#toSqlString()}} (through {{{}ConvertContext#toQuotedSqlString{}}}). This normalizes the user's input: identifier casing is changed, type aliases are expanded ({{{}int{}}} → {{{}INTEGER{}}}), whitespace is reformatted, and quoting style is rewritten.
> As a result, {{SHOW CREATE MATERIALIZED TABLE}} / {{SHOW CREATE VIEW}} and round-trips through the catalog no longer reflect what the user typed, even though the field is named {{{}originalQuery{}}}.
> h2. Example
> User input:
> {code:java}
> CREATE MATERIALIZED TABLE mt AS SELECT a, b, cast(c as int) as int_c FROM t1 WHERE c > 200 {code}
>  
>  
> Currently persisted {{{}originalQuery{}}}:
>  
>  
> {code:java}
> SELECT `a`, `b`, CAST(`c` AS INTEGER) AS `int_c` FROM `t1` WHERE `c` > 200{code}
>  
>  
> Desired:
>  
> {code:java}
> SELECT a, b, cast(c as int) as int_c FROM t1 WHERE c > 200{code}
> The {{expandedQuery}} field is unchanged; it continues to hold the fully-qualified, normalized form used by the planner.
> h2. Acceptance criteria
>  * {{originalQuery}} on {{CatalogMaterializedTable}} and {{CatalogView}} equals the verbatim substring the user typed for the AS-query.
>  * {{expandedQuery}} remains the planner-normalized form.
>  * {{SHOW CREATE MATERIALIZED TABLE}} / {{SHOW CREATE VIEW}} reflect the user's original wording.
>  * Existing planner tests are updated where they asserted the normalized form.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)