[
https://issues.apache.org/jira/browse/FLINK-26712?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17510380#comment-17510380
]
Timo Walther commented on FLINK-26712:
--------------------------------------
[~hackergin] Sorry, I somehow missed your comment. The fix is actually quite
easy which is why I'm about to open a PR soon. The error only occurs because we
currently have hard checks in `RowType` that a column name must be unique. This
is actually not very SQL-like as all column arithmetic should be index-based.
But for metadata columns we can make them unique very easily by prefixing. It
would be great to get this into 1.15 as it is a plan changing change.
> Metadata keys should not conflict with physical columns
> -------------------------------------------------------
>
> Key: FLINK-26712
> URL: https://issues.apache.org/jira/browse/FLINK-26712
> Project: Flink
> Issue Type: Sub-task
> Components: Table SQL / API
> Reporter: Timo Walther
> Assignee: Timo Walther
> Priority: Major
>
> If you have an field called timestamp and in addition want to read the
> timestamp from the metadata:
> {code}
> CREATE TABLE animal_sightings_with_metadata (
> `timestamp` TIMESTAMP(3),
> `name` STRING,
> `country` STRING,
> `number` INT,
> `append_time` TIMESTAMP(3) METADATA FROM 'timestamp',
> `partition` BIGINT METADATA VIRTUAL,
> `offset` BIGINT METADATA VIRTUAL,
> `headers` MAP<STRING, BYTES> METADATA,
> `timestamp-type` STRING METADATA,
> `leader-epoch` INT METADATA,
> `topic` STRING METADATA
> )
> {code}
> This gives:
> {code}
> [ERROR] Could not execute SQL statement. Reason:
> org.apache.flink.table.api.ValidationException: Field names must be unique.
> Found duplicates: [timestamp]
> {code}
--
This message was sent by Atlassian Jira
(v8.20.1#820001)