[
https://issues.apache.org/jira/browse/HIVE-27533?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Krisztian Kasa resolved HIVE-27533.
-----------------------------------
Resolution: Fixed
Merged to master. Thanks [~soumyakanti.das] for the patch.
> Incorrect FOREIGN KEY constraints in SHOW CREATE TABLE
> ------------------------------------------------------
>
> Key: HIVE-27533
> URL: https://issues.apache.org/jira/browse/HIVE-27533
> Project: Hive
> Issue Type: Bug
> Components: Hive
> Reporter: Soumyakanti Das
> Assignee: Soumyakanti Das
> Priority: Major
> Labels: pull-request-available
>
> For a table that has a composite foreign key, SHOW CREATE TABLE returns
> multiple ALTER STATEMENTS, which is incorrect.
> For example, in show_create_table.q, we have FK constraints on table TEST3
> referencing table TEST:
> {code:java}
> foreign key(col1, col2) references TEST(col1, col2) disable novalidate rely
> {code}
> In the output of {{{}SHOW CREATE TABLE TEST3;{}}}, we see that there are two
> ALTER TABLE constraints for the composite key, which is incorrect as FK
> constraint cannot be on a subset of a composite PK:
> {code:java}
> ALTER TABLE `default`.`test3` ADD CONSTRAINT `#### A masked pattern was here
> ####` FOREIGN KEY (`col1`) REFERENCES `default`.`test`(`col1`) DISABLE
> NOVALIDATE RELY;
> ALTER TABLE `default`.`test3` ADD CONSTRAINT `#### A masked pattern was here
> ####` FOREIGN KEY (`col2`) REFERENCES `default`.`test`(`col2`) DISABLE
> NOVALIDATE RELY; {code}
> For this case, we should get a single ALTER TABLE statement like:
> {code:java}
> ALTER TABLE `default`.`test3` ADD CONSTRAINT `#### A masked pattern was here
> ####` FOREIGN KEY (`col1`, `col2`) REFERENCES `default`.`test`(`col1`,
> `col2`) DISABLE NOVALIDATE RELY; {code}
> To reproduce this, please run:
> {code:java}
> mvn test -Dtest=TestMiniLlapLocalCliDriver -Dtest.output.overwrite=true
> -Dqfile=show_create_table.q {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)