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

Xuyang Zhong edited comment on FLINK-37941 at 7/3/25 7:14 AM:
--------------------------------------------------------------

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      |if 
partitions on new table are same as those on the old table, use them;

else an error will be thrown.                            |
|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                            |


was (Author: xuyangzhong):
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)

Reply via email to