You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Xuyang Zhong (Jira)" <ji...@apache.org> on 2025/07/01 09:05:00 UTC

[jira] [Commented] (FLINK-37941) EXCLUDING PARTITIONS doesn't work when using CREATE TABLE LIKE

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

Xuyang Zhong commented on FLINK-37941:
--------------------------------------

I think the effective matrix should be as follows:

|| partitions exist on old table || partitions exist on new table || merge strategy || merge result                     ||
| yes                           | yes                           | INCLUDING      | ERROR                            |
| yes                           | no                            | INCLUDING      | partitions on old table          |
| no                            | yes                           | INCLUDING      | partitions on new table          |
| no                            | no                            | INCLUDING      | none                             |
| yes                           | yes                           | EXCLUDING      | partitions on new table          |
| yes                           | no                            | EXCLUDING      | none                             |
| no                            | yes                           | EXCLUDING      | partitions on new table          |
| no                            | no                            | EXCLUDING      | none                             |


> EXCLUDING PARTITIONS doesn't work when using CREATE TABLE LIKE
> --------------------------------------------------------------
>
>                 Key: FLINK-37941
>                 URL: https://issues.apache.org/jira/browse/FLINK-37941
>             Project: Flink
>          Issue Type: Bug
>          Components: Table SQL / Planner
>    Affects Versions: 2.0.0, 1.20.1
>            Reporter: Xuyang Zhong
>            Priority: Major
>
> The following test can reproduce this bug:
>  
> {code:java}
> @Test
> def test(): Unit = {
>   tEnv
>     .executeSql(s"""
>                    |CREATE TABLE `originalT` (
>                    |  `msisdn` VARCHAR(2147483647),
>                    |  `uuid` VARCHAR(2147483647) NOT NULL,
>                    |  `street_id` VARCHAR(2147483647),
>                    |  `dt` VARCHAR(2147483647) NOT NULL,
>                    |  CONSTRAINT `PK_dt_uuid` PRIMARY KEY (`dt`, `uuid`) NOT ENFORCED
>                    |) COMMENT 'radius日志表,以事件日期为分区'
>                    |PARTITIONED BY (`dt`)
>                    |WITH (
>                    |  'connector' = 'values'
>                    |)
>                    |""".stripMargin)
>     .await()
>   tEnv
>     .executeSql(s"""
>                    |create table `newT` LIKE `originalT`(
>                    |    INCLUDING ALL
>                    |    EXCLUDING PARTITIONS
>                    |  )
>                    |;
>                    |""".stripMargin)
>     .await()
>   val re = tEnv.executeSql("show create table `newT`;")
>   println(re.asInstanceOf[TableResultImpl].collect().next())
> } {code}
> The result is:
> {code:java}
> CREATE TABLE `default_catalog`.`default_database`.`newT` (
>   `msisdn` VARCHAR(2147483647),
>   `uuid` VARCHAR(2147483647) NOT NULL,
>   `street_id` VARCHAR(2147483647),
>   `dt` VARCHAR(2147483647) NOT NULL,
>   CONSTRAINT `PK_dt_uuid` PRIMARY KEY (`dt`, `uuid`) NOT ENFORCED
> ) PARTITIONED BY (`dt`)
> WITH (
>   'connector' = 'values'
> ) {code}
> It seems that `EXCLUDING PARTITIONS` doesn't work actually.



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