Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1441,7 +1441,9 @@ public enum ConfVars {
"org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe," +
"org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe," +
"org.apache.hadoop.hive.serde2.OpenCSVSerde," +
"org.apache.iceberg.mr.hive.HiveIcebergSerDe",
"org.apache.iceberg.mr.hive.HiveIcebergSerDe," +
"org.apache.hadoop.hive.serde2.avro.AvroSerDe," +
"org.apache.hadoop.hive.hbase.HBaseSerDe",
"SerDes retrieving schema from metastore. This is an internal parameter."),
SERDES_WITHOUT_FROM_DESERIALIZER("metastore.serdes.without.from.deserializer",
"hive.metastore.serdes.without.from.deserializer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3958,4 +3958,58 @@ public void testDropDataConnectorIfNotExistsTrue() throws Exception {
// No such data connector, ignore NoSuchObjectException
client.dropDataConnector("no_such_data_connector", true, false);
}

/**
* Test for storage-based SerDes (AvroSerDe, HBaseSerDe).If the SerDe is not listed in
* SERDES_USING_METASTORE_FOR_SCHEMA, HMS falls through to DefaultStorageSchemaReader and throws
* "Storage schema reading not supported".
*/
@Test
public void testGetFieldsForStorageSerDes() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably divide this into two tests for the two SerDes as they are completely different and not related to each other. Also, the comment above should be edited accordingly.

String dbName = "test_storage_serde_db";
String avroTbl = "avro_tbl";
String hbaseTbl = "hbase_tbl";

client.dropTable(dbName, avroTbl, true, true);
client.dropTable(dbName, hbaseTbl, true, true);
silentDropDatabase(dbName);

new DatabaseBuilder()
.setName(dbName)
.create(client, conf);

new TableBuilder()
.setDbName(dbName)
.setTableName(avroTbl)
.setSerdeLib("org.apache.hadoop.hive.serde2.avro.AvroSerDe")
.setInputFormat("org.apache.hadoop.hive.ql.io.avro.AvroContainerInputFormat")
.setOutputFormat("org.apache.hadoop.hive.ql.io.avro.AvroContainerOutputFormat")
.addCol("foo", "int", "")
.addCol("bar", "string", "")
.addCol("baz", "bigint", "")
.create(client, conf);

List<FieldSchema> avroFields = client.getFields(dbName, avroTbl);
assertEquals("AvroSerDe table should return 3 fields from metastore", 3, avroFields.size());
assertEquals("foo", avroFields.get(0).getName());
assertEquals("bar", avroFields.get(1).getName());
assertEquals("baz", avroFields.get(2).getName());

new TableBuilder()
.setDbName(dbName)
.setTableName(hbaseTbl)
.setSerdeLib("org.apache.hadoop.hive.hbase.HBaseSerDe")
.addCol("key", "string", "")
.addCol("value", "string", "")
.create(client, conf);

List<FieldSchema> hbaseFields = client.getFields(dbName, hbaseTbl);
assertEquals("HBaseSerDe table should return 2 fields from metastore", 2, hbaseFields.size());
assertEquals("key", hbaseFields.get(0).getName());
assertEquals("value", hbaseFields.get(1).getName());

client.dropTable(dbName, avroTbl, true, true);
client.dropTable(dbName, hbaseTbl, true, true);
client.dropDatabase(dbName);
}
}