You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by "kasakrisz (via GitHub)" <gi...@apache.org> on 2023/11/07 09:29:19 UTC

Re: [PR] HIVE-27533: Incorrect FOREIGN KEY constraints in SHOW CREATE TABLE [hive]

kasakrisz commented on code in PR #4837:
URL: https://github.com/apache/hive/pull/4837#discussion_r1384617494


##########
ql/src/java/org/apache/hadoop/hive/ql/exec/DDLPlanUtils.java:
##########
@@ -691,20 +691,26 @@ public void getAlterTableStmtForeignKeyConstraint(ForeignKeyInfo fr, List<String
     }
     Map<String, List<ForeignKeyInfo.ForeignKeyCol>> all = fr.getForeignKeys();
     for (String key : all.keySet()) {
-      for (ForeignKeyInfo.ForeignKeyCol fkc : all.get(key)) {
-        ST command = new ST(ALTER_TABLE_ADD_FOREIGN_KEY);
-        command.add(CHILD_TABLE_NAME, fr.getChildTableName());
-        command.add(DATABASE_NAME, fr.getChildDatabaseName());
-        command.add(CONSTRAINT_NAME, key);
-        command.add(CHILD_COL_NAME, fkc.childColName);
-        command.add(DATABASE_NAME_FR, fkc.parentDatabaseName);
-        command.add(PARENT_TABLE_NAME, fkc.parentTableName);
-        command.add(PARENT_COL_NAME, fkc.parentColName);
-        command.add(ENABLE, fkc.enable);
-        command.add(VALIDATE, fkc.validate);
-        command.add(RELY, fkc.rely);
-        constraints.add(command.render());
+      List<ForeignKeyInfo.ForeignKeyCol> fkCols = all.get(key);
+      List<String> parentCols = new ArrayList<>();
+      List<String> childCols = new ArrayList<>();

Review Comment:
   How about using `LinkedHashSet<String>(fkCols.size())` since column names should be unique.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org