[jira] [Work logged] (HIVE-25256) Support ALTER TABLE CHANGE COLUMN for Iceberg
[ https://issues.apache.org/jira/browse/HIVE-25256?focusedWorklogId=624984&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-624984 ] ASF GitHub Bot logged work on HIVE-25256: - Author: ASF GitHub Bot Created on: 20/Jul/21 09:50 Start Date: 20/Jul/21 09:50 Worklog Time Spent: 10m Work Description: szlta merged pull request #2463: URL: https://github.com/apache/hive/pull/2463 -- 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-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 624984) Time Spent: 2.5h (was: 2h 20m) > Support ALTER TABLE CHANGE COLUMN for Iceberg > - > > Key: HIVE-25256 > URL: https://issues.apache.org/jira/browse/HIVE-25256 > Project: Hive > Issue Type: New Feature >Reporter: Marton Bod >Assignee: Marton Bod >Priority: Major > Labels: pull-request-available > Fix For: 4.0.0 > > Time Spent: 2.5h > Remaining Estimate: 0h > > In order to provide support for renaming/changing the data type of a single > column, we should add alter table change column support for Iceberg tables. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (HIVE-25256) Support ALTER TABLE CHANGE COLUMN for Iceberg
[ https://issues.apache.org/jira/browse/HIVE-25256?focusedWorklogId=624221&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-624221 ] ASF GitHub Bot logged work on HIVE-25256: - Author: ASF GitHub Bot Created on: 19/Jul/21 08:21 Start Date: 19/Jul/21 08:21 Worklog Time Spent: 10m Work Description: szlta merged pull request #2463: URL: https://github.com/apache/hive/pull/2463 -- 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-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 624221) Time Spent: 2h 20m (was: 2h 10m) > Support ALTER TABLE CHANGE COLUMN for Iceberg > - > > Key: HIVE-25256 > URL: https://issues.apache.org/jira/browse/HIVE-25256 > Project: Hive > Issue Type: New Feature >Reporter: Marton Bod >Assignee: Marton Bod >Priority: Major > Labels: pull-request-available > Time Spent: 2h 20m > Remaining Estimate: 0h > > In order to provide support for renaming/changing the data type of a single > column, we should add alter table change column support for Iceberg tables. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (HIVE-25256) Support ALTER TABLE CHANGE COLUMN for Iceberg
[ https://issues.apache.org/jira/browse/HIVE-25256?focusedWorklogId=622945&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-622945 ] ASF GitHub Bot logged work on HIVE-25256: - Author: ASF GitHub Bot Created on: 15/Jul/21 09:50 Start Date: 15/Jul/21 09:50 Worklog Time Spent: 10m Work Description: szlta commented on a change in pull request #2463: URL: https://github.com/apache/hive/pull/2463#discussion_r670311756 ## File path: iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergMetaHook.java ## @@ -505,19 +512,83 @@ private void handleReplaceColumns(org.apache.hadoop.hive.metastore.api.Table hms } for (FieldSchema updatedCol : schemaDifference.getTypeChanged()) { - Type newType = HiveSchemaUtil.convert(TypeInfoUtils.getTypeInfoFromTypeString(updatedCol.getType())); - if (!(newType instanceof Type.PrimitiveType)) { -throw new MetaException(String.format("Cannot promote type of column: '%s' to a non-primitive type: %s.", -updatedCol.getName(), newType)); - } - updateSchema.updateColumn(updatedCol.getName(), (Type.PrimitiveType) newType, updatedCol.getComment()); + updateSchema.updateColumn(updatedCol.getName(), getPrimitiveTypeOrThrow(updatedCol), updatedCol.getComment()); } for (FieldSchema updatedCol : schemaDifference.getCommentChanged()) { updateSchema.updateColumnDoc(updatedCol.getName(), updatedCol.getComment()); } } + private void handleChangeColumn(org.apache.hadoop.hive.metastore.api.Table hmsTable) throws MetaException { +List hmsCols = hmsTable.getSd().getCols(); +List icebergCols = HiveSchemaUtil.convert(icebergTable.schema()); +// compute schema difference for renames, type/comment changes +HiveSchemaUtil.SchemaDifference schemaDifference = HiveSchemaUtil.getSchemaDiff(hmsCols, icebergCols, true); +// check column reorder (which could happen even in the absence of any rename, type or comment change) +Map renameMapping = ImmutableMap.of(); +if (!schemaDifference.getMissingFromSecond().isEmpty()) { + renameMapping = ImmutableMap.of( + schemaDifference.getMissingFromSecond().get(0).getName(), + schemaDifference.getMissingFromFirst().get(0).getName()); +} +Pair> outOfOrder = HiveSchemaUtil.getFirstOutOfOrderColumn(hmsCols, icebergCols, +renameMapping); + +if (!schemaDifference.isEmpty() || outOfOrder != null) { + updateSchema = icebergTable.updateSchema(); +} else { + // we should get here if the user didn't change anything about the column + // i.e. no changes to the name, type, comment or order + LOG.info("Found no difference between new and old schema for ALTER TABLE CHANGE COLUMN for" + + " table: {}. There will be no Iceberg commit.", hmsTable.getTableName()); + return; +} + +// case 1: column name has been renamed +if (!schemaDifference.getMissingFromSecond().isEmpty()) { + FieldSchema updatedField = schemaDifference.getMissingFromSecond().get(0); + FieldSchema oldField = schemaDifference.getMissingFromFirst().get(0); + updateSchema.renameColumn(oldField.getName(), updatedField.getName()); + + // check if type/comment changed too + if (!Objects.equals(oldField.getType(), updatedField.getType())) { +updateSchema.updateColumn(oldField.getName(), getPrimitiveTypeOrThrow(updatedField), updatedField.getComment()); + } else if (!Objects.equals(oldField.getComment(), updatedField.getComment())) { +updateSchema.updateColumnDoc(oldField.getName(), updatedField.getComment()); + } + +// case 2: only column type and/or comment changed +} else if (!schemaDifference.getTypeChanged().isEmpty()) { + FieldSchema updatedField = schemaDifference.getTypeChanged().get(0); + updateSchema.updateColumn(updatedField.getName(), getPrimitiveTypeOrThrow(updatedField), + updatedField.getComment()); + +// case 3: only comment changed +} else if (!schemaDifference.getCommentChanged().isEmpty()) { + FieldSchema updatedField = schemaDifference.getCommentChanged().get(0); + updateSchema.updateColumnDoc(updatedField.getName(), updatedField.getComment()); +} Review comment: Thanks! -- 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-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 622945) Time Spent: 2h 10m (was: 2h) > Support ALTER TABLE CHANGE COLUMN for Iceberg > - > > Key: HIVE
[jira] [Work logged] (HIVE-25256) Support ALTER TABLE CHANGE COLUMN for Iceberg
[ https://issues.apache.org/jira/browse/HIVE-25256?focusedWorklogId=622543&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-622543 ] ASF GitHub Bot logged work on HIVE-25256: - Author: ASF GitHub Bot Created on: 14/Jul/21 15:12 Start Date: 14/Jul/21 15:12 Worklog Time Spent: 10m Work Description: marton-bod commented on a change in pull request #2463: URL: https://github.com/apache/hive/pull/2463#discussion_r669708908 ## File path: iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergMetaHook.java ## @@ -505,19 +512,83 @@ private void handleReplaceColumns(org.apache.hadoop.hive.metastore.api.Table hms } for (FieldSchema updatedCol : schemaDifference.getTypeChanged()) { - Type newType = HiveSchemaUtil.convert(TypeInfoUtils.getTypeInfoFromTypeString(updatedCol.getType())); - if (!(newType instanceof Type.PrimitiveType)) { -throw new MetaException(String.format("Cannot promote type of column: '%s' to a non-primitive type: %s.", -updatedCol.getName(), newType)); - } - updateSchema.updateColumn(updatedCol.getName(), (Type.PrimitiveType) newType, updatedCol.getComment()); + updateSchema.updateColumn(updatedCol.getName(), getPrimitiveTypeOrThrow(updatedCol), updatedCol.getComment()); } for (FieldSchema updatedCol : schemaDifference.getCommentChanged()) { updateSchema.updateColumnDoc(updatedCol.getName(), updatedCol.getComment()); } } + private void handleChangeColumn(org.apache.hadoop.hive.metastore.api.Table hmsTable) throws MetaException { +List hmsCols = hmsTable.getSd().getCols(); +List icebergCols = HiveSchemaUtil.convert(icebergTable.schema()); +// compute schema difference for renames, type/comment changes +HiveSchemaUtil.SchemaDifference schemaDifference = HiveSchemaUtil.getSchemaDiff(hmsCols, icebergCols, true); +// check column reorder (which could happen even in the absence of any rename, type or comment change) +Map renameMapping = ImmutableMap.of(); +if (!schemaDifference.getMissingFromSecond().isEmpty()) { + renameMapping = ImmutableMap.of( + schemaDifference.getMissingFromSecond().get(0).getName(), + schemaDifference.getMissingFromFirst().get(0).getName()); +} +Pair> outOfOrder = HiveSchemaUtil.getFirstOutOfOrderColumn(hmsCols, icebergCols, +renameMapping); + +if (!schemaDifference.isEmpty() || outOfOrder != null) { + updateSchema = icebergTable.updateSchema(); +} else { + // we should get here if the user didn't change anything about the column + // i.e. no changes to the name, type, comment or order + LOG.info("Found no difference between new and old schema for ALTER TABLE CHANGE COLUMN for" + + " table: {}. There will be no Iceberg commit.", hmsTable.getTableName()); + return; +} + +// case 1: column name has been renamed +if (!schemaDifference.getMissingFromSecond().isEmpty()) { + FieldSchema updatedField = schemaDifference.getMissingFromSecond().get(0); + FieldSchema oldField = schemaDifference.getMissingFromFirst().get(0); + updateSchema.renameColumn(oldField.getName(), updatedField.getName()); + + // check if type/comment changed too + if (!Objects.equals(oldField.getType(), updatedField.getType())) { +updateSchema.updateColumn(oldField.getName(), getPrimitiveTypeOrThrow(updatedField), updatedField.getComment()); + } else if (!Objects.equals(oldField.getComment(), updatedField.getComment())) { +updateSchema.updateColumnDoc(oldField.getName(), updatedField.getComment()); + } + +// case 2: only column type and/or comment changed +} else if (!schemaDifference.getTypeChanged().isEmpty()) { + FieldSchema updatedField = schemaDifference.getTypeChanged().get(0); + updateSchema.updateColumn(updatedField.getName(), getPrimitiveTypeOrThrow(updatedField), + updatedField.getComment()); + +// case 3: only comment changed +} else if (!schemaDifference.getCommentChanged().isEmpty()) { + FieldSchema updatedField = schemaDifference.getCommentChanged().get(0); + updateSchema.updateColumnDoc(updatedField.getName(), updatedField.getComment()); +} Review comment: Yes, it should. In that case, we'd have an entry in both the `commentChanged` and the `typeChanged` lists in the `schemaDifference`. There's a unit test covering this called `testAlterTableChangeColumnTypeAndComment` -- 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-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking
[jira] [Work logged] (HIVE-25256) Support ALTER TABLE CHANGE COLUMN for Iceberg
[ https://issues.apache.org/jira/browse/HIVE-25256?focusedWorklogId=622542&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-622542 ] ASF GitHub Bot logged work on HIVE-25256: - Author: ASF GitHub Bot Created on: 14/Jul/21 15:11 Start Date: 14/Jul/21 15:11 Worklog Time Spent: 10m Work Description: marton-bod commented on a change in pull request #2463: URL: https://github.com/apache/hive/pull/2463#discussion_r669708042 ## File path: iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergStorageHandler.java ## @@ -86,6 +88,10 @@ private static final Splitter TABLE_NAME_SPLITTER = Splitter.on(".."); private static final String TABLE_NAME_SEPARATOR = ".."; + private static final List ALLOWED_ALTER_OPS = ImmutableList.of( + AlterTableType.ADDPROPS, AlterTableType.DROPPROPS, AlterTableType.ADDCOLS, + AlterTableType.REPLACE_COLUMNS, AlterTableType.RENAME_COLUMN, AlterTableType.SETPARTITIONSPEC); + Review comment: Yes, good idea! -- 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-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 622542) Time Spent: 1h 50m (was: 1h 40m) > Support ALTER TABLE CHANGE COLUMN for Iceberg > - > > Key: HIVE-25256 > URL: https://issues.apache.org/jira/browse/HIVE-25256 > Project: Hive > Issue Type: New Feature >Reporter: Marton Bod >Assignee: Marton Bod >Priority: Major > Labels: pull-request-available > Time Spent: 1h 50m > Remaining Estimate: 0h > > In order to provide support for renaming/changing the data type of a single > column, we should add alter table change column support for Iceberg tables. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (HIVE-25256) Support ALTER TABLE CHANGE COLUMN for Iceberg
[ https://issues.apache.org/jira/browse/HIVE-25256?focusedWorklogId=622541&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-622541 ] ASF GitHub Bot logged work on HIVE-25256: - Author: ASF GitHub Bot Created on: 14/Jul/21 15:08 Start Date: 14/Jul/21 15:08 Worklog Time Spent: 10m Work Description: szlta commented on a change in pull request #2463: URL: https://github.com/apache/hive/pull/2463#discussion_r669696347 ## File path: iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergStorageHandler.java ## @@ -86,6 +88,10 @@ private static final Splitter TABLE_NAME_SPLITTER = Splitter.on(".."); private static final String TABLE_NAME_SEPARATOR = ".."; + private static final List ALLOWED_ALTER_OPS = ImmutableList.of( + AlterTableType.ADDPROPS, AlterTableType.DROPPROPS, AlterTableType.ADDCOLS, + AlterTableType.REPLACE_COLUMNS, AlterTableType.RENAME_COLUMN, AlterTableType.SETPARTITIONSPEC); + Review comment: Shouldn't we rely on EnumSet SUPPORTED_ALTER_OPS found in meta hook class here too? ## File path: iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergMetaHook.java ## @@ -505,19 +512,83 @@ private void handleReplaceColumns(org.apache.hadoop.hive.metastore.api.Table hms } for (FieldSchema updatedCol : schemaDifference.getTypeChanged()) { - Type newType = HiveSchemaUtil.convert(TypeInfoUtils.getTypeInfoFromTypeString(updatedCol.getType())); - if (!(newType instanceof Type.PrimitiveType)) { -throw new MetaException(String.format("Cannot promote type of column: '%s' to a non-primitive type: %s.", -updatedCol.getName(), newType)); - } - updateSchema.updateColumn(updatedCol.getName(), (Type.PrimitiveType) newType, updatedCol.getComment()); + updateSchema.updateColumn(updatedCol.getName(), getPrimitiveTypeOrThrow(updatedCol), updatedCol.getComment()); } for (FieldSchema updatedCol : schemaDifference.getCommentChanged()) { updateSchema.updateColumnDoc(updatedCol.getName(), updatedCol.getComment()); } } + private void handleChangeColumn(org.apache.hadoop.hive.metastore.api.Table hmsTable) throws MetaException { +List hmsCols = hmsTable.getSd().getCols(); +List icebergCols = HiveSchemaUtil.convert(icebergTable.schema()); +// compute schema difference for renames, type/comment changes +HiveSchemaUtil.SchemaDifference schemaDifference = HiveSchemaUtil.getSchemaDiff(hmsCols, icebergCols, true); +// check column reorder (which could happen even in the absence of any rename, type or comment change) +Map renameMapping = ImmutableMap.of(); +if (!schemaDifference.getMissingFromSecond().isEmpty()) { + renameMapping = ImmutableMap.of( + schemaDifference.getMissingFromSecond().get(0).getName(), + schemaDifference.getMissingFromFirst().get(0).getName()); +} +Pair> outOfOrder = HiveSchemaUtil.getFirstOutOfOrderColumn(hmsCols, icebergCols, +renameMapping); + +if (!schemaDifference.isEmpty() || outOfOrder != null) { + updateSchema = icebergTable.updateSchema(); +} else { + // we should get here if the user didn't change anything about the column + // i.e. no changes to the name, type, comment or order + LOG.info("Found no difference between new and old schema for ALTER TABLE CHANGE COLUMN for" + + " table: {}. There will be no Iceberg commit.", hmsTable.getTableName()); + return; +} + +// case 1: column name has been renamed +if (!schemaDifference.getMissingFromSecond().isEmpty()) { + FieldSchema updatedField = schemaDifference.getMissingFromSecond().get(0); + FieldSchema oldField = schemaDifference.getMissingFromFirst().get(0); + updateSchema.renameColumn(oldField.getName(), updatedField.getName()); + + // check if type/comment changed too + if (!Objects.equals(oldField.getType(), updatedField.getType())) { +updateSchema.updateColumn(oldField.getName(), getPrimitiveTypeOrThrow(updatedField), updatedField.getComment()); + } else if (!Objects.equals(oldField.getComment(), updatedField.getComment())) { +updateSchema.updateColumnDoc(oldField.getName(), updatedField.getComment()); + } + +// case 2: only column type and/or comment changed +} else if (!schemaDifference.getTypeChanged().isEmpty()) { + FieldSchema updatedField = schemaDifference.getTypeChanged().get(0); + updateSchema.updateColumn(updatedField.getName(), getPrimitiveTypeOrThrow(updatedField), + updatedField.getComment()); + +// case 3: only comment changed +} else if (!schemaDifference.getCommentChanged().isEmpty()) { + FieldSchema updatedField = schemaDifference.getCommentChanged().get(0); + updateSchema.updateColumnD
[jira] [Work logged] (HIVE-25256) Support ALTER TABLE CHANGE COLUMN for Iceberg
[ https://issues.apache.org/jira/browse/HIVE-25256?focusedWorklogId=622502&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-622502 ] ASF GitHub Bot logged work on HIVE-25256: - Author: ASF GitHub Bot Created on: 14/Jul/21 13:28 Start Date: 14/Jul/21 13:28 Worklog Time Spent: 10m Work Description: marton-bod commented on a change in pull request #2463: URL: https://github.com/apache/hive/pull/2463#discussion_r669615214 ## File path: iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergMetaHook.java ## @@ -505,19 +512,82 @@ private void handleReplaceColumns(org.apache.hadoop.hive.metastore.api.Table hms } for (FieldSchema updatedCol : schemaDifference.getTypeChanged()) { - Type newType = HiveSchemaUtil.convert(TypeInfoUtils.getTypeInfoFromTypeString(updatedCol.getType())); - if (!(newType instanceof Type.PrimitiveType)) { -throw new MetaException(String.format("Cannot promote type of column: '%s' to a non-primitive type: %s.", -updatedCol.getName(), newType)); - } - updateSchema.updateColumn(updatedCol.getName(), (Type.PrimitiveType) newType, updatedCol.getComment()); + updateSchema.updateColumn(updatedCol.getName(), getPrimitiveTypeOrThrow(updatedCol), updatedCol.getComment()); } for (FieldSchema updatedCol : schemaDifference.getCommentChanged()) { updateSchema.updateColumnDoc(updatedCol.getName(), updatedCol.getComment()); } } + private void handleChangeColumn(org.apache.hadoop.hive.metastore.api.Table hmsTable) throws MetaException { +List hmsCols = hmsTable.getSd().getCols(); +List icebergCols = HiveSchemaUtil.convert(icebergTable.schema()); +// compute schema difference for renames, type/comment changes +HiveSchemaUtil.SchemaDifference schemaDifference = HiveSchemaUtil.getSchemaDiff(hmsCols, icebergCols, true); +// check column reorder (which could happen even in the absence of any rename, type or comment change) +Map renameMapping = ImmutableMap.of(); +if (!schemaDifference.getMissingFromSecond().isEmpty()) { + renameMapping = ImmutableMap.of( + schemaDifference.getMissingFromSecond().get(0).getName(), + schemaDifference.getMissingFromFirst().get(0).getName()); +} +Pair> outOfOrder = HiveSchemaUtil.getFirstOutOfOrderColumn(hmsCols, icebergCols, +renameMapping); + +if (!schemaDifference.isEmpty() || outOfOrder != null) { + updateSchema = icebergTable.updateSchema(); +} else { + // we should get here if the user restated the exactly the existing column in the CHANGE COLUMN command Review comment: Updated the comment, let me know if this clarifies it. -- 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-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 622502) Time Spent: 1.5h (was: 1h 20m) > Support ALTER TABLE CHANGE COLUMN for Iceberg > - > > Key: HIVE-25256 > URL: https://issues.apache.org/jira/browse/HIVE-25256 > Project: Hive > Issue Type: New Feature >Reporter: Marton Bod >Assignee: Marton Bod >Priority: Major > Labels: pull-request-available > Time Spent: 1.5h > Remaining Estimate: 0h > > In order to provide support for renaming/changing the data type of a single > column, we should add alter table change column support for Iceberg tables. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (HIVE-25256) Support ALTER TABLE CHANGE COLUMN for Iceberg
[ https://issues.apache.org/jira/browse/HIVE-25256?focusedWorklogId=622485&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-622485 ] ASF GitHub Bot logged work on HIVE-25256: - Author: ASF GitHub Bot Created on: 14/Jul/21 12:48 Start Date: 14/Jul/21 12:48 Worklog Time Spent: 10m Work Description: marton-bod commented on a change in pull request #2463: URL: https://github.com/apache/hive/pull/2463#discussion_r669567104 ## File path: hbase-handler/src/test/results/negative/hbase_ddl.q.out ## @@ -26,4 +26,4 @@ key int It is a column key value string It is the column string value A masked pattern was here -FAILED: SemanticException [Error 10134]: ALTER TABLE can only be used for [ADDPROPS, DROPPROPS, ADDCOLS, REPLACE_COLUMNS, SETPARTITIONSPEC] to a non-native table hbase_table_1 +FAILED: SemanticException [Error 10134]: ALTER TABLE can only be used for [ADDPROPS, DROPPROPS, ADDCOLS] to a non-native table hbase_table_1 Review comment: Hbase would get this SemanticException: ``` ALTER TABLE can only be used for [ADDPROPS, DROPPROPS, ADDCOLS] to a non-native table hbase_table_1 ``` HBase (and all other storage handlers except for Iceberg at the moment), should get this exception for all alter commands other than SET/UNSET TBLPROPERTIES and ADD COLUMNS. -- 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-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 622485) Time Spent: 1h 20m (was: 1h 10m) > Support ALTER TABLE CHANGE COLUMN for Iceberg > - > > Key: HIVE-25256 > URL: https://issues.apache.org/jira/browse/HIVE-25256 > Project: Hive > Issue Type: New Feature >Reporter: Marton Bod >Assignee: Marton Bod >Priority: Major > Labels: pull-request-available > Time Spent: 1h 20m > Remaining Estimate: 0h > > In order to provide support for renaming/changing the data type of a single > column, we should add alter table change column support for Iceberg tables. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (HIVE-25256) Support ALTER TABLE CHANGE COLUMN for Iceberg
[ https://issues.apache.org/jira/browse/HIVE-25256?focusedWorklogId=622482&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-622482 ] ASF GitHub Bot logged work on HIVE-25256: - Author: ASF GitHub Bot Created on: 14/Jul/21 12:30 Start Date: 14/Jul/21 12:30 Worklog Time Spent: 10m Work Description: marton-bod commented on a change in pull request #2463: URL: https://github.com/apache/hive/pull/2463#discussion_r669569756 ## File path: hbase-handler/src/test/results/negative/hbase_ddl.q.out ## @@ -26,4 +26,4 @@ key int It is a column key value string It is the column string value A masked pattern was here -FAILED: SemanticException [Error 10134]: ALTER TABLE can only be used for [ADDPROPS, DROPPROPS, ADDCOLS, REPLACE_COLUMNS, SETPARTITIONSPEC] to a non-native table hbase_table_1 +FAILED: SemanticException [Error 10134]: ALTER TABLE can only be used for [ADDPROPS, DROPPROPS, ADDCOLS] to a non-native table hbase_table_1 Review comment: Previously, when we were working on adding new alter commands for Iceberg, we kept adding these new operation types (rename columns, etc.) to the allowed list. However, there was only one global allowed list for all storage handler types. Now, the allowed list has been moved into the storage handler, so I've reverted the global list to its original form (before all our Iceberg changes started flowing in) -- 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-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 622482) Time Spent: 1h 10m (was: 1h) > Support ALTER TABLE CHANGE COLUMN for Iceberg > - > > Key: HIVE-25256 > URL: https://issues.apache.org/jira/browse/HIVE-25256 > Project: Hive > Issue Type: New Feature >Reporter: Marton Bod >Assignee: Marton Bod >Priority: Major > Labels: pull-request-available > Time Spent: 1h 10m > Remaining Estimate: 0h > > In order to provide support for renaming/changing the data type of a single > column, we should add alter table change column support for Iceberg tables. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (HIVE-25256) Support ALTER TABLE CHANGE COLUMN for Iceberg
[ https://issues.apache.org/jira/browse/HIVE-25256?focusedWorklogId=622479&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-622479 ] ASF GitHub Bot logged work on HIVE-25256: - Author: ASF GitHub Bot Created on: 14/Jul/21 12:26 Start Date: 14/Jul/21 12:26 Worklog Time Spent: 10m Work Description: marton-bod commented on a change in pull request #2463: URL: https://github.com/apache/hive/pull/2463#discussion_r669567104 ## File path: hbase-handler/src/test/results/negative/hbase_ddl.q.out ## @@ -26,4 +26,4 @@ key int It is a column key value string It is the column string value A masked pattern was here -FAILED: SemanticException [Error 10134]: ALTER TABLE can only be used for [ADDPROPS, DROPPROPS, ADDCOLS, REPLACE_COLUMNS, SETPARTITIONSPEC] to a non-native table hbase_table_1 +FAILED: SemanticException [Error 10134]: ALTER TABLE can only be used for [ADDPROPS, DROPPROPS, ADDCOLS] to a non-native table hbase_table_1 Review comment: They get this SemanticException: ``` ALTER TABLE can only be used for [ADDPROPS, DROPPROPS, ADDCOLS] to a non-native table hbase_table_1 ``` HBase (and all other storage handlers except for Iceberg at the moment), should get this exception for alter commands other than SET/UNSET TBLPROPERTIES and ADD COLUMNS. -- 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-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 622479) Time Spent: 1h (was: 50m) > Support ALTER TABLE CHANGE COLUMN for Iceberg > - > > Key: HIVE-25256 > URL: https://issues.apache.org/jira/browse/HIVE-25256 > Project: Hive > Issue Type: New Feature >Reporter: Marton Bod >Assignee: Marton Bod >Priority: Major > Labels: pull-request-available > Time Spent: 1h > Remaining Estimate: 0h > > In order to provide support for renaming/changing the data type of a single > column, we should add alter table change column support for Iceberg tables. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (HIVE-25256) Support ALTER TABLE CHANGE COLUMN for Iceberg
[ https://issues.apache.org/jira/browse/HIVE-25256?focusedWorklogId=622453&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-622453 ] ASF GitHub Bot logged work on HIVE-25256: - Author: ASF GitHub Bot Created on: 14/Jul/21 11:11 Start Date: 14/Jul/21 11:11 Worklog Time Spent: 10m Work Description: pvary commented on a change in pull request #2463: URL: https://github.com/apache/hive/pull/2463#discussion_r669514565 ## File path: hbase-handler/src/test/results/negative/hbase_ddl.q.out ## @@ -26,4 +26,4 @@ key int It is a column key value string It is the column string value A masked pattern was here -FAILED: SemanticException [Error 10134]: ALTER TABLE can only be used for [ADDPROPS, DROPPROPS, ADDCOLS, REPLACE_COLUMNS, SETPARTITIONSPEC] to a non-native table hbase_table_1 +FAILED: SemanticException [Error 10134]: ALTER TABLE can only be used for [ADDPROPS, DROPPROPS, ADDCOLS] to a non-native table hbase_table_1 Review comment: What happens with HBase tables if we try replacing columns and setting partition spec? -- 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-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 622453) Time Spent: 50m (was: 40m) > Support ALTER TABLE CHANGE COLUMN for Iceberg > - > > Key: HIVE-25256 > URL: https://issues.apache.org/jira/browse/HIVE-25256 > Project: Hive > Issue Type: New Feature >Reporter: Marton Bod >Assignee: Marton Bod >Priority: Major > Labels: pull-request-available > Time Spent: 50m > Remaining Estimate: 0h > > In order to provide support for renaming/changing the data type of a single > column, we should add alter table change column support for Iceberg tables. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (HIVE-25256) Support ALTER TABLE CHANGE COLUMN for Iceberg
[ https://issues.apache.org/jira/browse/HIVE-25256?focusedWorklogId=622434&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-622434 ] ASF GitHub Bot logged work on HIVE-25256: - Author: ASF GitHub Bot Created on: 14/Jul/21 09:58 Start Date: 14/Jul/21 09:58 Worklog Time Spent: 10m Work Description: marton-bod commented on a change in pull request #2463: URL: https://github.com/apache/hive/pull/2463#discussion_r669468024 ## File path: iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergMetaHook.java ## @@ -505,19 +512,82 @@ private void handleReplaceColumns(org.apache.hadoop.hive.metastore.api.Table hms } for (FieldSchema updatedCol : schemaDifference.getTypeChanged()) { - Type newType = HiveSchemaUtil.convert(TypeInfoUtils.getTypeInfoFromTypeString(updatedCol.getType())); - if (!(newType instanceof Type.PrimitiveType)) { -throw new MetaException(String.format("Cannot promote type of column: '%s' to a non-primitive type: %s.", -updatedCol.getName(), newType)); - } - updateSchema.updateColumn(updatedCol.getName(), (Type.PrimitiveType) newType, updatedCol.getComment()); + updateSchema.updateColumn(updatedCol.getName(), getPrimitiveTypeOrThrow(updatedCol), updatedCol.getComment()); } for (FieldSchema updatedCol : schemaDifference.getCommentChanged()) { updateSchema.updateColumnDoc(updatedCol.getName(), updatedCol.getComment()); } } + private void handleChangeColumn(org.apache.hadoop.hive.metastore.api.Table hmsTable) throws MetaException { +List hmsCols = hmsTable.getSd().getCols(); +List icebergCols = HiveSchemaUtil.convert(icebergTable.schema()); +// compute schema difference for renames, type/comment changes +HiveSchemaUtil.SchemaDifference schemaDifference = HiveSchemaUtil.getSchemaDiff(hmsCols, icebergCols, true); +// check column reorder (which could happen even in the absence of any rename, type or comment change) +Map renameMapping = ImmutableMap.of(); +if (!schemaDifference.getMissingFromSecond().isEmpty()) { + renameMapping = ImmutableMap.of( + schemaDifference.getMissingFromSecond().get(0).getName(), + schemaDifference.getMissingFromFirst().get(0).getName()); +} +Pair> outOfOrder = HiveSchemaUtil.getFirstOutOfOrderColumn(hmsCols, icebergCols, +renameMapping); + +if (!schemaDifference.isEmpty() || outOfOrder != null) { + updateSchema = icebergTable.updateSchema(); +} else { + // we should get here if the user restated the exactly the existing column in the CHANGE COLUMN command Review comment: If the comment is not clear to you, it needs to be fixed :) Will do it -- 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-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 622434) Time Spent: 40m (was: 0.5h) > Support ALTER TABLE CHANGE COLUMN for Iceberg > - > > Key: HIVE-25256 > URL: https://issues.apache.org/jira/browse/HIVE-25256 > Project: Hive > Issue Type: New Feature >Reporter: Marton Bod >Assignee: Marton Bod >Priority: Major > Labels: pull-request-available > Time Spent: 40m > Remaining Estimate: 0h > > In order to provide support for renaming/changing the data type of a single > column, we should add alter table change column support for Iceberg tables. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (HIVE-25256) Support ALTER TABLE CHANGE COLUMN for Iceberg
[ https://issues.apache.org/jira/browse/HIVE-25256?focusedWorklogId=622432&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-622432 ] ASF GitHub Bot logged work on HIVE-25256: - Author: ASF GitHub Bot Created on: 14/Jul/21 09:47 Start Date: 14/Jul/21 09:47 Worklog Time Spent: 10m Work Description: pvary commented on a change in pull request #2463: URL: https://github.com/apache/hive/pull/2463#discussion_r669460802 ## File path: iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergMetaHook.java ## @@ -505,19 +512,82 @@ private void handleReplaceColumns(org.apache.hadoop.hive.metastore.api.Table hms } for (FieldSchema updatedCol : schemaDifference.getTypeChanged()) { - Type newType = HiveSchemaUtil.convert(TypeInfoUtils.getTypeInfoFromTypeString(updatedCol.getType())); - if (!(newType instanceof Type.PrimitiveType)) { -throw new MetaException(String.format("Cannot promote type of column: '%s' to a non-primitive type: %s.", -updatedCol.getName(), newType)); - } - updateSchema.updateColumn(updatedCol.getName(), (Type.PrimitiveType) newType, updatedCol.getComment()); + updateSchema.updateColumn(updatedCol.getName(), getPrimitiveTypeOrThrow(updatedCol), updatedCol.getComment()); } for (FieldSchema updatedCol : schemaDifference.getCommentChanged()) { updateSchema.updateColumnDoc(updatedCol.getName(), updatedCol.getComment()); } } + private void handleChangeColumn(org.apache.hadoop.hive.metastore.api.Table hmsTable) throws MetaException { +List hmsCols = hmsTable.getSd().getCols(); +List icebergCols = HiveSchemaUtil.convert(icebergTable.schema()); +// compute schema difference for renames, type/comment changes +HiveSchemaUtil.SchemaDifference schemaDifference = HiveSchemaUtil.getSchemaDiff(hmsCols, icebergCols, true); +// check column reorder (which could happen even in the absence of any rename, type or comment change) +Map renameMapping = ImmutableMap.of(); +if (!schemaDifference.getMissingFromSecond().isEmpty()) { + renameMapping = ImmutableMap.of( + schemaDifference.getMissingFromSecond().get(0).getName(), + schemaDifference.getMissingFromFirst().get(0).getName()); +} +Pair> outOfOrder = HiveSchemaUtil.getFirstOutOfOrderColumn(hmsCols, icebergCols, +renameMapping); + +if (!schemaDifference.isEmpty() || outOfOrder != null) { + updateSchema = icebergTable.updateSchema(); +} else { + // we should get here if the user restated the exactly the existing column in the CHANGE COLUMN command Review comment: Please fix the comment, I do not get it 😄 -- 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-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 622432) Time Spent: 20m (was: 10m) > Support ALTER TABLE CHANGE COLUMN for Iceberg > - > > Key: HIVE-25256 > URL: https://issues.apache.org/jira/browse/HIVE-25256 > Project: Hive > Issue Type: New Feature >Reporter: Marton Bod >Assignee: Marton Bod >Priority: Major > Labels: pull-request-available > Time Spent: 20m > Remaining Estimate: 0h > > In order to provide support for renaming/changing the data type of a single > column, we should add alter table change column support for Iceberg tables. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (HIVE-25256) Support ALTER TABLE CHANGE COLUMN for Iceberg
[ https://issues.apache.org/jira/browse/HIVE-25256?focusedWorklogId=622433&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-622433 ] ASF GitHub Bot logged work on HIVE-25256: - Author: ASF GitHub Bot Created on: 14/Jul/21 09:47 Start Date: 14/Jul/21 09:47 Worklog Time Spent: 10m Work Description: pvary commented on a change in pull request #2463: URL: https://github.com/apache/hive/pull/2463#discussion_r669460952 ## File path: iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergMetaHook.java ## @@ -505,19 +512,82 @@ private void handleReplaceColumns(org.apache.hadoop.hive.metastore.api.Table hms } for (FieldSchema updatedCol : schemaDifference.getTypeChanged()) { - Type newType = HiveSchemaUtil.convert(TypeInfoUtils.getTypeInfoFromTypeString(updatedCol.getType())); - if (!(newType instanceof Type.PrimitiveType)) { -throw new MetaException(String.format("Cannot promote type of column: '%s' to a non-primitive type: %s.", -updatedCol.getName(), newType)); - } - updateSchema.updateColumn(updatedCol.getName(), (Type.PrimitiveType) newType, updatedCol.getComment()); + updateSchema.updateColumn(updatedCol.getName(), getPrimitiveTypeOrThrow(updatedCol), updatedCol.getComment()); } for (FieldSchema updatedCol : schemaDifference.getCommentChanged()) { updateSchema.updateColumnDoc(updatedCol.getName(), updatedCol.getComment()); } } + private void handleChangeColumn(org.apache.hadoop.hive.metastore.api.Table hmsTable) throws MetaException { +List hmsCols = hmsTable.getSd().getCols(); +List icebergCols = HiveSchemaUtil.convert(icebergTable.schema()); +// compute schema difference for renames, type/comment changes +HiveSchemaUtil.SchemaDifference schemaDifference = HiveSchemaUtil.getSchemaDiff(hmsCols, icebergCols, true); +// check column reorder (which could happen even in the absence of any rename, type or comment change) +Map renameMapping = ImmutableMap.of(); +if (!schemaDifference.getMissingFromSecond().isEmpty()) { + renameMapping = ImmutableMap.of( + schemaDifference.getMissingFromSecond().get(0).getName(), + schemaDifference.getMissingFromFirst().get(0).getName()); +} +Pair> outOfOrder = HiveSchemaUtil.getFirstOutOfOrderColumn(hmsCols, icebergCols, +renameMapping); + +if (!schemaDifference.isEmpty() || outOfOrder != null) { + updateSchema = icebergTable.updateSchema(); +} else { + // we should get here if the user restated the exactly the existing column in the CHANGE COLUMN command Review comment: Or fix me 😄 -- 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-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 622433) Time Spent: 0.5h (was: 20m) > Support ALTER TABLE CHANGE COLUMN for Iceberg > - > > Key: HIVE-25256 > URL: https://issues.apache.org/jira/browse/HIVE-25256 > Project: Hive > Issue Type: New Feature >Reporter: Marton Bod >Assignee: Marton Bod >Priority: Major > Labels: pull-request-available > Time Spent: 0.5h > Remaining Estimate: 0h > > In order to provide support for renaming/changing the data type of a single > column, we should add alter table change column support for Iceberg tables. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (HIVE-25256) Support ALTER TABLE CHANGE COLUMN for Iceberg
[ https://issues.apache.org/jira/browse/HIVE-25256?focusedWorklogId=620978&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-620978 ] ASF GitHub Bot logged work on HIVE-25256: - Author: ASF GitHub Bot Created on: 09/Jul/21 13:28 Start Date: 09/Jul/21 13:28 Worklog Time Spent: 10m Work Description: marton-bod opened a new pull request #2463: URL: https://github.com/apache/hive/pull/2463 ### What changes were proposed in this pull request? Introduce support for `ALTER TABLE tbl CHANGE COLUMN` ### Why are the changes needed? Allows us to rename a column, change its type (only float->double, int->bigint, decimal changes), change its comment or change its order. ### Does this PR introduce _any_ user-facing change? yes, new query type for iceberg ### How was this patch tested? Unit tests -- 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-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 620978) Remaining Estimate: 0h Time Spent: 10m > Support ALTER TABLE CHANGE COLUMN for Iceberg > - > > Key: HIVE-25256 > URL: https://issues.apache.org/jira/browse/HIVE-25256 > Project: Hive > Issue Type: New Feature >Reporter: Marton Bod >Assignee: Marton Bod >Priority: Major > Time Spent: 10m > Remaining Estimate: 0h > > In order to provide support for renaming/changing the data type of a single > column, we should add alter table change column support for Iceberg tables. -- This message was sent by Atlassian Jira (v8.3.4#803005)