deniskuzZ commented on code in PR #5995:
URL: https://github.com/apache/hive/pull/5995#discussion_r2287838669
##########
iceberg/iceberg-catalog/src/main/java/org/apache/iceberg/hive/MetastoreUtil.java:
##########
@@ -87,4 +103,39 @@ public static void alterTable(
}
}
}
+
+ public static Table convertIcebergTableToHiveTable(org.apache.iceberg.Table
icebergTable, Configuration conf) {
Review Comment:
please replace with (column conversion is wrong):
````
public static Table toHiveTable(org.apache.iceberg.Table table,
Configuration conf) {
var result = new Table();
TableName tableName = TableName.fromString(table.name(), null, null);
result.setDbName(tableName.getDb());
result.setTableName(tableName.getTable());
result.setTableType(TableType.EXTERNAL_TABLE.toString());
/*result.setPartitionKeys(
IcebergTableUtil.getPartitionKeys(table, table.spec().specId()));*/
TableMetadata metadata = ((BaseTable) table).operations().current();
long maxHiveTablePropertySize =
conf.getLong(HiveOperationsBase.HIVE_TABLE_PROPERTY_MAX_SIZE,
HiveOperationsBase.HIVE_TABLE_PROPERTY_MAX_SIZE_DEFAULT);
HMSTablePropertyHelper.updateHmsTableForIcebergTable(metadata.metadataFileLocation(),
result, metadata,
null, true, maxHiveTablePropertySize, null);
result.getParameters().put(CatalogUtils.ICEBERG_CATALOG_TYPE,
CatalogUtil.ICEBERG_CATALOG_TYPE_REST);
result.setSd(toHiveStorageDescriptor(table));
return result;
}
private static StorageDescriptor
toHiveStorageDescriptor(org.apache.iceberg.Table table) {
var result = new StorageDescriptor();
result.setCols(HiveSchemaUtil.convert(table.schema()));
result.setBucketCols(Lists.newArrayList());
result.setNumBuckets(-1);
result.setSortCols(Lists.newArrayList());
result.setInputFormat(DEFAULT_INPUT_FORMAT_CLASS);
result.setOutputFormat(DEFAULT_OUTPUT_FORMAT_CLASS);
result.setSerdeInfo(getHiveSerdeInfo());
result.setLocation(table.location());
result.setParameters(Maps.newHashMap());
return result;
}
private static SerDeInfo getHiveSerdeInfo() {
var result = new SerDeInfo("icebergSerde", DEFAULT_SERDE_CLASS,
Maps.newHashMap());
result.getParameters().put(serdeConstants.SERIALIZATION_FORMAT, "1"); //
Default serialization format.
return result;
}
````
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]