Skip to content

Commit

Permalink
[improvement]support add comment to hive table
Browse files Browse the repository at this point in the history
  • Loading branch information
Aireed committed Jan 3, 2025
1 parent 907973e commit b407eea
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;

public class MixedHiveTables {

Expand Down Expand Up @@ -510,6 +511,11 @@ private org.apache.hadoop.hive.metastore.api.Table newHiveTable(
TableMeta meta, Schema schema, PartitionSpec partitionSpec) {
final long currentTimeMillis = System.currentTimeMillis();

// set table comment here!
Map<String, String> parameters = new HashMap<>();
Optional<String> comment = Optional.ofNullable(meta.getProperties().get("comment"));
comment.ifPresent(val -> parameters.put("comment", val));

org.apache.hadoop.hive.metastore.api.Table newTable =
new org.apache.hadoop.hive.metastore.api.Table(
meta.getTableIdentifier().getTableName(),
Expand All @@ -521,7 +527,7 @@ private org.apache.hadoop.hive.metastore.api.Table newHiveTable(
Integer.MAX_VALUE,
null,
HiveSchemaUtil.hivePartitionFields(schema, partitionSpec),
new HashMap<>(),
parameters,
null,
null,
TableType.EXTERNAL_TABLE.toString());
Expand Down

0 comments on commit b407eea

Please sign in to comment.