This is an automated email from the ASF dual-hosted git repository.
dkuzmenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git
The following commit(s) were added to refs/heads/master by this push:
new fa17cd60e3c HIVE-15984: Add support for ALTER TABLE .. DROP COLUMN
(#5715)
fa17cd60e3c is described below
commit fa17cd60e3cd5368573cacdbfb6a053cc80ce6ad
Author: ramitg254 <[email protected]>
AuthorDate: Fri May 16 18:03:33 2025 +0530
HIVE-15984: Add support for ALTER TABLE .. DROP COLUMN (#5715)
---
.../java/org/apache/hadoop/hive/ql/ErrorMsg.java | 3 +
.../iceberg/mr/hive/HiveIcebergMetaHook.java | 21 +-
.../mr/hive/TestHiveIcebergSchemaEvolution.java | 41 ++
.../test/queries/negative/iceberg_drop_column.q | 14 +
.../test/queries/positive/iceberg_drop_column.q | 51 +++
.../results/negative/iceberg_drop_column.q.out | 36 ++
.../results/positive/iceberg_drop_column.q.out | 305 +++++++++++++
.../hadoop/hive/ql/parse/AlterClauseParser.g | 8 +
.../org/apache/hadoop/hive/ql/parse/HiveParser.g | 1 +
.../hadoop/hive/ql/ddl/table/AlterTableType.java | 3 +-
.../column/drop/AlterTableDropColumnAnalyser.java | 57 +++
.../column/drop/AlterTableDropColumnDesc.java | 59 +++
.../AlterTableDropColumnOperation.java} | 62 +--
.../replace/AlterTableReplaceColumnsOperation.java | 2 +-
.../apache/hadoop/hive/ql/hooks/WriteEntity.java | 1 +
.../apache/hadoop/hive/ql/plan/HiveOperation.java | 2 +
.../authorization/plugin/HiveOperationType.java | 1 +
.../plugin/sqlstd/Operation2Privilege.java | 2 +
.../test/queries/clientnegative/orc_drop_column.q | 13 +
.../queries/clientnegative/orc_drop_column_acid.q | 6 +
.../queries/clientnegative/parquet_drop_column.q | 11 +
.../test/queries/clientpositive/orc_drop_column.q | 54 +++
.../queries/clientpositive/parquet_drop_column.q | 54 +++
.../results/clientnegative/orc_drop_column.q.out | 38 ++
.../clientnegative/orc_drop_column_acid.q.out | 13 +
.../parquet_alter_part_table_drop_columns.q.out | 2 +-
.../clientnegative/parquet_drop_column.q.out | 30 ++
.../clientpositive/llap/orc_drop_column.q.out | 489 +++++++++++++++++++++
.../clientpositive/llap/parquet_drop_column.q.out | 489 +++++++++++++++++++++
29 files changed, 1833 insertions(+), 35 deletions(-)
diff --git a/common/src/java/org/apache/hadoop/hive/ql/ErrorMsg.java
b/common/src/java/org/apache/hadoop/hive/ql/ErrorMsg.java
index cd62ad1688c..e6f893edcf4 100644
--- a/common/src/java/org/apache/hadoop/hive/ql/ErrorMsg.java
+++ b/common/src/java/org/apache/hadoop/hive/ql/ErrorMsg.java
@@ -351,6 +351,7 @@ public enum ErrorMsg {
"Resource type GLOBAL is not supported in this authorization setting",
"28000"),
UNSUPPORTED_AUTHORIZATION_RESOURCE_TYPE_COLUMN(10258,
"Resource type COLUMN is not supported in this authorization setting",
"28000"),
+ CANNOT_DROP_COLUMN(10259, "Drop column is not supported for table {0}. SerDe
may be incompatible.", true),
TXNMGR_NOT_SPECIFIED(10260, "Transaction manager not specified correctly, " +
"set hive.txn.manager"),
@@ -362,6 +363,8 @@ public enum ErrorMsg {
DBTXNMGR_REQUIRES_CONCURRENCY(10264,
"To use DbTxnManager you must set hive.support.concurrency=true"),
TXNMGR_NOT_ACID(10265, "This command is not allowed on an ACID table {0}.{1}
with a non-ACID transaction manager", true),
+ DROP_COLUMN_UNCASCADED(10266, "Drop column is not supported without cascade
for partitioned table. SerDe may be incompatible.", true),
+
LOCK_NO_SUCH_LOCK(10270, "No record of lock {0} could be found, " +
"may have timed out", true),
LOCK_REQUEST_UNSUPPORTED(10271, "Current transaction manager does not " +
diff --git
a/iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergMetaHook.java
b/iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergMetaHook.java
index 65368460c09..a06c294ddbf 100644
---
a/iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergMetaHook.java
+++
b/iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergMetaHook.java
@@ -167,7 +167,7 @@ public class HiveIcebergMetaHook implements HiveMetaHook {
.of(BaseMetastoreTableOperations.METADATA_LOCATION_PROP,
BaseMetastoreTableOperations.PREVIOUS_METADATA_LOCATION_PROP);
static final EnumSet<AlterTableType> SUPPORTED_ALTER_OPS = EnumSet.of(
- AlterTableType.ADDCOLS, AlterTableType.REPLACE_COLUMNS,
AlterTableType.RENAME_COLUMN,
+ AlterTableType.ADDCOLS, AlterTableType.REPLACE_COLUMNS,
AlterTableType.RENAME_COLUMN, AlterTableType.DROP_COLUMN,
AlterTableType.ADDPROPS, AlterTableType.DROPPROPS,
AlterTableType.SETPARTITIONSPEC,
AlterTableType.UPDATE_COLUMNS, AlterTableType.RENAME,
AlterTableType.EXECUTE, AlterTableType.CREATE_BRANCH,
AlterTableType.CREATE_TAG, AlterTableType.DROP_BRANCH,
AlterTableType.RENAME_BRANCH, AlterTableType.DROPPARTITION,
@@ -503,6 +503,9 @@ private void
doPreAlterTable(org.apache.hadoop.hive.metastore.api.Table hmsTable
} else if (AlterTableType.REPLACE_COLUMNS.equals(currentAlterTableOp)) {
assertNotMigratedTable(hmsTable.getParameters(),
currentAlterTableOp.getName().toUpperCase());
handleReplaceColumns(hmsTable);
+ } else if (AlterTableType.DROP_COLUMN.equals(currentAlterTableOp)) {
+ assertNotMigratedTable(hmsTable.getParameters(),
currentAlterTableOp.getName().toUpperCase());
+ handleDropColumn(hmsTable);
} else if (AlterTableType.RENAME_COLUMN.equals(currentAlterTableOp)) {
// passing in the "CHANGE COLUMN" string instead, since RENAME COLUMN is
not part of SQL syntax (not to mention
// that users can change data types or reorder columns too with this
alter op type, so its name is misleading..)
@@ -641,6 +644,7 @@ public void
commitAlterTable(org.apache.hadoop.hive.metastore.api.Table hmsTable
preAlterTableProperties.partitionSpecProxy,
preAlterTableProperties.partitionKeys, catalogProperties, conf);
} else if (currentAlterTableOp != null) {
switch (currentAlterTableOp) {
+ case DROP_COLUMN:
case REPLACE_COLUMNS:
case RENAME_COLUMN:
case ADDCOLS:
@@ -947,6 +951,21 @@ private void
handleAddColumns(org.apache.hadoop.hive.metastore.api.Table hmsTabl
updateSchema.commit();
}
+ private void handleDropColumn(org.apache.hadoop.hive.metastore.api.Table
hmsTable) throws MetaException {
+ List<FieldSchema> hmsCols = hmsTable.getSd().getCols();
+ List<FieldSchema> icebergCols =
HiveSchemaUtil.convert(icebergTable.schema());
+
+ List<FieldSchema> removedCols = HiveSchemaUtil.getSchemaDiff(icebergCols,
hmsCols, false).getMissingFromSecond();
+ if (removedCols.isEmpty()) {
+ return;
+ }
+
+ transaction = icebergTable.newTransaction();
+
transaction.updateSchema().deleteColumn(removedCols.get(0).getName()).commit();
+ LOG.info("handleDropColumn: Dropping the following column for Iceberg
table {}, col: {}", hmsTable.getTableName(),
+ removedCols);
+ }
+
private void handleReplaceColumns(org.apache.hadoop.hive.metastore.api.Table
hmsTable) throws MetaException {
List<FieldSchema> hmsCols = hmsTable.getSd().getCols();
List<FieldSchema> icebergCols =
HiveSchemaUtil.convert(icebergTable.schema());
diff --git
a/iceberg/iceberg-handler/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergSchemaEvolution.java
b/iceberg/iceberg-handler/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergSchemaEvolution.java
index 9bd3393efc5..774fbfb52df 100644
---
a/iceberg/iceberg-handler/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergSchemaEvolution.java
+++
b/iceberg/iceberg-handler/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergSchemaEvolution.java
@@ -255,6 +255,47 @@ private static void assertQueryResult(List<Object[]>
result, int expectedCount,
}
}
+ @Test
+ public void testDropColumnFromIcebergTable() throws IOException {
+ Table icebergTable =
+ testTables.createTable(shell, "customers",
HiveIcebergStorageHandlerTestUtils.CUSTOMER_SCHEMA, fileFormat,
+ HiveIcebergStorageHandlerTestUtils.CUSTOMER_RECORDS);
+
+ // drop a column
+ icebergTable.updateSchema().deleteColumn("last_name").commit();
+
+ if (testTableType != TestTables.TestTableType.HIVE_CATALOG) {
+ // We need to update columns for non-Hive catalogs
+ shell.executeStatement("ALTER TABLE customers UPDATE COLUMNS");
+ }
+
+ Schema customerSchemaWithAge = new Schema(optional(1, "customer_id",
Types.LongType.get()),
+ optional(2, "first_name", Types.StringType.get(), "This is first
name"));
+
+ icebergTable = testTables.loadTable(TableIdentifier.of("default",
"customers"));
+ List<Record> newCustomerWithAge =
+ TestHelper.RecordsBuilder.newInstance(customerSchemaWithAge).add(3L,
"James").add(4L, "Lily").build();
+
+ testTables.appendIcebergTable(shell.getHiveConf(), icebergTable,
fileFormat, null, newCustomerWithAge);
+
+ TestHelper.RecordsBuilder customersWithAgeBuilder =
+ TestHelper.RecordsBuilder.newInstance(customerSchemaWithAge).add(0L,
"Alice").add(1L, "Bob").add(2L, "Trudy")
+ .add(3L, "James").add(4L, "Lily");
+ List<Record> customersWithAge = customersWithAgeBuilder.build();
+
+ List<Object[]> rows = shell.executeStatement("SELECT * FROM
default.customers");
+ HiveIcebergTestUtils.validateData(customersWithAge,
HiveIcebergTestUtils.valueForRow(customerSchemaWithAge, rows),
+ 0);
+
+ shell.executeStatement("INSERT INTO default.customers values (5L, 'Lily'),
(6L, 'Roni')");
+
+ customersWithAgeBuilder.add(5L, "Lily").add(6L, "Roni");
+ customersWithAge = customersWithAgeBuilder.build();
+ rows = shell.executeStatement("SELECT * FROM default.customers");
+ HiveIcebergTestUtils.validateData(customersWithAge,
HiveIcebergTestUtils.valueForRow(customerSchemaWithAge, rows),
+ 0);
+ }
+
@Test
public void testAddColumnToIcebergTable() throws IOException {
// Create an Iceberg table with the columns customer_id, first_name and
last_name with some initial data.
diff --git
a/iceberg/iceberg-handler/src/test/queries/negative/iceberg_drop_column.q
b/iceberg/iceberg-handler/src/test/queries/negative/iceberg_drop_column.q
new file mode 100644
index 00000000000..65608abd030
--- /dev/null
+++ b/iceberg/iceberg-handler/src/test/queries/negative/iceberg_drop_column.q
@@ -0,0 +1,14 @@
+-- SORT_QUERY_RESULTS
+set hive.cli.print.header=true;
+
+create external table ice_tbl (
+ strcol string,
+ intcol integer,
+ pcol string,
+ datecol date
+) partitioned by spec (pcol, datecol)
+stored by iceberg;
+
+show columns in ice_tbl;
+
+alter table ice_tbl drop column misscol;
diff --git
a/iceberg/iceberg-handler/src/test/queries/positive/iceberg_drop_column.q
b/iceberg/iceberg-handler/src/test/queries/positive/iceberg_drop_column.q
new file mode 100644
index 00000000000..ee73a9ef83d
--- /dev/null
+++ b/iceberg/iceberg-handler/src/test/queries/positive/iceberg_drop_column.q
@@ -0,0 +1,51 @@
+-- SORT_QUERY_RESULTS
+set hive.cli.print.header=true;
+
+create external table ice_tbl (
+ strcol string,
+ intcol integer,
+ pcol string,
+ datecol date
+) partitioned by spec (pcol, datecol)
+stored by iceberg;
+
+desc ice_tbl;
+
+insert into ice_tbl values ('str', 1, 'xya', '2027-01-20');
+insert into ice_tbl values ('str', 1, 'xyz', '2026-07-19');
+insert into ice_tbl values ('str', 1, 'xyb', '2025-07-18');
+insert into ice_tbl values ('str', 2, 'yzb', '2023-07-26');
+insert into ice_tbl values ('str', 1, 'yab', '2023-07-26');
+insert into ice_tbl values ('str', 1, 'yzb', '2023-07-26');
+insert into ice_tbl values ('str', 2, 'xyz', '2026-07-19');
+insert into ice_tbl values ('str', 1, 'abc', '2019-02-07');
+insert into ice_tbl values ('str', 1, 'a"ab', '2019-02-07');
+insert into ice_tbl values ('str', 1, "a'ab", '2019-02-07');
+
+show partitions ice_tbl;
+
+show columns in ice_tbl;
+
+select * from ice_tbl;
+
+explain alter table ice_tbl drop column intcol;
+
+alter table ice_tbl drop column intcol;
+
+show columns in ice_tbl;
+
+select * from ice_tbl;
+
+explain alter table ice_tbl drop column if exists intcol;
+
+alter table ice_tbl drop column if exists intcol;
+
+show columns in ice_tbl;
+
+select * from ice_tbl;
+
+alter table ice_tbl drop column if exists strcol;
+
+show columns in ice_tbl;
+
+select * from ice_tbl;
diff --git
a/iceberg/iceberg-handler/src/test/results/negative/iceberg_drop_column.q.out
b/iceberg/iceberg-handler/src/test/results/negative/iceberg_drop_column.q.out
new file mode 100644
index 00000000000..9e1d0dd92ed
--- /dev/null
+++
b/iceberg/iceberg-handler/src/test/results/negative/iceberg_drop_column.q.out
@@ -0,0 +1,36 @@
+PREHOOK: query: create external table ice_tbl (
+ strcol string,
+ intcol integer,
+ pcol string,
+ datecol date
+) partitioned by spec (pcol, datecol)
+stored by iceberg
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@ice_tbl
+POSTHOOK: query: create external table ice_tbl (
+ strcol string,
+ intcol integer,
+ pcol string,
+ datecol date
+) partitioned by spec (pcol, datecol)
+stored by iceberg
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@ice_tbl
+PREHOOK: query: show columns in ice_tbl
+PREHOOK: type: SHOWCOLUMNS
+PREHOOK: Input: default@ice_tbl
+POSTHOOK: query: show columns in ice_tbl
+POSTHOOK: type: SHOWCOLUMNS
+POSTHOOK: Input: default@ice_tbl
+field
+strcol
+intcol
+pcol
+datecol
+PREHOOK: query: alter table ice_tbl drop column misscol
+PREHOOK: type: ALTERTABLE_DROPCOL
+PREHOOK: Input: default@ice_tbl
+PREHOOK: Output: default@ice_tbl
+FAILED: Execution Error, return code 10328 from
org.apache.hadoop.hive.ql.ddl.DDLTask. Invalid column name misscol
diff --git
a/iceberg/iceberg-handler/src/test/results/positive/iceberg_drop_column.q.out
b/iceberg/iceberg-handler/src/test/results/positive/iceberg_drop_column.q.out
new file mode 100644
index 00000000000..c7e7c4e4acf
--- /dev/null
+++
b/iceberg/iceberg-handler/src/test/results/positive/iceberg_drop_column.q.out
@@ -0,0 +1,305 @@
+PREHOOK: query: create external table ice_tbl (
+ strcol string,
+ intcol integer,
+ pcol string,
+ datecol date
+) partitioned by spec (pcol, datecol)
+stored by iceberg
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@ice_tbl
+POSTHOOK: query: create external table ice_tbl (
+ strcol string,
+ intcol integer,
+ pcol string,
+ datecol date
+) partitioned by spec (pcol, datecol)
+stored by iceberg
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@ice_tbl
+PREHOOK: query: desc ice_tbl
+PREHOOK: type: DESCTABLE
+PREHOOK: Input: default@ice_tbl
+POSTHOOK: query: desc ice_tbl
+POSTHOOK: type: DESCTABLE
+POSTHOOK: Input: default@ice_tbl
+col_name data_type comment
+strcol string
+intcol int
+pcol string
+datecol date
+
+# Partition Transform Information
+# col_name transform_type
+pcol IDENTITY
+datecol IDENTITY
+PREHOOK: query: insert into ice_tbl values ('str', 1, 'xya', '2027-01-20')
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+PREHOOK: Output: default@ice_tbl
+POSTHOOK: query: insert into ice_tbl values ('str', 1, 'xya', '2027-01-20')
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+POSTHOOK: Output: default@ice_tbl
+_col0 _col1 _col2 _col3
+PREHOOK: query: insert into ice_tbl values ('str', 1, 'xyz', '2026-07-19')
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+PREHOOK: Output: default@ice_tbl
+POSTHOOK: query: insert into ice_tbl values ('str', 1, 'xyz', '2026-07-19')
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+POSTHOOK: Output: default@ice_tbl
+_col0 _col1 _col2 _col3
+PREHOOK: query: insert into ice_tbl values ('str', 1, 'xyb', '2025-07-18')
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+PREHOOK: Output: default@ice_tbl
+POSTHOOK: query: insert into ice_tbl values ('str', 1, 'xyb', '2025-07-18')
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+POSTHOOK: Output: default@ice_tbl
+_col0 _col1 _col2 _col3
+PREHOOK: query: insert into ice_tbl values ('str', 2, 'yzb', '2023-07-26')
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+PREHOOK: Output: default@ice_tbl
+POSTHOOK: query: insert into ice_tbl values ('str', 2, 'yzb', '2023-07-26')
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+POSTHOOK: Output: default@ice_tbl
+_col0 _col1 _col2 _col3
+PREHOOK: query: insert into ice_tbl values ('str', 1, 'yab', '2023-07-26')
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+PREHOOK: Output: default@ice_tbl
+POSTHOOK: query: insert into ice_tbl values ('str', 1, 'yab', '2023-07-26')
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+POSTHOOK: Output: default@ice_tbl
+_col0 _col1 _col2 _col3
+PREHOOK: query: insert into ice_tbl values ('str', 1, 'yzb', '2023-07-26')
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+PREHOOK: Output: default@ice_tbl
+POSTHOOK: query: insert into ice_tbl values ('str', 1, 'yzb', '2023-07-26')
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+POSTHOOK: Output: default@ice_tbl
+_col0 _col1 _col2 _col3
+PREHOOK: query: insert into ice_tbl values ('str', 2, 'xyz', '2026-07-19')
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+PREHOOK: Output: default@ice_tbl
+POSTHOOK: query: insert into ice_tbl values ('str', 2, 'xyz', '2026-07-19')
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+POSTHOOK: Output: default@ice_tbl
+_col0 _col1 _col2 _col3
+PREHOOK: query: insert into ice_tbl values ('str', 1, 'abc', '2019-02-07')
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+PREHOOK: Output: default@ice_tbl
+POSTHOOK: query: insert into ice_tbl values ('str', 1, 'abc', '2019-02-07')
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+POSTHOOK: Output: default@ice_tbl
+_col0 _col1 _col2 _col3
+PREHOOK: query: insert into ice_tbl values ('str', 1, 'a"ab', '2019-02-07')
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+PREHOOK: Output: default@ice_tbl
+POSTHOOK: query: insert into ice_tbl values ('str', 1, 'a"ab', '2019-02-07')
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+POSTHOOK: Output: default@ice_tbl
+_col0 _col1 _col2 _col3
+PREHOOK: query: insert into ice_tbl values ('str', 1, "a'ab", '2019-02-07')
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+PREHOOK: Output: default@ice_tbl
+POSTHOOK: query: insert into ice_tbl values ('str', 1, "a'ab", '2019-02-07')
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+POSTHOOK: Output: default@ice_tbl
+_col0 _col1 _col2 _col3
+PREHOOK: query: show partitions ice_tbl
+PREHOOK: type: SHOWPARTITIONS
+PREHOOK: Input: default@ice_tbl
+POSTHOOK: query: show partitions ice_tbl
+POSTHOOK: type: SHOWPARTITIONS
+POSTHOOK: Input: default@ice_tbl
+partition
+pcol=a%22ab/datecol=2019-02-07
+pcol=a%27ab/datecol=2019-02-07
+pcol=abc/datecol=2019-02-07
+pcol=xya/datecol=2027-01-20
+pcol=xyb/datecol=2025-07-18
+pcol=xyz/datecol=2026-07-19
+pcol=yab/datecol=2023-07-26
+pcol=yzb/datecol=2023-07-26
+PREHOOK: query: show columns in ice_tbl
+PREHOOK: type: SHOWCOLUMNS
+PREHOOK: Input: default@ice_tbl
+POSTHOOK: query: show columns in ice_tbl
+POSTHOOK: type: SHOWCOLUMNS
+POSTHOOK: Input: default@ice_tbl
+field
+strcol
+intcol
+pcol
+datecol
+PREHOOK: query: select * from ice_tbl
+PREHOOK: type: QUERY
+PREHOOK: Input: default@ice_tbl
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: select * from ice_tbl
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@ice_tbl
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+ice_tbl.strcol ice_tbl.intcol ice_tbl.pcol ice_tbl.datecol
+str 1 a"ab 2019-02-07
+str 1 a'ab 2019-02-07
+str 1 abc 2019-02-07
+str 1 xya 2027-01-20
+str 1 xyb 2025-07-18
+str 1 xyz 2026-07-19
+str 1 yab 2023-07-26
+str 1 yzb 2023-07-26
+str 2 xyz 2026-07-19
+str 2 yzb 2023-07-26
+PREHOOK: query: explain alter table ice_tbl drop column intcol
+PREHOOK: type: ALTERTABLE_DROPCOL
+PREHOOK: Input: default@ice_tbl
+PREHOOK: Output: default@ice_tbl
+POSTHOOK: query: explain alter table ice_tbl drop column intcol
+POSTHOOK: type: ALTERTABLE_DROPCOL
+POSTHOOK: Input: default@ice_tbl
+POSTHOOK: Output: default@ice_tbl
+Explain
+Stage-0
+ Drop Column{"column name:":"intcol","table name:":"default.ice_tbl"}
+
+PREHOOK: query: alter table ice_tbl drop column intcol
+PREHOOK: type: ALTERTABLE_DROPCOL
+PREHOOK: Input: default@ice_tbl
+PREHOOK: Output: default@ice_tbl
+POSTHOOK: query: alter table ice_tbl drop column intcol
+POSTHOOK: type: ALTERTABLE_DROPCOL
+POSTHOOK: Input: default@ice_tbl
+POSTHOOK: Output: default@ice_tbl
+PREHOOK: query: show columns in ice_tbl
+PREHOOK: type: SHOWCOLUMNS
+PREHOOK: Input: default@ice_tbl
+POSTHOOK: query: show columns in ice_tbl
+POSTHOOK: type: SHOWCOLUMNS
+POSTHOOK: Input: default@ice_tbl
+field
+strcol
+pcol
+datecol
+PREHOOK: query: select * from ice_tbl
+PREHOOK: type: QUERY
+PREHOOK: Input: default@ice_tbl
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: select * from ice_tbl
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@ice_tbl
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+ice_tbl.strcol ice_tbl.pcol ice_tbl.datecol
+str a"ab 2019-02-07
+str a'ab 2019-02-07
+str abc 2019-02-07
+str xya 2027-01-20
+str xyb 2025-07-18
+str xyz 2026-07-19
+str xyz 2026-07-19
+str yab 2023-07-26
+str yzb 2023-07-26
+str yzb 2023-07-26
+PREHOOK: query: explain alter table ice_tbl drop column if exists intcol
+PREHOOK: type: ALTERTABLE_DROPCOL
+PREHOOK: Input: default@ice_tbl
+PREHOOK: Output: default@ice_tbl
+POSTHOOK: query: explain alter table ice_tbl drop column if exists intcol
+POSTHOOK: type: ALTERTABLE_DROPCOL
+POSTHOOK: Input: default@ice_tbl
+POSTHOOK: Output: default@ice_tbl
+Explain
+Stage-0
+ Drop Column{"column name:":"intcol","table name:":"default.ice_tbl"}
+
+PREHOOK: query: alter table ice_tbl drop column if exists intcol
+PREHOOK: type: ALTERTABLE_DROPCOL
+PREHOOK: Input: default@ice_tbl
+PREHOOK: Output: default@ice_tbl
+POSTHOOK: query: alter table ice_tbl drop column if exists intcol
+POSTHOOK: type: ALTERTABLE_DROPCOL
+POSTHOOK: Input: default@ice_tbl
+POSTHOOK: Output: default@ice_tbl
+PREHOOK: query: show columns in ice_tbl
+PREHOOK: type: SHOWCOLUMNS
+PREHOOK: Input: default@ice_tbl
+POSTHOOK: query: show columns in ice_tbl
+POSTHOOK: type: SHOWCOLUMNS
+POSTHOOK: Input: default@ice_tbl
+field
+strcol
+pcol
+datecol
+PREHOOK: query: select * from ice_tbl
+PREHOOK: type: QUERY
+PREHOOK: Input: default@ice_tbl
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: select * from ice_tbl
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@ice_tbl
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+ice_tbl.strcol ice_tbl.pcol ice_tbl.datecol
+str a"ab 2019-02-07
+str a'ab 2019-02-07
+str abc 2019-02-07
+str xya 2027-01-20
+str xyb 2025-07-18
+str xyz 2026-07-19
+str xyz 2026-07-19
+str yab 2023-07-26
+str yzb 2023-07-26
+str yzb 2023-07-26
+PREHOOK: query: alter table ice_tbl drop column if exists strcol
+PREHOOK: type: ALTERTABLE_DROPCOL
+PREHOOK: Input: default@ice_tbl
+PREHOOK: Output: default@ice_tbl
+POSTHOOK: query: alter table ice_tbl drop column if exists strcol
+POSTHOOK: type: ALTERTABLE_DROPCOL
+POSTHOOK: Input: default@ice_tbl
+POSTHOOK: Output: default@ice_tbl
+PREHOOK: query: show columns in ice_tbl
+PREHOOK: type: SHOWCOLUMNS
+PREHOOK: Input: default@ice_tbl
+POSTHOOK: query: show columns in ice_tbl
+POSTHOOK: type: SHOWCOLUMNS
+POSTHOOK: Input: default@ice_tbl
+field
+pcol
+datecol
+PREHOOK: query: select * from ice_tbl
+PREHOOK: type: QUERY
+PREHOOK: Input: default@ice_tbl
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: select * from ice_tbl
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@ice_tbl
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+ice_tbl.pcol ice_tbl.datecol
+a"ab 2019-02-07
+a'ab 2019-02-07
+abc 2019-02-07
+xya 2027-01-20
+xyb 2025-07-18
+xyz 2026-07-19
+xyz 2026-07-19
+yab 2023-07-26
+yzb 2023-07-26
+yzb 2023-07-26
diff --git
a/parser/src/java/org/apache/hadoop/hive/ql/parse/AlterClauseParser.g
b/parser/src/java/org/apache/hadoop/hive/ql/parse/AlterClauseParser.g
index 7277e97d468..4f37ce7bca5 100644
--- a/parser/src/java/org/apache/hadoop/hive/ql/parse/AlterClauseParser.g
+++ b/parser/src/java/org/apache/hadoop/hive/ql/parse/AlterClauseParser.g
@@ -103,6 +103,7 @@ alterTblPartitionStatementSuffix[boolean partition]
| alterStatementSuffixUpdateStats[partition]
| alterStatementSuffixRenameCol
| alterStatementSuffixAddCol
+ | alterStatementSuffixDropCol
| alterStatementSuffixUpdateColumns
;
@@ -223,6 +224,13 @@ alterStatementSuffixAddCol
-> ^(TOK_ALTERTABLE_REPLACECOLS columnNameTypeList
restrictOrCascade?)
;
+alterStatementSuffixDropCol
+@init { gParent.pushMsg("drop column statement", state); }
+@after { gParent.popMsg(state); }
+ : KW_DROP KW_COLUMN ifExists? columnName restrictOrCascade?
+ -> ^(TOK_ALTERTABLE_DROPCOL ifExists? columnName restrictOrCascade?)
+ ;
+
alterStatementSuffixAddConstraint
@init { gParent.pushMsg("add constraint statement", state); }
@after { gParent.popMsg(state); }
diff --git a/parser/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g
b/parser/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g
index 44645bccc1a..8a093ce0030 100644
--- a/parser/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g
+++ b/parser/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g
@@ -176,6 +176,7 @@ TOK_DESCFUNCTION;
TOK_ALTERTABLE;
TOK_ALTERTABLE_RENAME;
TOK_ALTERTABLE_ADDCOLS;
+TOK_ALTERTABLE_DROPCOL;
TOK_ALTERTABLE_RENAMECOL;
TOK_ALTERTABLE_RENAMEPART;
TOK_ALTERTABLE_REPLACECOLS;
diff --git
a/ql/src/java/org/apache/hadoop/hive/ql/ddl/table/AlterTableType.java
b/ql/src/java/org/apache/hadoop/hive/ql/ddl/table/AlterTableType.java
index 0926c6aa53a..eeac095811e 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/table/AlterTableType.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/table/AlterTableType.java
@@ -30,6 +30,7 @@
public enum AlterTableType {
// column
ADDCOLS("add columns"),
+ DROP_COLUMN("drop column"),
REPLACE_COLUMNS("replace columns"),
RENAME_COLUMN("rename column"),
UPDATE_COLUMNS("update columns"),
@@ -88,6 +89,6 @@ public String getName() {
ImmutableList.of(ADDPROPS, DROPPROPS, ADDCOLS, EXECUTE);
public static final Set<AlterTableType> SUPPORT_PARTIAL_PARTITION_SPEC =
- ImmutableSet.of(ADDCOLS, REPLACE_COLUMNS, RENAME_COLUMN, ADDPROPS,
DROPPROPS, SET_SERDE,
+ ImmutableSet.of(ADDCOLS, DROP_COLUMN, REPLACE_COLUMNS, RENAME_COLUMN,
ADDPROPS, DROPPROPS, SET_SERDE,
SET_SERDE_PROPS, SET_FILE_FORMAT);
}
diff --git
a/ql/src/java/org/apache/hadoop/hive/ql/ddl/table/column/drop/AlterTableDropColumnAnalyser.java
b/ql/src/java/org/apache/hadoop/hive/ql/ddl/table/column/drop/AlterTableDropColumnAnalyser.java
new file mode 100644
index 00000000000..1db56610820
--- /dev/null
+++
b/ql/src/java/org/apache/hadoop/hive/ql/ddl/table/column/drop/AlterTableDropColumnAnalyser.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.ql.ddl.table.column.drop;
+
+import java.util.Map;
+
+import org.apache.hadoop.hive.common.TableName;
+import org.apache.hadoop.hive.ql.QueryState;
+import org.apache.hadoop.hive.ql.ddl.DDLWork;
+import org.apache.hadoop.hive.ql.ddl.DDLSemanticAnalyzerFactory.DDLType;
+import org.apache.hadoop.hive.ql.ddl.table.AbstractAlterTableAnalyzer;
+import org.apache.hadoop.hive.ql.exec.TaskFactory;
+import org.apache.hadoop.hive.ql.io.AcidUtils;
+import org.apache.hadoop.hive.ql.metadata.Table;
+import org.apache.hadoop.hive.ql.parse.ASTNode;
+import org.apache.hadoop.hive.ql.parse.HiveParser;
+import org.apache.hadoop.hive.ql.parse.SemanticException;
+
+/**
+ * Analyzer for drop column command.
+ */
+@DDLType(types = HiveParser.TOK_ALTERTABLE_DROPCOL)
+public class AlterTableDropColumnAnalyser extends AbstractAlterTableAnalyzer {
+
+ public AlterTableDropColumnAnalyser(QueryState queryState) throws
SemanticException {
+ super(queryState);
+ }
+
+ @Override
+ protected void analyzeCommand(TableName tableName, Map<String, String>
partitionSpec, ASTNode command)
+ throws SemanticException {
+ boolean ifExists = command.getFirstChildWithType(HiveParser.TOK_IFEXISTS)
!= null;
+ String colName = command.getChild((ifExists) ? 1 :
0).getText().toLowerCase();
+ boolean isCascade = command.getFirstChildWithType(HiveParser.TOK_CASCADE)
!= null;
+ AlterTableDropColumnDesc desc =
+ new AlterTableDropColumnDesc(tableName, partitionSpec, isCascade,
colName, ifExists);
+ Table table = getTable(tableName, true);
+ addInputsOutputsAlterTable(tableName, partitionSpec, desc, desc.getType(),
false);
+ rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(),
desc)));
+ }
+}
diff --git
a/ql/src/java/org/apache/hadoop/hive/ql/ddl/table/column/drop/AlterTableDropColumnDesc.java
b/ql/src/java/org/apache/hadoop/hive/ql/ddl/table/column/drop/AlterTableDropColumnDesc.java
new file mode 100644
index 00000000000..91f02961c80
--- /dev/null
+++
b/ql/src/java/org/apache/hadoop/hive/ql/ddl/table/column/drop/AlterTableDropColumnDesc.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.ql.ddl.table.column.drop;
+
+import java.util.Map;
+
+import org.apache.hadoop.hive.common.TableName;
+import org.apache.hadoop.hive.ql.ddl.table.AbstractAlterTableDesc;
+import org.apache.hadoop.hive.ql.ddl.table.AlterTableType;
+import org.apache.hadoop.hive.ql.parse.SemanticException;
+import org.apache.hadoop.hive.ql.plan.Explain;
+import org.apache.hadoop.hive.ql.plan.Explain.Level;
+
+/**
+ * DDL task description for ALTER TABLE ... DROP COLUMN ... command.
+ */
+@Explain(displayName = "Drop Column", explainLevels = { Level.USER,
Level.DEFAULT, Level.EXTENDED })
+public class AlterTableDropColumnDesc extends AbstractAlterTableDesc {
+ private static final long serialVersionUID = 1L;
+ private final String colName;
+ private final boolean ifExists;
+
+ public AlterTableDropColumnDesc(TableName tableName, Map<String, String>
partitionSpec, boolean isCascade,
+ String colName, boolean ifExists) throws SemanticException {
+ super(AlterTableType.DROP_COLUMN, tableName, partitionSpec, null,
isCascade, false, null);
+ this.colName = colName;
+ this.ifExists = ifExists;
+ }
+
+ @Explain(displayName = "column name", explainLevels = { Level.USER,
Level.DEFAULT, Level.EXTENDED })
+ public String getColName() {
+ return colName;
+ }
+
+ public boolean isIfExists() {
+ return ifExists;
+ }
+
+ @Override
+ public boolean mayNeedWriteId() {
+ return true;
+ }
+}
diff --git
a/ql/src/java/org/apache/hadoop/hive/ql/ddl/table/column/replace/AlterTableReplaceColumnsOperation.java
b/ql/src/java/org/apache/hadoop/hive/ql/ddl/table/column/drop/AlterTableDropColumnOperation.java
similarity index 54%
copy from
ql/src/java/org/apache/hadoop/hive/ql/ddl/table/column/replace/AlterTableReplaceColumnsOperation.java
copy to
ql/src/java/org/apache/hadoop/hive/ql/ddl/table/column/drop/AlterTableDropColumnOperation.java
index ac4e939d511..1924ba79782 100644
---
a/ql/src/java/org/apache/hadoop/hive/ql/ddl/table/column/replace/AlterTableReplaceColumnsOperation.java
+++
b/ql/src/java/org/apache/hadoop/hive/ql/ddl/table/column/drop/AlterTableDropColumnOperation.java
@@ -16,71 +16,71 @@
* limitations under the License.
*/
-package org.apache.hadoop.hive.ql.ddl.table.column.replace;
-
-import java.util.List;
-import java.util.Set;
+package org.apache.hadoop.hive.ql.ddl.table.column.drop;
+import com.google.common.collect.ImmutableSet;
import org.apache.hadoop.hive.metastore.api.FieldSchema;
import org.apache.hadoop.hive.metastore.api.StorageDescriptor;
import org.apache.hadoop.hive.ql.ErrorMsg;
import org.apache.hadoop.hive.ql.ddl.DDLOperationContext;
-import org.apache.hadoop.hive.ql.ddl.table.AlterTableUtils;
import org.apache.hadoop.hive.ql.ddl.table.AbstractAlterTableOperation;
+import org.apache.hadoop.hive.ql.ddl.table.AlterTableUtils;
import org.apache.hadoop.hive.ql.io.orc.OrcSerde;
import org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe;
import org.apache.hadoop.hive.ql.metadata.HiveException;
import org.apache.hadoop.hive.ql.metadata.Partition;
import org.apache.hadoop.hive.ql.metadata.Table;
import org.apache.hadoop.hive.serde2.MetadataTypedColumnsetSerDe;
+import org.apache.hadoop.hive.serde2.avro.AvroSerdeUtils;
import org.apache.hadoop.hive.serde2.columnar.ColumnarSerDe;
import org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe;
-import com.google.common.collect.ImmutableSet;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
/**
- * Operation process of replacing two columns.
+ * Operation process of dropping column.
*/
-public class AlterTableReplaceColumnsOperation extends
AbstractAlterTableOperation<AlterTableReplaceColumnsDesc> {
- public AlterTableReplaceColumnsOperation(DDLOperationContext context,
AlterTableReplaceColumnsDesc desc) {
+public class AlterTableDropColumnOperation extends
AbstractAlterTableOperation<AlterTableDropColumnDesc> {
+
+ public AlterTableDropColumnOperation(DDLOperationContext context,
AlterTableDropColumnDesc desc) {
super(context, desc);
}
- private static final Set<String> VALID_SERIALIZATION_LIBS = ImmutableSet.of(
- MetadataTypedColumnsetSerDe.class.getName(),
LazySimpleSerDe.class.getName(), ColumnarSerDe.class.getName(),
- ParquetHiveSerDe.class.getName(), OrcSerde.class.getName(),
"org.apache.iceberg.mr.hive.HiveIcebergSerDe");
-
@Override
protected void doAlteration(Table table, Partition partition) throws
HiveException {
StorageDescriptor sd = getStorageDescriptor(table, partition);
- // change SerDe to LazySimpleSerDe if it is columnsetSerDe
String serializationLib = sd.getSerdeInfo().getSerializationLib();
+ AvroSerdeUtils.handleAlterTableForAvro(context.getConf(),
serializationLib, table.getTTable().getParameters());
+
if
("org.apache.hadoop.hive.serde.thrift.columnsetSerDe".equals(serializationLib))
{
- context.getConsole().printInfo("Replacing columns for columnsetSerDe and
changing to LazySimpleSerDe");
+ context.getConsole().printInfo("Dropping column for columnsetSerDe and
changing to LazySimpleSerDe");
sd.getSerdeInfo().setSerializationLib(LazySimpleSerDe.class.getName());
- } else if (!VALID_SERIALIZATION_LIBS.contains(serializationLib)) {
- throw new HiveException(ErrorMsg.CANNOT_REPLACE_COLUMNS,
desc.getDbTableName());
}
- // adding columns and limited integer type promotion is not supported for
ORC schema evolution
- boolean isOrcSchemaEvolution =
serializationLib.equals(OrcSerde.class.getName()) &&
- AlterTableUtils.isSchemaEvolutionEnabled(table, context.getConf());
+ boolean isOrcSchemaEvolution =
+ serializationLib.equals(OrcSerde.class.getName()) &&
AlterTableUtils.isSchemaEvolutionEnabled(table,
+ context.getConf());
if (isOrcSchemaEvolution) {
- List<FieldSchema> existingCols = sd.getCols();
- List<FieldSchema> replaceCols = desc.getNewColumns();
+ throw new HiveException(ErrorMsg.CANNOT_DROP_COLUMN,
desc.getDbTableName());
+ }
- if (replaceCols.size() < existingCols.size()) {
- throw new HiveException(ErrorMsg.REPLACE_CANNOT_DROP_COLUMNS,
desc.getDbTableName());
- }
+ if (ParquetHiveSerDe.isParquetTable(table) &&
AlterTableUtils.isSchemaEvolutionEnabled(table,
+ context.getConf()) && !desc.isCascade() && table.isPartitioned()) {
+ LOG.warn("Cannot drop column from a partitioned parquet table without
the CASCADE option");
+ throw new HiveException(ErrorMsg.DROP_COLUMN_UNCASCADED,
desc.getDbTableName());
}
- boolean droppingColumns = desc.getNewColumns().size() <
sd.getCols().size();
- if (ParquetHiveSerDe.isParquetTable(table) &&
AlterTableUtils.isSchemaEvolutionEnabled(table, context.getConf()) &&
- !desc.isCascade() && droppingColumns && table.isPartitioned()) {
- LOG.warn("Cannot drop columns from a partitioned parquet table without
the CASCADE option");
- throw new HiveException(ErrorMsg.REPLACE_CANNOT_DROP_COLUMNS,
desc.getDbTableName());
+ List<FieldSchema> cols = new ArrayList<>(sd.getCols());
+ boolean removed = cols.removeIf(col ->
col.getName().equalsIgnoreCase(desc.getColName()));
+ if (!removed) {
+ if (desc.isIfExists()) {
+ return;
+ }
+ throw new HiveException(ErrorMsg.INVALID_COLUMN_NAME, desc.getColName());
}
- sd.setCols(desc.getNewColumns());
+ sd.setCols(cols);
}
}
diff --git
a/ql/src/java/org/apache/hadoop/hive/ql/ddl/table/column/replace/AlterTableReplaceColumnsOperation.java
b/ql/src/java/org/apache/hadoop/hive/ql/ddl/table/column/replace/AlterTableReplaceColumnsOperation.java
index ac4e939d511..eec274313d3 100644
---
a/ql/src/java/org/apache/hadoop/hive/ql/ddl/table/column/replace/AlterTableReplaceColumnsOperation.java
+++
b/ql/src/java/org/apache/hadoop/hive/ql/ddl/table/column/replace/AlterTableReplaceColumnsOperation.java
@@ -78,7 +78,7 @@ protected void doAlteration(Table table, Partition partition)
throws HiveExcepti
if (ParquetHiveSerDe.isParquetTable(table) &&
AlterTableUtils.isSchemaEvolutionEnabled(table, context.getConf()) &&
!desc.isCascade() && droppingColumns && table.isPartitioned()) {
LOG.warn("Cannot drop columns from a partitioned parquet table without
the CASCADE option");
- throw new HiveException(ErrorMsg.REPLACE_CANNOT_DROP_COLUMNS,
desc.getDbTableName());
+ throw new HiveException(ErrorMsg.DROP_COLUMN_UNCASCADED,
desc.getDbTableName());
}
sd.setCols(desc.getNewColumns());
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/hooks/WriteEntity.java
b/ql/src/java/org/apache/hadoop/hive/ql/hooks/WriteEntity.java
index 6563e460970..96b701eb955 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/hooks/WriteEntity.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/hooks/WriteEntity.java
@@ -255,6 +255,7 @@ public static WriteType
determineAlterTableWriteType(AlterTableType op, Table ta
case SET_SERDE:
// alter table {table_name} [PARTITION ({partition_spec})] set serde
'{serde_class_name}'
case ADDCOLS:
+ case DROP_COLUMN:
case REPLACE_COLUMNS:
// alter table {table_name} [partition ({partition_spec})] add/replace
columns ({col_name} {data_type})
case RENAME_COLUMN:
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/plan/HiveOperation.java
b/ql/src/java/org/apache/hadoop/hive/ql/plan/HiveOperation.java
index a045114720b..1d908bb1bdb 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/plan/HiveOperation.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/plan/HiveOperation.java
@@ -47,6 +47,8 @@ public enum HiveOperation {
MSCK("MSCK", HiveParser.TOK_MSCK, null, null),
ALTERTABLE_ADDCOLS("ALTERTABLE_ADDCOLS", HiveParser.TOK_ALTERTABLE_ADDCOLS,
new Privilege[]{Privilege.ALTER_METADATA},
null),
+ ALTERTABLE_DROPCOL("ALTERTABLE_DROPCOL", HiveParser.TOK_ALTERTABLE_DROPCOL,
new Privilege[]{Privilege.ALTER_METADATA},
+ null),
ALTERTABLE_REPLACECOLS("ALTERTABLE_REPLACECOLS",
HiveParser.TOK_ALTERTABLE_REPLACECOLS,
new Privilege[]{Privilege.ALTER_METADATA}, null),
ALTERTABLE_RENAMECOL("ALTERTABLE_RENAMECOL",
HiveParser.TOK_ALTERTABLE_RENAMECOL,
diff --git
a/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/HiveOperationType.java
b/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/HiveOperationType.java
index 0fbcf6d22aa..6c84e31fc9e 100644
---
a/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/HiveOperationType.java
+++
b/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/HiveOperationType.java
@@ -49,6 +49,7 @@ public enum HiveOperationType {
EXECUTE,
MSCK,
ALTERTABLE_ADDCOLS,
+ ALTERTABLE_DROPCOL,
ALTERTABLE_REPLACECOLS,
ALTERTABLE_RENAMECOL,
ALTERTABLE_RENAMEPART,
diff --git
a/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/sqlstd/Operation2Privilege.java
b/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/sqlstd/Operation2Privilege.java
index b727a3a6d25..d5869c2f4f5 100644
---
a/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/sqlstd/Operation2Privilege.java
+++
b/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/sqlstd/Operation2Privilege.java
@@ -166,6 +166,8 @@ public HivePrivilegeObjectType getObjectType() {
// to output instead of input, adding owner requirement on output will
catch that as well
op2Priv.put(HiveOperationType.ALTERTABLE_ADDCOLS,
PrivRequirement.newIOPrivRequirement(OWNER_PRIV_AR, OWNER_PRIV_AR));
+ op2Priv.put(HiveOperationType. ALTERTABLE_DROPCOL,
+ PrivRequirement.newIOPrivRequirement(OWNER_PRIV_AR,
OWNER_PRIV_AR));
op2Priv.put(HiveOperationType.ALTERTABLE_REPLACECOLS,
PrivRequirement.newIOPrivRequirement(OWNER_PRIV_AR, OWNER_PRIV_AR));
op2Priv.put(HiveOperationType.ALTERTABLE_RENAMECOL,
diff --git a/ql/src/test/queries/clientnegative/orc_drop_column.q
b/ql/src/test/queries/clientnegative/orc_drop_column.q
new file mode 100644
index 00000000000..647446fc7f0
--- /dev/null
+++ b/ql/src/test/queries/clientnegative/orc_drop_column.q
@@ -0,0 +1,13 @@
+-- SORT_QUERY_RESULTS
+set hive.cli.print.header=true;
+set hive.exec.schema.evolution=false;
+
+drop table if exists tbl_orc;
+
+create external table tbl_orc(a int, b string, c int) partitioned by (d
string) stored as orc;
+
+show columns in tbl_orc;
+
+alter table tbl_orc drop column c cascade;
+
+alter table tbl_orc drop column c cascade;
diff --git a/ql/src/test/queries/clientnegative/orc_drop_column_acid.q
b/ql/src/test/queries/clientnegative/orc_drop_column_acid.q
new file mode 100644
index 00000000000..91467f6c4d9
--- /dev/null
+++ b/ql/src/test/queries/clientnegative/orc_drop_column_acid.q
@@ -0,0 +1,6 @@
+set hive.support.concurrency=true;
+set hive.txn.manager=org.apache.hadoop.hive.ql.lockmgr.DbTxnManager;
+
+SET hive.exec.schema.evolution=false;
+create table src_orc (key tinyint, val string) clustered by (val) into 2
buckets stored as orc TBLPROPERTIES ('transactional'='true');
+alter table src_orc drop column val;
diff --git a/ql/src/test/queries/clientnegative/parquet_drop_column.q
b/ql/src/test/queries/clientnegative/parquet_drop_column.q
new file mode 100644
index 00000000000..1f95ba52307
--- /dev/null
+++ b/ql/src/test/queries/clientnegative/parquet_drop_column.q
@@ -0,0 +1,11 @@
+-- SORT_QUERY_RESULTS
+set hive.cli.print.header=true;
+set hive.exec.schema.evolution=true;
+
+drop table if exists tbl_parq;
+
+create external table tbl_parq(a int, b string, c int) partitioned by (d
string) stored as parquet;
+
+show columns in tbl_parq;
+
+alter table tbl_parq drop column if exists c;
diff --git a/ql/src/test/queries/clientpositive/orc_drop_column.q
b/ql/src/test/queries/clientpositive/orc_drop_column.q
new file mode 100644
index 00000000000..ddd57420197
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/orc_drop_column.q
@@ -0,0 +1,54 @@
+-- SORT_QUERY_RESULTS
+set hive.cli.print.header=true;
+set hive.exec.schema.evolution=false;
+
+drop table if exists tbl_orc;
+
+create external table tbl_orc(a int, b string, c int) partitioned by (d
string) stored as orc;
+
+desc formatted tbl_orc;
+
+insert into table tbl_orc partition (d='one') values (1, "ab", 1), (2, "bc",
3), (3, "cd", 4);
+insert into table tbl_orc partition (d='two') values (4, "bc", 6), (5, "cd",
5);
+insert into table tbl_orc partition (d='three') values (6, "ab", 7), (7, "bc",
8), (8, "cd", 9);
+insert into table tbl_orc partition (d='four') values (9, "ab", 10);
+
+show partitions tbl_orc;
+
+show columns in tbl_orc;
+
+select * from tbl_orc;
+
+explain alter table tbl_orc drop column if exists c cascade;
+
+alter table tbl_orc drop column if exists c cascade;
+
+alter table tbl_orc drop column if exists c cascade;
+
+desc formatted tbl_orc;
+
+desc formatted tbl_orc partition (d='one');
+
+show columns in tbl_orc;
+
+select * from tbl_orc;
+
+create external table tbl_orc2(a int, b string) stored as orc;
+
+desc formatted tbl_orc2;
+
+insert into table tbl_orc2 values (1, "ab"), (2, "bc"), (3, "cd");
+
+show columns in tbl_orc2;
+
+select * from tbl_orc2;
+
+explain alter table tbl_orc2 drop column b;
+
+alter table tbl_orc2 drop column b;
+
+desc formatted tbl_orc2;
+
+show columns in tbl_orc2;
+
+select * from tbl_orc2;
diff --git a/ql/src/test/queries/clientpositive/parquet_drop_column.q
b/ql/src/test/queries/clientpositive/parquet_drop_column.q
new file mode 100644
index 00000000000..effcbe172a7
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/parquet_drop_column.q
@@ -0,0 +1,54 @@
+-- SORT_QUERY_RESULTS
+set hive.cli.print.header=true;
+set hive.exec.schema.evolution=true;
+
+drop table if exists tbl_parq;
+
+create external table tbl_parq(a int, b string, c int) partitioned by (d
string) stored as parquet;
+
+desc formatted tbl_parq;
+
+insert into table tbl_parq partition (d='one') values (1, "ab", 1), (2, "bc",
3), (3, "cd", 4);
+insert into table tbl_parq partition (d='two') values (4, "bc", 6), (5, "cd",
5);
+insert into table tbl_parq partition (d='three') values (6, "ab", 7), (7,
"bc", 8), (8, "cd", 9);
+insert into table tbl_parq partition (d='four') values (9, "ab", 10);
+
+show partitions tbl_parq;
+
+show columns in tbl_parq;
+
+select * from tbl_parq;
+
+explain alter table tbl_parq drop column if exists c cascade;
+
+alter table tbl_parq drop column if exists c cascade;
+
+alter table tbl_parq drop column if exists c cascade;
+
+desc formatted tbl_parq;
+
+desc formatted tbl_parq partition (d='one');
+
+show columns in tbl_parq;
+
+select * from tbl_parq;
+
+create external table tbl_parq2(a int, b string) stored as parquet;
+
+desc formatted tbl_parq2;
+
+insert into table tbl_parq2 values (1, "ab"), (2, "bc"), (3, "cd");
+
+show columns in tbl_parq2;
+
+select * from tbl_parq2;
+
+explain alter table tbl_parq2 drop column b;
+
+alter table tbl_parq2 drop column b;
+
+desc formatted tbl_parq2;
+
+show columns in tbl_parq2;
+
+select * from tbl_parq2;
diff --git a/ql/src/test/results/clientnegative/orc_drop_column.q.out
b/ql/src/test/results/clientnegative/orc_drop_column.q.out
new file mode 100644
index 00000000000..fea4777ad57
--- /dev/null
+++ b/ql/src/test/results/clientnegative/orc_drop_column.q.out
@@ -0,0 +1,38 @@
+PREHOOK: query: drop table if exists tbl_orc
+PREHOOK: type: DROPTABLE
+PREHOOK: Output: database:default
+POSTHOOK: query: drop table if exists tbl_orc
+POSTHOOK: type: DROPTABLE
+POSTHOOK: Output: database:default
+PREHOOK: query: create external table tbl_orc(a int, b string, c int)
partitioned by (d string) stored as orc
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@tbl_orc
+POSTHOOK: query: create external table tbl_orc(a int, b string, c int)
partitioned by (d string) stored as orc
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@tbl_orc
+PREHOOK: query: show columns in tbl_orc
+PREHOOK: type: SHOWCOLUMNS
+PREHOOK: Input: default@tbl_orc
+POSTHOOK: query: show columns in tbl_orc
+POSTHOOK: type: SHOWCOLUMNS
+POSTHOOK: Input: default@tbl_orc
+field
+a
+b
+c
+d
+PREHOOK: query: alter table tbl_orc drop column c cascade
+PREHOOK: type: ALTERTABLE_DROPCOL
+PREHOOK: Input: default@tbl_orc
+PREHOOK: Output: default@tbl_orc
+POSTHOOK: query: alter table tbl_orc drop column c cascade
+POSTHOOK: type: ALTERTABLE_DROPCOL
+POSTHOOK: Input: default@tbl_orc
+POSTHOOK: Output: default@tbl_orc
+PREHOOK: query: alter table tbl_orc drop column c cascade
+PREHOOK: type: ALTERTABLE_DROPCOL
+PREHOOK: Input: default@tbl_orc
+PREHOOK: Output: default@tbl_orc
+FAILED: Execution Error, return code 10328 from
org.apache.hadoop.hive.ql.ddl.DDLTask. Invalid column name c
diff --git a/ql/src/test/results/clientnegative/orc_drop_column_acid.q.out
b/ql/src/test/results/clientnegative/orc_drop_column_acid.q.out
new file mode 100644
index 00000000000..e11847d706c
--- /dev/null
+++ b/ql/src/test/results/clientnegative/orc_drop_column_acid.q.out
@@ -0,0 +1,13 @@
+PREHOOK: query: create table src_orc (key tinyint, val string) clustered by
(val) into 2 buckets stored as orc TBLPROPERTIES ('transactional'='true')
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@src_orc
+POSTHOOK: query: create table src_orc (key tinyint, val string) clustered by
(val) into 2 buckets stored as orc TBLPROPERTIES ('transactional'='true')
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@src_orc
+PREHOOK: query: alter table src_orc drop column val
+PREHOOK: type: ALTERTABLE_DROPCOL
+PREHOOK: Input: default@src_orc
+PREHOOK: Output: default@src_orc
+FAILED: Execution Error, return code 10259 from
org.apache.hadoop.hive.ql.ddl.DDLTask. Drop column is not supported for table
default.src_orc. SerDe may be incompatible.
diff --git
a/ql/src/test/results/clientnegative/parquet_alter_part_table_drop_columns.q.out
b/ql/src/test/results/clientnegative/parquet_alter_part_table_drop_columns.q.out
index 7556aefd393..b7d08b48720 100644
---
a/ql/src/test/results/clientnegative/parquet_alter_part_table_drop_columns.q.out
+++
b/ql/src/test/results/clientnegative/parquet_alter_part_table_drop_columns.q.out
@@ -50,4 +50,4 @@ favnumber int
PREHOOK: type: ALTERTABLE_REPLACECOLS
PREHOOK: Input: default@myparquettable_parted
PREHOOK: Output: default@myparquettable_parted
-FAILED: Execution Error, return code 10313 from
org.apache.hadoop.hive.ql.ddl.DDLTask. Replacing columns cannot drop columns
for table default.myparquettable_parted. SerDe may be incompatible
+FAILED: Execution Error, return code 10266 from
org.apache.hadoop.hive.ql.ddl.DDLTask. Drop column is not supported without
cascade for partitioned table. SerDe may be incompatible.
diff --git a/ql/src/test/results/clientnegative/parquet_drop_column.q.out
b/ql/src/test/results/clientnegative/parquet_drop_column.q.out
new file mode 100644
index 00000000000..b28e60423f2
--- /dev/null
+++ b/ql/src/test/results/clientnegative/parquet_drop_column.q.out
@@ -0,0 +1,30 @@
+PREHOOK: query: drop table if exists tbl_parq
+PREHOOK: type: DROPTABLE
+PREHOOK: Output: database:default
+POSTHOOK: query: drop table if exists tbl_parq
+POSTHOOK: type: DROPTABLE
+POSTHOOK: Output: database:default
+PREHOOK: query: create external table tbl_parq(a int, b string, c int)
partitioned by (d string) stored as parquet
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@tbl_parq
+POSTHOOK: query: create external table tbl_parq(a int, b string, c int)
partitioned by (d string) stored as parquet
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@tbl_parq
+PREHOOK: query: show columns in tbl_parq
+PREHOOK: type: SHOWCOLUMNS
+PREHOOK: Input: default@tbl_parq
+POSTHOOK: query: show columns in tbl_parq
+POSTHOOK: type: SHOWCOLUMNS
+POSTHOOK: Input: default@tbl_parq
+field
+a
+b
+c
+d
+PREHOOK: query: alter table tbl_parq drop column if exists c
+PREHOOK: type: ALTERTABLE_DROPCOL
+PREHOOK: Input: default@tbl_parq
+PREHOOK: Output: default@tbl_parq
+FAILED: Execution Error, return code 10266 from
org.apache.hadoop.hive.ql.ddl.DDLTask. Drop column is not supported without
cascade for partitioned table. SerDe may be incompatible.
diff --git a/ql/src/test/results/clientpositive/llap/orc_drop_column.q.out
b/ql/src/test/results/clientpositive/llap/orc_drop_column.q.out
new file mode 100644
index 00000000000..2cca11a8281
--- /dev/null
+++ b/ql/src/test/results/clientpositive/llap/orc_drop_column.q.out
@@ -0,0 +1,489 @@
+PREHOOK: query: drop table if exists tbl_orc
+PREHOOK: type: DROPTABLE
+PREHOOK: Output: database:default
+POSTHOOK: query: drop table if exists tbl_orc
+POSTHOOK: type: DROPTABLE
+POSTHOOK: Output: database:default
+PREHOOK: query: create external table tbl_orc(a int, b string, c int)
partitioned by (d string) stored as orc
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@tbl_orc
+POSTHOOK: query: create external table tbl_orc(a int, b string, c int)
partitioned by (d string) stored as orc
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@tbl_orc
+PREHOOK: query: desc formatted tbl_orc
+PREHOOK: type: DESCTABLE
+PREHOOK: Input: default@tbl_orc
+POSTHOOK: query: desc formatted tbl_orc
+POSTHOOK: type: DESCTABLE
+POSTHOOK: Input: default@tbl_orc
+col_name data_type comment
+# col_name data_type comment
+a int
+b string
+c int
+
+# Partition Information
+# col_name data_type comment
+d string
+
+# Detailed Table Information
+Database: default
+#### A masked pattern was here ####
+Retention: 0
+#### A masked pattern was here ####
+Table Type: EXTERNAL_TABLE
+Table Parameters:
+ COLUMN_STATS_ACCURATE {\"BASIC_STATS\":\"true\"}
+ EXTERNAL TRUE
+ bucketing_version 2
+ numFiles 0
+ numPartitions 0
+ numRows 0
+ rawDataSize 0
+ totalSize #Masked#
+#### A masked pattern was here ####
+
+# Storage Information
+SerDe Library: org.apache.hadoop.hive.ql.io.orc.OrcSerde
+InputFormat: org.apache.hadoop.hive.ql.io.orc.OrcInputFormat
+OutputFormat: org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat
+Compressed: No
+Num Buckets: -1
+Bucket Columns: []
+Sort Columns: []
+Storage Desc Params:
+ serialization.format 1
+PREHOOK: query: insert into table tbl_orc partition (d='one') values (1, "ab",
1), (2, "bc", 3), (3, "cd", 4)
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+PREHOOK: Output: default@tbl_orc@d=one
+POSTHOOK: query: insert into table tbl_orc partition (d='one') values (1,
"ab", 1), (2, "bc", 3), (3, "cd", 4)
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+POSTHOOK: Output: default@tbl_orc@d=one
+POSTHOOK: Lineage: tbl_orc PARTITION(d=one).a SCRIPT []
+POSTHOOK: Lineage: tbl_orc PARTITION(d=one).b SCRIPT []
+POSTHOOK: Lineage: tbl_orc PARTITION(d=one).c SCRIPT []
+col1 col2 col3
+PREHOOK: query: insert into table tbl_orc partition (d='two') values (4, "bc",
6), (5, "cd", 5)
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+PREHOOK: Output: default@tbl_orc@d=two
+POSTHOOK: query: insert into table tbl_orc partition (d='two') values (4,
"bc", 6), (5, "cd", 5)
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+POSTHOOK: Output: default@tbl_orc@d=two
+POSTHOOK: Lineage: tbl_orc PARTITION(d=two).a SCRIPT []
+POSTHOOK: Lineage: tbl_orc PARTITION(d=two).b SCRIPT []
+POSTHOOK: Lineage: tbl_orc PARTITION(d=two).c SCRIPT []
+col1 col2 col3
+PREHOOK: query: insert into table tbl_orc partition (d='three') values (6,
"ab", 7), (7, "bc", 8), (8, "cd", 9)
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+PREHOOK: Output: default@tbl_orc@d=three
+POSTHOOK: query: insert into table tbl_orc partition (d='three') values (6,
"ab", 7), (7, "bc", 8), (8, "cd", 9)
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+POSTHOOK: Output: default@tbl_orc@d=three
+POSTHOOK: Lineage: tbl_orc PARTITION(d=three).a SCRIPT []
+POSTHOOK: Lineage: tbl_orc PARTITION(d=three).b SCRIPT []
+POSTHOOK: Lineage: tbl_orc PARTITION(d=three).c SCRIPT []
+col1 col2 col3
+PREHOOK: query: insert into table tbl_orc partition (d='four') values (9,
"ab", 10)
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+PREHOOK: Output: default@tbl_orc@d=four
+POSTHOOK: query: insert into table tbl_orc partition (d='four') values (9,
"ab", 10)
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+POSTHOOK: Output: default@tbl_orc@d=four
+POSTHOOK: Lineage: tbl_orc PARTITION(d=four).a SCRIPT []
+POSTHOOK: Lineage: tbl_orc PARTITION(d=four).b SCRIPT []
+POSTHOOK: Lineage: tbl_orc PARTITION(d=four).c SCRIPT []
+col1 col2 col3
+PREHOOK: query: show partitions tbl_orc
+PREHOOK: type: SHOWPARTITIONS
+PREHOOK: Input: default@tbl_orc
+POSTHOOK: query: show partitions tbl_orc
+POSTHOOK: type: SHOWPARTITIONS
+POSTHOOK: Input: default@tbl_orc
+partition
+d=four
+d=one
+d=three
+d=two
+PREHOOK: query: show columns in tbl_orc
+PREHOOK: type: SHOWCOLUMNS
+PREHOOK: Input: default@tbl_orc
+POSTHOOK: query: show columns in tbl_orc
+POSTHOOK: type: SHOWCOLUMNS
+POSTHOOK: Input: default@tbl_orc
+field
+a
+b
+c
+d
+PREHOOK: query: select * from tbl_orc
+PREHOOK: type: QUERY
+PREHOOK: Input: default@tbl_orc
+PREHOOK: Input: default@tbl_orc@d=four
+PREHOOK: Input: default@tbl_orc@d=one
+PREHOOK: Input: default@tbl_orc@d=three
+PREHOOK: Input: default@tbl_orc@d=two
+#### A masked pattern was here ####
+POSTHOOK: query: select * from tbl_orc
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@tbl_orc
+POSTHOOK: Input: default@tbl_orc@d=four
+POSTHOOK: Input: default@tbl_orc@d=one
+POSTHOOK: Input: default@tbl_orc@d=three
+POSTHOOK: Input: default@tbl_orc@d=two
+#### A masked pattern was here ####
+tbl_orc.a tbl_orc.b tbl_orc.c tbl_orc.d
+1 ab 1 one
+2 bc 3 one
+3 cd 4 one
+4 bc 6 two
+5 cd 5 two
+6 ab 7 three
+7 bc 8 three
+8 cd 9 three
+9 ab 10 four
+PREHOOK: query: explain alter table tbl_orc drop column if exists c cascade
+PREHOOK: type: ALTERTABLE_DROPCOL
+PREHOOK: Input: default@tbl_orc
+PREHOOK: Output: default@tbl_orc
+PREHOOK: Output: default@tbl_orc@d=four
+PREHOOK: Output: default@tbl_orc@d=one
+PREHOOK: Output: default@tbl_orc@d=three
+PREHOOK: Output: default@tbl_orc@d=two
+POSTHOOK: query: explain alter table tbl_orc drop column if exists c cascade
+POSTHOOK: type: ALTERTABLE_DROPCOL
+POSTHOOK: Input: default@tbl_orc
+POSTHOOK: Output: default@tbl_orc
+POSTHOOK: Output: default@tbl_orc@d=four
+POSTHOOK: Output: default@tbl_orc@d=one
+POSTHOOK: Output: default@tbl_orc@d=three
+POSTHOOK: Output: default@tbl_orc@d=two
+Explain
+STAGE DEPENDENCIES:
+ Stage-0 is a root stage
+
+STAGE PLANS:
+ Stage: Stage-0
+ Drop Column
+ column name: c
+ table name: default.tbl_orc
+ cascade: true
+
+PREHOOK: query: alter table tbl_orc drop column if exists c cascade
+PREHOOK: type: ALTERTABLE_DROPCOL
+PREHOOK: Input: default@tbl_orc
+PREHOOK: Output: default@tbl_orc
+PREHOOK: Output: default@tbl_orc@d=four
+PREHOOK: Output: default@tbl_orc@d=one
+PREHOOK: Output: default@tbl_orc@d=three
+PREHOOK: Output: default@tbl_orc@d=two
+POSTHOOK: query: alter table tbl_orc drop column if exists c cascade
+POSTHOOK: type: ALTERTABLE_DROPCOL
+POSTHOOK: Input: default@tbl_orc
+POSTHOOK: Output: default@tbl_orc
+POSTHOOK: Output: default@tbl_orc@d=four
+POSTHOOK: Output: default@tbl_orc@d=one
+POSTHOOK: Output: default@tbl_orc@d=three
+POSTHOOK: Output: default@tbl_orc@d=two
+PREHOOK: query: alter table tbl_orc drop column if exists c cascade
+PREHOOK: type: ALTERTABLE_DROPCOL
+PREHOOK: Input: default@tbl_orc
+PREHOOK: Output: default@tbl_orc
+PREHOOK: Output: default@tbl_orc@d=four
+PREHOOK: Output: default@tbl_orc@d=one
+PREHOOK: Output: default@tbl_orc@d=three
+PREHOOK: Output: default@tbl_orc@d=two
+POSTHOOK: query: alter table tbl_orc drop column if exists c cascade
+POSTHOOK: type: ALTERTABLE_DROPCOL
+POSTHOOK: Input: default@tbl_orc
+POSTHOOK: Output: default@tbl_orc
+POSTHOOK: Output: default@tbl_orc@d=four
+POSTHOOK: Output: default@tbl_orc@d=one
+POSTHOOK: Output: default@tbl_orc@d=three
+POSTHOOK: Output: default@tbl_orc@d=two
+PREHOOK: query: desc formatted tbl_orc
+PREHOOK: type: DESCTABLE
+PREHOOK: Input: default@tbl_orc
+POSTHOOK: query: desc formatted tbl_orc
+POSTHOOK: type: DESCTABLE
+POSTHOOK: Input: default@tbl_orc
+col_name data_type comment
+# col_name data_type comment
+a int
+b string
+
+# Partition Information
+# col_name data_type comment
+d string
+
+# Detailed Table Information
+Database: default
+#### A masked pattern was here ####
+Retention: 0
+#### A masked pattern was here ####
+Table Type: EXTERNAL_TABLE
+Table Parameters:
+ COLUMN_STATS_ACCURATE {\"BASIC_STATS\":\"true\"}
+ EXTERNAL TRUE
+ bucketing_version 2
+#### A masked pattern was here ####
+ numFiles 4
+ numPartitions 4
+ numRows 9
+ rawDataSize 846
+ totalSize #Masked#
+#### A masked pattern was here ####
+
+# Storage Information
+SerDe Library: org.apache.hadoop.hive.ql.io.orc.OrcSerde
+InputFormat: org.apache.hadoop.hive.ql.io.orc.OrcInputFormat
+OutputFormat: org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat
+Compressed: No
+Num Buckets: -1
+Bucket Columns: []
+Sort Columns: []
+Storage Desc Params:
+ serialization.format 1
+PREHOOK: query: desc formatted tbl_orc partition (d='one')
+PREHOOK: type: DESCTABLE
+PREHOOK: Input: default@tbl_orc
+POSTHOOK: query: desc formatted tbl_orc partition (d='one')
+POSTHOOK: type: DESCTABLE
+POSTHOOK: Input: default@tbl_orc
+col_name data_type comment
+# col_name data_type comment
+a int
+b string
+
+# Partition Information
+# col_name data_type comment
+d string
+
+# Detailed Partition Information
+Partition Value: [one]
+Database: default
+Table: tbl_orc
+#### A masked pattern was here ####
+Partition Parameters:
+ COLUMN_STATS_ACCURATE
{\"BASIC_STATS\":\"true\",\"COLUMN_STATS\":{\"a\":\"true\",\"b\":\"true\"}}
+ numFiles 1
+ numRows 3
+ rawDataSize 282
+ totalSize #Masked#
+#### A masked pattern was here ####
+
+# Storage Information
+SerDe Library: org.apache.hadoop.hive.ql.io.orc.OrcSerde
+InputFormat: org.apache.hadoop.hive.ql.io.orc.OrcInputFormat
+OutputFormat: org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat
+Compressed: No
+Num Buckets: -1
+Bucket Columns: []
+Sort Columns: []
+Storage Desc Params:
+ serialization.format 1
+PREHOOK: query: show columns in tbl_orc
+PREHOOK: type: SHOWCOLUMNS
+PREHOOK: Input: default@tbl_orc
+POSTHOOK: query: show columns in tbl_orc
+POSTHOOK: type: SHOWCOLUMNS
+POSTHOOK: Input: default@tbl_orc
+field
+a
+b
+d
+PREHOOK: query: select * from tbl_orc
+PREHOOK: type: QUERY
+PREHOOK: Input: default@tbl_orc
+PREHOOK: Input: default@tbl_orc@d=four
+PREHOOK: Input: default@tbl_orc@d=one
+PREHOOK: Input: default@tbl_orc@d=three
+PREHOOK: Input: default@tbl_orc@d=two
+#### A masked pattern was here ####
+POSTHOOK: query: select * from tbl_orc
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@tbl_orc
+POSTHOOK: Input: default@tbl_orc@d=four
+POSTHOOK: Input: default@tbl_orc@d=one
+POSTHOOK: Input: default@tbl_orc@d=three
+POSTHOOK: Input: default@tbl_orc@d=two
+#### A masked pattern was here ####
+tbl_orc.a tbl_orc.b tbl_orc.d
+1 ab one
+2 bc one
+3 cd one
+4 bc two
+5 cd two
+6 ab three
+7 bc three
+8 cd three
+9 ab four
+PREHOOK: query: create external table tbl_orc2(a int, b string) stored as orc
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@tbl_orc2
+POSTHOOK: query: create external table tbl_orc2(a int, b string) stored as orc
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@tbl_orc2
+PREHOOK: query: desc formatted tbl_orc2
+PREHOOK: type: DESCTABLE
+PREHOOK: Input: default@tbl_orc2
+POSTHOOK: query: desc formatted tbl_orc2
+POSTHOOK: type: DESCTABLE
+POSTHOOK: Input: default@tbl_orc2
+col_name data_type comment
+# col_name data_type comment
+a int
+b string
+
+# Detailed Table Information
+Database: default
+#### A masked pattern was here ####
+Retention: 0
+#### A masked pattern was here ####
+Table Type: EXTERNAL_TABLE
+Table Parameters:
+ COLUMN_STATS_ACCURATE
{\"BASIC_STATS\":\"true\",\"COLUMN_STATS\":{\"a\":\"true\",\"b\":\"true\"}}
+ EXTERNAL TRUE
+ bucketing_version 2
+ numFiles 0
+ numRows 0
+ rawDataSize 0
+ totalSize #Masked#
+#### A masked pattern was here ####
+
+# Storage Information
+SerDe Library: org.apache.hadoop.hive.ql.io.orc.OrcSerde
+InputFormat: org.apache.hadoop.hive.ql.io.orc.OrcInputFormat
+OutputFormat: org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat
+Compressed: No
+Num Buckets: -1
+Bucket Columns: []
+Sort Columns: []
+Storage Desc Params:
+ serialization.format 1
+PREHOOK: query: insert into table tbl_orc2 values (1, "ab"), (2, "bc"), (3,
"cd")
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+PREHOOK: Output: default@tbl_orc2
+POSTHOOK: query: insert into table tbl_orc2 values (1, "ab"), (2, "bc"), (3,
"cd")
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+POSTHOOK: Output: default@tbl_orc2
+POSTHOOK: Lineage: tbl_orc2.a SCRIPT []
+POSTHOOK: Lineage: tbl_orc2.b SCRIPT []
+col1 col2
+PREHOOK: query: show columns in tbl_orc2
+PREHOOK: type: SHOWCOLUMNS
+PREHOOK: Input: default@tbl_orc2
+POSTHOOK: query: show columns in tbl_orc2
+POSTHOOK: type: SHOWCOLUMNS
+POSTHOOK: Input: default@tbl_orc2
+field
+a
+b
+PREHOOK: query: select * from tbl_orc2
+PREHOOK: type: QUERY
+PREHOOK: Input: default@tbl_orc2
+#### A masked pattern was here ####
+POSTHOOK: query: select * from tbl_orc2
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@tbl_orc2
+#### A masked pattern was here ####
+tbl_orc2.a tbl_orc2.b
+1 ab
+2 bc
+3 cd
+PREHOOK: query: explain alter table tbl_orc2 drop column b
+PREHOOK: type: ALTERTABLE_DROPCOL
+PREHOOK: Input: default@tbl_orc2
+PREHOOK: Output: default@tbl_orc2
+POSTHOOK: query: explain alter table tbl_orc2 drop column b
+POSTHOOK: type: ALTERTABLE_DROPCOL
+POSTHOOK: Input: default@tbl_orc2
+POSTHOOK: Output: default@tbl_orc2
+Explain
+STAGE DEPENDENCIES:
+ Stage-0 is a root stage
+
+STAGE PLANS:
+ Stage: Stage-0
+ Drop Column
+ column name: b
+ table name: default.tbl_orc2
+
+PREHOOK: query: alter table tbl_orc2 drop column b
+PREHOOK: type: ALTERTABLE_DROPCOL
+PREHOOK: Input: default@tbl_orc2
+PREHOOK: Output: default@tbl_orc2
+POSTHOOK: query: alter table tbl_orc2 drop column b
+POSTHOOK: type: ALTERTABLE_DROPCOL
+POSTHOOK: Input: default@tbl_orc2
+POSTHOOK: Output: default@tbl_orc2
+PREHOOK: query: desc formatted tbl_orc2
+PREHOOK: type: DESCTABLE
+PREHOOK: Input: default@tbl_orc2
+POSTHOOK: query: desc formatted tbl_orc2
+POSTHOOK: type: DESCTABLE
+POSTHOOK: Input: default@tbl_orc2
+col_name data_type comment
+# col_name data_type comment
+a int
+
+# Detailed Table Information
+Database: default
+#### A masked pattern was here ####
+Retention: 0
+#### A masked pattern was here ####
+Table Type: EXTERNAL_TABLE
+Table Parameters:
+ COLUMN_STATS_ACCURATE
{\"BASIC_STATS\":\"true\",\"COLUMN_STATS\":{\"a\":\"true\"}}
+ EXTERNAL TRUE
+ bucketing_version 2
+#### A masked pattern was here ####
+ numFiles 1
+ numRows 3
+ rawDataSize 270
+ totalSize #Masked#
+#### A masked pattern was here ####
+
+# Storage Information
+SerDe Library: org.apache.hadoop.hive.ql.io.orc.OrcSerde
+InputFormat: org.apache.hadoop.hive.ql.io.orc.OrcInputFormat
+OutputFormat: org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat
+Compressed: No
+Num Buckets: -1
+Bucket Columns: []
+Sort Columns: []
+Storage Desc Params:
+ serialization.format 1
+PREHOOK: query: show columns in tbl_orc2
+PREHOOK: type: SHOWCOLUMNS
+PREHOOK: Input: default@tbl_orc2
+POSTHOOK: query: show columns in tbl_orc2
+POSTHOOK: type: SHOWCOLUMNS
+POSTHOOK: Input: default@tbl_orc2
+field
+a
+PREHOOK: query: select * from tbl_orc2
+PREHOOK: type: QUERY
+PREHOOK: Input: default@tbl_orc2
+#### A masked pattern was here ####
+POSTHOOK: query: select * from tbl_orc2
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@tbl_orc2
+#### A masked pattern was here ####
+tbl_orc2.a
+1
+2
+3
diff --git a/ql/src/test/results/clientpositive/llap/parquet_drop_column.q.out
b/ql/src/test/results/clientpositive/llap/parquet_drop_column.q.out
new file mode 100644
index 00000000000..9532377036a
--- /dev/null
+++ b/ql/src/test/results/clientpositive/llap/parquet_drop_column.q.out
@@ -0,0 +1,489 @@
+PREHOOK: query: drop table if exists tbl_parq
+PREHOOK: type: DROPTABLE
+PREHOOK: Output: database:default
+POSTHOOK: query: drop table if exists tbl_parq
+POSTHOOK: type: DROPTABLE
+POSTHOOK: Output: database:default
+PREHOOK: query: create external table tbl_parq(a int, b string, c int)
partitioned by (d string) stored as parquet
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@tbl_parq
+POSTHOOK: query: create external table tbl_parq(a int, b string, c int)
partitioned by (d string) stored as parquet
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@tbl_parq
+PREHOOK: query: desc formatted tbl_parq
+PREHOOK: type: DESCTABLE
+PREHOOK: Input: default@tbl_parq
+POSTHOOK: query: desc formatted tbl_parq
+POSTHOOK: type: DESCTABLE
+POSTHOOK: Input: default@tbl_parq
+col_name data_type comment
+# col_name data_type comment
+a int
+b string
+c int
+
+# Partition Information
+# col_name data_type comment
+d string
+
+# Detailed Table Information
+Database: default
+#### A masked pattern was here ####
+Retention: 0
+#### A masked pattern was here ####
+Table Type: EXTERNAL_TABLE
+Table Parameters:
+ COLUMN_STATS_ACCURATE {\"BASIC_STATS\":\"true\"}
+ EXTERNAL TRUE
+ bucketing_version 2
+ numFiles 0
+ numPartitions 0
+ numRows 0
+ rawDataSize 0
+ totalSize #Masked#
+#### A masked pattern was here ####
+
+# Storage Information
+SerDe Library:
org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe
+InputFormat:
org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat
+OutputFormat:
org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat
+Compressed: No
+Num Buckets: -1
+Bucket Columns: []
+Sort Columns: []
+Storage Desc Params:
+ serialization.format 1
+PREHOOK: query: insert into table tbl_parq partition (d='one') values (1,
"ab", 1), (2, "bc", 3), (3, "cd", 4)
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+PREHOOK: Output: default@tbl_parq@d=one
+POSTHOOK: query: insert into table tbl_parq partition (d='one') values (1,
"ab", 1), (2, "bc", 3), (3, "cd", 4)
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+POSTHOOK: Output: default@tbl_parq@d=one
+POSTHOOK: Lineage: tbl_parq PARTITION(d=one).a SCRIPT []
+POSTHOOK: Lineage: tbl_parq PARTITION(d=one).b SCRIPT []
+POSTHOOK: Lineage: tbl_parq PARTITION(d=one).c SCRIPT []
+col1 col2 col3
+PREHOOK: query: insert into table tbl_parq partition (d='two') values (4,
"bc", 6), (5, "cd", 5)
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+PREHOOK: Output: default@tbl_parq@d=two
+POSTHOOK: query: insert into table tbl_parq partition (d='two') values (4,
"bc", 6), (5, "cd", 5)
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+POSTHOOK: Output: default@tbl_parq@d=two
+POSTHOOK: Lineage: tbl_parq PARTITION(d=two).a SCRIPT []
+POSTHOOK: Lineage: tbl_parq PARTITION(d=two).b SCRIPT []
+POSTHOOK: Lineage: tbl_parq PARTITION(d=two).c SCRIPT []
+col1 col2 col3
+PREHOOK: query: insert into table tbl_parq partition (d='three') values (6,
"ab", 7), (7, "bc", 8), (8, "cd", 9)
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+PREHOOK: Output: default@tbl_parq@d=three
+POSTHOOK: query: insert into table tbl_parq partition (d='three') values (6,
"ab", 7), (7, "bc", 8), (8, "cd", 9)
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+POSTHOOK: Output: default@tbl_parq@d=three
+POSTHOOK: Lineage: tbl_parq PARTITION(d=three).a SCRIPT []
+POSTHOOK: Lineage: tbl_parq PARTITION(d=three).b SCRIPT []
+POSTHOOK: Lineage: tbl_parq PARTITION(d=three).c SCRIPT []
+col1 col2 col3
+PREHOOK: query: insert into table tbl_parq partition (d='four') values (9,
"ab", 10)
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+PREHOOK: Output: default@tbl_parq@d=four
+POSTHOOK: query: insert into table tbl_parq partition (d='four') values (9,
"ab", 10)
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+POSTHOOK: Output: default@tbl_parq@d=four
+POSTHOOK: Lineage: tbl_parq PARTITION(d=four).a SCRIPT []
+POSTHOOK: Lineage: tbl_parq PARTITION(d=four).b SCRIPT []
+POSTHOOK: Lineage: tbl_parq PARTITION(d=four).c SCRIPT []
+col1 col2 col3
+PREHOOK: query: show partitions tbl_parq
+PREHOOK: type: SHOWPARTITIONS
+PREHOOK: Input: default@tbl_parq
+POSTHOOK: query: show partitions tbl_parq
+POSTHOOK: type: SHOWPARTITIONS
+POSTHOOK: Input: default@tbl_parq
+partition
+d=four
+d=one
+d=three
+d=two
+PREHOOK: query: show columns in tbl_parq
+PREHOOK: type: SHOWCOLUMNS
+PREHOOK: Input: default@tbl_parq
+POSTHOOK: query: show columns in tbl_parq
+POSTHOOK: type: SHOWCOLUMNS
+POSTHOOK: Input: default@tbl_parq
+field
+a
+b
+c
+d
+PREHOOK: query: select * from tbl_parq
+PREHOOK: type: QUERY
+PREHOOK: Input: default@tbl_parq
+PREHOOK: Input: default@tbl_parq@d=four
+PREHOOK: Input: default@tbl_parq@d=one
+PREHOOK: Input: default@tbl_parq@d=three
+PREHOOK: Input: default@tbl_parq@d=two
+#### A masked pattern was here ####
+POSTHOOK: query: select * from tbl_parq
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@tbl_parq
+POSTHOOK: Input: default@tbl_parq@d=four
+POSTHOOK: Input: default@tbl_parq@d=one
+POSTHOOK: Input: default@tbl_parq@d=three
+POSTHOOK: Input: default@tbl_parq@d=two
+#### A masked pattern was here ####
+tbl_parq.a tbl_parq.b tbl_parq.c tbl_parq.d
+1 ab 1 one
+2 bc 3 one
+3 cd 4 one
+4 bc 6 two
+5 cd 5 two
+6 ab 7 three
+7 bc 8 three
+8 cd 9 three
+9 ab 10 four
+PREHOOK: query: explain alter table tbl_parq drop column if exists c cascade
+PREHOOK: type: ALTERTABLE_DROPCOL
+PREHOOK: Input: default@tbl_parq
+PREHOOK: Output: default@tbl_parq
+PREHOOK: Output: default@tbl_parq@d=four
+PREHOOK: Output: default@tbl_parq@d=one
+PREHOOK: Output: default@tbl_parq@d=three
+PREHOOK: Output: default@tbl_parq@d=two
+POSTHOOK: query: explain alter table tbl_parq drop column if exists c cascade
+POSTHOOK: type: ALTERTABLE_DROPCOL
+POSTHOOK: Input: default@tbl_parq
+POSTHOOK: Output: default@tbl_parq
+POSTHOOK: Output: default@tbl_parq@d=four
+POSTHOOK: Output: default@tbl_parq@d=one
+POSTHOOK: Output: default@tbl_parq@d=three
+POSTHOOK: Output: default@tbl_parq@d=two
+Explain
+STAGE DEPENDENCIES:
+ Stage-0 is a root stage
+
+STAGE PLANS:
+ Stage: Stage-0
+ Drop Column
+ column name: c
+ table name: default.tbl_parq
+ cascade: true
+
+PREHOOK: query: alter table tbl_parq drop column if exists c cascade
+PREHOOK: type: ALTERTABLE_DROPCOL
+PREHOOK: Input: default@tbl_parq
+PREHOOK: Output: default@tbl_parq
+PREHOOK: Output: default@tbl_parq@d=four
+PREHOOK: Output: default@tbl_parq@d=one
+PREHOOK: Output: default@tbl_parq@d=three
+PREHOOK: Output: default@tbl_parq@d=two
+POSTHOOK: query: alter table tbl_parq drop column if exists c cascade
+POSTHOOK: type: ALTERTABLE_DROPCOL
+POSTHOOK: Input: default@tbl_parq
+POSTHOOK: Output: default@tbl_parq
+POSTHOOK: Output: default@tbl_parq@d=four
+POSTHOOK: Output: default@tbl_parq@d=one
+POSTHOOK: Output: default@tbl_parq@d=three
+POSTHOOK: Output: default@tbl_parq@d=two
+PREHOOK: query: alter table tbl_parq drop column if exists c cascade
+PREHOOK: type: ALTERTABLE_DROPCOL
+PREHOOK: Input: default@tbl_parq
+PREHOOK: Output: default@tbl_parq
+PREHOOK: Output: default@tbl_parq@d=four
+PREHOOK: Output: default@tbl_parq@d=one
+PREHOOK: Output: default@tbl_parq@d=three
+PREHOOK: Output: default@tbl_parq@d=two
+POSTHOOK: query: alter table tbl_parq drop column if exists c cascade
+POSTHOOK: type: ALTERTABLE_DROPCOL
+POSTHOOK: Input: default@tbl_parq
+POSTHOOK: Output: default@tbl_parq
+POSTHOOK: Output: default@tbl_parq@d=four
+POSTHOOK: Output: default@tbl_parq@d=one
+POSTHOOK: Output: default@tbl_parq@d=three
+POSTHOOK: Output: default@tbl_parq@d=two
+PREHOOK: query: desc formatted tbl_parq
+PREHOOK: type: DESCTABLE
+PREHOOK: Input: default@tbl_parq
+POSTHOOK: query: desc formatted tbl_parq
+POSTHOOK: type: DESCTABLE
+POSTHOOK: Input: default@tbl_parq
+col_name data_type comment
+# col_name data_type comment
+a int
+b string
+
+# Partition Information
+# col_name data_type comment
+d string
+
+# Detailed Table Information
+Database: default
+#### A masked pattern was here ####
+Retention: 0
+#### A masked pattern was here ####
+Table Type: EXTERNAL_TABLE
+Table Parameters:
+ COLUMN_STATS_ACCURATE {\"BASIC_STATS\":\"true\"}
+ EXTERNAL TRUE
+ bucketing_version 2
+#### A masked pattern was here ####
+ numFiles 4
+ numPartitions 4
+ numRows 9
+ rawDataSize 473
+ totalSize #Masked#
+#### A masked pattern was here ####
+
+# Storage Information
+SerDe Library:
org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe
+InputFormat:
org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat
+OutputFormat:
org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat
+Compressed: No
+Num Buckets: -1
+Bucket Columns: []
+Sort Columns: []
+Storage Desc Params:
+ serialization.format 1
+PREHOOK: query: desc formatted tbl_parq partition (d='one')
+PREHOOK: type: DESCTABLE
+PREHOOK: Input: default@tbl_parq
+POSTHOOK: query: desc formatted tbl_parq partition (d='one')
+POSTHOOK: type: DESCTABLE
+POSTHOOK: Input: default@tbl_parq
+col_name data_type comment
+# col_name data_type comment
+a int
+b string
+
+# Partition Information
+# col_name data_type comment
+d string
+
+# Detailed Partition Information
+Partition Value: [one]
+Database: default
+Table: tbl_parq
+#### A masked pattern was here ####
+Partition Parameters:
+ COLUMN_STATS_ACCURATE
{\"BASIC_STATS\":\"true\",\"COLUMN_STATS\":{\"a\":\"true\",\"b\":\"true\"}}
+ numFiles 1
+ numRows 3
+ rawDataSize 128
+ totalSize #Masked#
+#### A masked pattern was here ####
+
+# Storage Information
+SerDe Library:
org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe
+InputFormat:
org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat
+OutputFormat:
org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat
+Compressed: No
+Num Buckets: -1
+Bucket Columns: []
+Sort Columns: []
+Storage Desc Params:
+ serialization.format 1
+PREHOOK: query: show columns in tbl_parq
+PREHOOK: type: SHOWCOLUMNS
+PREHOOK: Input: default@tbl_parq
+POSTHOOK: query: show columns in tbl_parq
+POSTHOOK: type: SHOWCOLUMNS
+POSTHOOK: Input: default@tbl_parq
+field
+a
+b
+d
+PREHOOK: query: select * from tbl_parq
+PREHOOK: type: QUERY
+PREHOOK: Input: default@tbl_parq
+PREHOOK: Input: default@tbl_parq@d=four
+PREHOOK: Input: default@tbl_parq@d=one
+PREHOOK: Input: default@tbl_parq@d=three
+PREHOOK: Input: default@tbl_parq@d=two
+#### A masked pattern was here ####
+POSTHOOK: query: select * from tbl_parq
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@tbl_parq
+POSTHOOK: Input: default@tbl_parq@d=four
+POSTHOOK: Input: default@tbl_parq@d=one
+POSTHOOK: Input: default@tbl_parq@d=three
+POSTHOOK: Input: default@tbl_parq@d=two
+#### A masked pattern was here ####
+tbl_parq.a tbl_parq.b tbl_parq.d
+1 ab one
+2 bc one
+3 cd one
+4 bc two
+5 cd two
+6 ab three
+7 bc three
+8 cd three
+9 ab four
+PREHOOK: query: create external table tbl_parq2(a int, b string) stored as
parquet
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@tbl_parq2
+POSTHOOK: query: create external table tbl_parq2(a int, b string) stored as
parquet
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@tbl_parq2
+PREHOOK: query: desc formatted tbl_parq2
+PREHOOK: type: DESCTABLE
+PREHOOK: Input: default@tbl_parq2
+POSTHOOK: query: desc formatted tbl_parq2
+POSTHOOK: type: DESCTABLE
+POSTHOOK: Input: default@tbl_parq2
+col_name data_type comment
+# col_name data_type comment
+a int
+b string
+
+# Detailed Table Information
+Database: default
+#### A masked pattern was here ####
+Retention: 0
+#### A masked pattern was here ####
+Table Type: EXTERNAL_TABLE
+Table Parameters:
+ COLUMN_STATS_ACCURATE
{\"BASIC_STATS\":\"true\",\"COLUMN_STATS\":{\"a\":\"true\",\"b\":\"true\"}}
+ EXTERNAL TRUE
+ bucketing_version 2
+ numFiles 0
+ numRows 0
+ rawDataSize 0
+ totalSize #Masked#
+#### A masked pattern was here ####
+
+# Storage Information
+SerDe Library:
org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe
+InputFormat:
org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat
+OutputFormat:
org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat
+Compressed: No
+Num Buckets: -1
+Bucket Columns: []
+Sort Columns: []
+Storage Desc Params:
+ serialization.format 1
+PREHOOK: query: insert into table tbl_parq2 values (1, "ab"), (2, "bc"), (3,
"cd")
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+PREHOOK: Output: default@tbl_parq2
+POSTHOOK: query: insert into table tbl_parq2 values (1, "ab"), (2, "bc"), (3,
"cd")
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+POSTHOOK: Output: default@tbl_parq2
+POSTHOOK: Lineage: tbl_parq2.a SCRIPT []
+POSTHOOK: Lineage: tbl_parq2.b SCRIPT []
+col1 col2
+PREHOOK: query: show columns in tbl_parq2
+PREHOOK: type: SHOWCOLUMNS
+PREHOOK: Input: default@tbl_parq2
+POSTHOOK: query: show columns in tbl_parq2
+POSTHOOK: type: SHOWCOLUMNS
+POSTHOOK: Input: default@tbl_parq2
+field
+a
+b
+PREHOOK: query: select * from tbl_parq2
+PREHOOK: type: QUERY
+PREHOOK: Input: default@tbl_parq2
+#### A masked pattern was here ####
+POSTHOOK: query: select * from tbl_parq2
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@tbl_parq2
+#### A masked pattern was here ####
+tbl_parq2.a tbl_parq2.b
+1 ab
+2 bc
+3 cd
+PREHOOK: query: explain alter table tbl_parq2 drop column b
+PREHOOK: type: ALTERTABLE_DROPCOL
+PREHOOK: Input: default@tbl_parq2
+PREHOOK: Output: default@tbl_parq2
+POSTHOOK: query: explain alter table tbl_parq2 drop column b
+POSTHOOK: type: ALTERTABLE_DROPCOL
+POSTHOOK: Input: default@tbl_parq2
+POSTHOOK: Output: default@tbl_parq2
+Explain
+STAGE DEPENDENCIES:
+ Stage-0 is a root stage
+
+STAGE PLANS:
+ Stage: Stage-0
+ Drop Column
+ column name: b
+ table name: default.tbl_parq2
+
+PREHOOK: query: alter table tbl_parq2 drop column b
+PREHOOK: type: ALTERTABLE_DROPCOL
+PREHOOK: Input: default@tbl_parq2
+PREHOOK: Output: default@tbl_parq2
+POSTHOOK: query: alter table tbl_parq2 drop column b
+POSTHOOK: type: ALTERTABLE_DROPCOL
+POSTHOOK: Input: default@tbl_parq2
+POSTHOOK: Output: default@tbl_parq2
+PREHOOK: query: desc formatted tbl_parq2
+PREHOOK: type: DESCTABLE
+PREHOOK: Input: default@tbl_parq2
+POSTHOOK: query: desc formatted tbl_parq2
+POSTHOOK: type: DESCTABLE
+POSTHOOK: Input: default@tbl_parq2
+col_name data_type comment
+# col_name data_type comment
+a int
+
+# Detailed Table Information
+Database: default
+#### A masked pattern was here ####
+Retention: 0
+#### A masked pattern was here ####
+Table Type: EXTERNAL_TABLE
+Table Parameters:
+ COLUMN_STATS_ACCURATE
{\"BASIC_STATS\":\"true\",\"COLUMN_STATS\":{\"a\":\"true\"}}
+ EXTERNAL TRUE
+ bucketing_version 2
+#### A masked pattern was here ####
+ numFiles 1
+ numRows 3
+ rawDataSize 88
+ totalSize #Masked#
+#### A masked pattern was here ####
+
+# Storage Information
+SerDe Library:
org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe
+InputFormat:
org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat
+OutputFormat:
org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat
+Compressed: No
+Num Buckets: -1
+Bucket Columns: []
+Sort Columns: []
+Storage Desc Params:
+ serialization.format 1
+PREHOOK: query: show columns in tbl_parq2
+PREHOOK: type: SHOWCOLUMNS
+PREHOOK: Input: default@tbl_parq2
+POSTHOOK: query: show columns in tbl_parq2
+POSTHOOK: type: SHOWCOLUMNS
+POSTHOOK: Input: default@tbl_parq2
+field
+a
+PREHOOK: query: select * from tbl_parq2
+PREHOOK: type: QUERY
+PREHOOK: Input: default@tbl_parq2
+#### A masked pattern was here ####
+POSTHOOK: query: select * from tbl_parq2
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@tbl_parq2
+#### A masked pattern was here ####
+tbl_parq2.a
+1
+2
+3