[
https://issues.apache.org/jira/browse/FLINK-41691?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Sergey Nuyanzin reassigned FLINK-41691:
---------------------------------------
Assignee: Sergey Nuyanzin
> Escape partition values and dynamic options when generating materialized
> table refresh statements
> -------------------------------------------------------------------------------------------------
>
> Key: FLINK-41691
> URL: https://issues.apache.org/jira/browse/FLINK-41691
> Project: Flink
> Issue Type: Bug
> Components: Table SQL / Gateway
> Reporter: Robert Metzger
> Assignee: Sergey Nuyanzin
> Priority: Major
>
> When a materialized table is refreshed or created, Flink builds the INSERT
> OVERWRITE / INSERT INTO statement by putting user-supplied values straight
> into the SQL text with String.format:
> - Partition spec (WHERE clause): String.format("%s = '%s'", key, value)
> - Dynamic options (OPTIONS hint): String.format("'%s'='%s'", key, value)
> Keys are not quoted as identifiers, and values are not escaped. A partition
> value or option that contains a single quote, such as O'Reilly, produces an
> invalid statement or changes what the statement means. Partition keys with
> special characters cause the same problem.
> The affected code is in DefaultMaterializedTableExecutor
> (flink-table-planner) on master and in MaterializedTableManager
> (flink-sql-gateway) on release-1.20 to release-2.4.
> Proposed changes:
> 1. Quote partition keys with EncodingUtils.escapeIdentifier(). Escape
> partition values and option keys and values with
> EncodingUtils.escapeSingleQuotes().
> 2. Add unit tests for the refresh and insert statement generation with
> quotes, backticks, -- and */ in keys and values. The tests must assert that
> the generated statement parses to one operation whose WHERE and hint contents
> match the input exactly.
> 3. Check the other places in flink-table that build SQL text from runtime
> values with String.format and apply the same escaping.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)