You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@phoenix.apache.org by GitBox <gi...@apache.org> on 2021/05/18 23:19:26 UTC

[GitHub] [phoenix] gjacoby126 commented on a change in pull request #1233: PHOENIX-6454: Add feature to SchemaTool to get the DDL in specificati…

gjacoby126 commented on a change in pull request #1233:
URL: https://github.com/apache/phoenix/pull/1233#discussion_r634812788



##########
File path: phoenix-tools/src/main/java/org/apache/phoenix/schema/SchemaSynthesisProcessor.java
##########
@@ -154,7 +156,24 @@ private CreateTableStatement getCreateTableStatement(AddColumnStatement alterSta
         } else {
             newColDef.addAll(oldColDef);
             newColDef.addAll(addStmt.getColumnDefs());
-            newCreateStmt = new CreateTableStatement(createStmt, newColDef);
+            PrimaryKeyConstraint oldPKConstraint = createStmt.getPrimaryKeyConstraint();
+            List<ColumnDefInPkConstraint> pkList = new ArrayList<>();
+            for(Pair<ColumnName, SortOrder> entry : oldPKConstraint.getColumnNames()) {
+                ColumnDefInPkConstraint cd = new
+                        ColumnDefInPkConstraint(entry.getFirst(), entry.getSecond(), oldPKConstraint.isColumnRowTimestamp(entry
+                .getFirst()));
+                pkList.add(cd);
+            }
+            for(ColumnDef cd : addStmt.getColumnDefs()) {

Review comment:
       What if the ALTER tries to add an existing PK column? 

##########
File path: phoenix-tools/src/it/java/org/apache/phoenix/schema/SchemaToolSynthesisIT.java
##########
@@ -154,18 +154,19 @@ public void testCreateIndexStatement_dropIndex() throws Exception {
     private void runAndVerify(String expected, String baseDDL) throws Exception {
         String[] arg = { "-m", "SYNTH", "-d", baseDDL };
         String result = runSchemaTool(null, arg);
+        System.out.println(result);

Review comment:
       Can cut out the println. 




-- 
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.

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