Skip to content

Commit 0a2bd54

Browse files
yogeshtewariYogesh Tewarishevek-google
authored
[Dumper] [Hive] Extract hive table SerDe details (#328)
* Extract Hive table StorageDescriptor info for SerDe and input output formats --------- Co-authored-by: Yogesh Tewari <tewariy@google.com> Co-authored-by: shevek-google <94193257+shevek-google@users.noreply.github.com>
1 parent ef25751 commit 0a2bd54

File tree

5 files changed

+66
-0
lines changed

5 files changed

+66
-0
lines changed

dumper/app/src/main/java/com/google/edwmigration/dumper/application/dumper/connector/hive/HiveMetadataConnector.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,10 @@ private void dumpTable(
201201
outTable.bucketsCount = table.getBucketsCount();
202202
outTable.isCompressed = table.isCompressed();
203203

204+
outTable.serializationLib = table.getSerializationLib();
205+
outTable.inputFormat = table.getInputFormat();
206+
outTable.outputFormat = table.getOutputFormat();
207+
204208
outTable.fields = new ArrayList<>();
205209
for (Field field : table.getFields()) {
206210
TableMetadata.FieldMetadata fieldMetadata = new TableMetadata.FieldMetadata();

dumper/lib-dumper-spi/src/main/java/com/google/edwmigration/dumper/plugin/lib/dumper/spi/HiveMetadataDumpFormat.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ public static class PartitionMetadata {
122122
@CheckForNull public Integer bucketsCount;
123123
@CheckForNull public Boolean isCompressed;
124124

125+
@CheckForNull public String serializationLib;
126+
@CheckForNull public String inputFormat;
127+
@CheckForNull public String outputFormat;
128+
125129
@CheckForNull public List<FieldMetadata> fields;
126130
@CheckForNull public List<PartitionKeyMetadata> partitionKeys;
127131
@CheckForNull public List<PartitionMetadata> partitions;

dumper/lib-ext-hive-metastore/src/main/java/com/google/edwmigration/dumper/ext/hive/metastore/HiveMetastoreThriftClient_Superset.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,30 @@ public Boolean isCompressed() {
238238
return table.isSetSd() && table.getSd().isCompressed();
239239
}
240240

241+
@CheckForNull
242+
@Override
243+
public String getSerializationLib(){
244+
return (table.isSetSd() && table.getSd().isSetSerdeInfo() && table.getSd().getSerdeInfo().isSetSerializationLib()
245+
? table.getSd().getSerdeInfo().getSerializationLib()
246+
: null);
247+
}
248+
249+
@CheckForNull
250+
@Override
251+
public String getInputFormat(){
252+
return (table.isSetSd() && table.getSd().isSetInputFormat()
253+
? table.getSd().getInputFormat()
254+
: null);
255+
}
256+
257+
@CheckForNull
258+
@Override
259+
public String getOutputFormat(){
260+
return (table.isSetSd() && table.getSd().isSetOutputFormat()
261+
? table.getSd().getOutputFormat()
262+
: null);
263+
}
264+
241265
@Nonnull
242266
@Override
243267
public List<? extends Field> getFields() throws Exception {

dumper/lib-ext-hive-metastore/src/main/java/com/google/edwmigration/dumper/ext/hive/metastore/HiveMetastoreThriftClient_v2_3_6.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,31 @@ public Boolean isCompressed() {
237237
return table.isSetSd() && table.getSd().isCompressed();
238238
}
239239

240+
@CheckForNull
241+
@Override
242+
public String getSerializationLib(){
243+
return (table.isSetSd() && table.getSd().isSetSerdeInfo() && table.getSd().getSerdeInfo().isSetSerializationLib()
244+
? table.getSd().getSerdeInfo().getSerializationLib()
245+
: null);
246+
}
247+
248+
@CheckForNull
249+
@Override
250+
public String getInputFormat(){
251+
return (table.isSetSd() && table.getSd().isSetInputFormat()
252+
? table.getSd().getInputFormat()
253+
: null);
254+
}
255+
256+
@CheckForNull
257+
@Override
258+
public String getOutputFormat(){
259+
return (table.isSetSd() && table.getSd().isSetOutputFormat()
260+
? table.getSd().getOutputFormat()
261+
: null);
262+
}
263+
264+
240265
@Nonnull
241266
@Override
242267
public List<? extends Field> getFields() throws Exception {

dumper/lib-ext-hive-metastore/src/main/java/com/google/edwmigration/dumper/ext/hive/metastore/Table.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,15 @@ public interface Table {
7373
@CheckForNull
7474
public Boolean isCompressed();
7575

76+
@CheckForNull
77+
public String getSerializationLib();
78+
79+
@CheckForNull
80+
public String getInputFormat();
81+
82+
@CheckForNull
83+
public String getOutputFormat();
84+
7685
@Nonnull
7786
public List<? extends Field> getFields() throws Exception;
7887

0 commit comments

Comments
 (0)