Skip to content

Commit

Permalink
HIVE-26575 - Copy Serde Description when Alter Table's Serde Description
Browse files Browse the repository at this point in the history
  • Loading branch information
yeahyung committed Jul 20, 2023
1 parent 8ea1d78 commit bf9f21e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5459,6 +5459,7 @@ private void copyMSD(MStorageDescriptor newSd, MStorageDescriptor oldSd) {
oldSd.getSerDeInfo().setSerializationLib(
newSd.getSerDeInfo().getSerializationLib());
oldSd.getSerDeInfo().setParameters(newSd.getSerDeInfo().getParameters());
oldSd.getSerDeInfo().setDescription(newSd.getSerDeInfo().getDescription());
oldSd.setSkewedColNames(newSd.getSkewedColNames());
oldSd.setSkewedColValues(newSd.getSkewedColValues());
oldSd.setSkewedColValueLocationMaps(newSd.getSkewedColValueLocationMaps());
Expand Down Expand Up @@ -10032,15 +10033,15 @@ private Map<String, MTableColumnStatistics> getPartitionColStats(Table table, Li
}
return statsMap;
}

@Override
public Map<String, String> updateTableColumnStatistics(ColumnStatistics colStats, String validWriteIds, long writeId)
throws NoSuchObjectException, MetaException, InvalidObjectException, InvalidInputException {
boolean committed = false;

List<ColumnStatisticsObj> statsObjs = colStats.getStatsObj();
ColumnStatisticsDesc statsDesc = colStats.getStatsDesc();

Lock tableLock = getTableLockFor(statsDesc.getDbName(), statsDesc.getTableName());
tableLock.lock();
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ public void testTableOps() throws MetaException, InvalidObjectException, NoSuchO
new StorageDescriptor(ImmutableList.of(new FieldSchema("pk_col", "double", null)),
"location", null, null, false, 0, new SerDeInfo("SerDeName", "serializationLib", null),
null, null, null);
sd1.getSerdeInfo().setDescription("this is sd1 description");
HashMap<String, String> params = new HashMap<>();
params.put("EXTERNAL", "false");
Table tbl1 =
Expand All @@ -294,6 +295,7 @@ public void testTableOps() throws MetaException, InvalidObjectException, NoSuchO
new StorageDescriptor(ImmutableList.of(new FieldSchema("fk_col", "double", null)),
"location", null, null, false, 0, new SerDeInfo("SerDeName", "serializationLib", null),
null, null, null);
sd2.getSerdeInfo().setDescription("this is sd2 description");
Table newTbl1 = new Table("new" + TABLE1, DB1, "owner", 1, 2, 3, sd2, null, params, null, null,
"MANAGED_TABLE");

Expand All @@ -311,6 +313,10 @@ public void testTableOps() throws MetaException, InvalidObjectException, NoSuchO
Assert.assertEquals("Owner of table was not altered", newTbl1.getOwner(), alteredTable.getOwner());
Assert.assertEquals("Owner type of table was not altered", newTbl1.getOwnerType(), alteredTable.getOwnerType());

// Verify serde description is altered during the alterTable operation
Assert.assertNotEquals("Serde Description was not altered", tbl1.getSd().getSerdeInfo().getDescription(), alteredTable.getSd().getSerdeInfo().getDescription());
Assert.assertEquals("Serde Description was not altered", newTbl1.getSd().getSerdeInfo().getDescription(), alteredTable.getSd().getSerdeInfo().getDescription());

objectStore.createTable(tbl1);
tables = objectStore.getAllTables(DEFAULT_CATALOG_NAME, DB1);
Assert.assertEquals(2, tables.size());
Expand Down

0 comments on commit bf9f21e

Please sign in to comment.