[
https://issues.apache.org/jira/browse/FLINK-33490?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17788980#comment-17788980
]
Benchao Li commented on FLINK-33490:
------------------------------------
Great, thanks [~xuyangzhong] for the investigation!
The reason I'm asking this question is that name deriving happens in many
cases, and they all belong to the "query" realm. I agree that in "CREATE VIEW"
we can throw exception for duplicated names for better user experience. But
we'd better to have a clear vision on what cases we support and what not, and
put these cases into the test.
A few more come into my mind could be:
{code:sql}
SELECT *, 'hello' as new_field FROM (
SELECT id, uid AS id FROM id_table
)
{code}
{code:sql}
SELECT *, 'hello' as id FROM (
SELECT id FROM id_table
)
{code}
Besides, since this would change the public behavior, I'm not sure if we'd
better to have a FLIP for it.
> Validate the name conflicts when creating view
> ----------------------------------------------
>
> Key: FLINK-33490
> URL: https://issues.apache.org/jira/browse/FLINK-33490
> Project: Flink
> Issue Type: Bug
> Components: Table SQL / Planner
> Affects Versions: 1.19.0
> Reporter: Shengkai Fang
> Assignee: xuyang
> Priority: Major
> Labels: pull-request-available
>
> We should forbid
> ```
> CREATE VIEW id_view AS
> SELECT id, uid AS id FROM id_table
> ```
> As the SQL standards states,
> If <regular view specification> is specified, then:
> i) If any two columns in the table specified by the <query expression> have
> equivalent <column name>s, or if any column of that table has an
> implementation-dependent name, then a <view column list> shall be specified.
> ii) Equivalent <column name>s shall not be specified more than once in the
> <view column list>.
> Many databases also throw exception when view name conflicts, e.g. mysql,
> postgres.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)