This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-c108335-hive-sql
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-c108335-hive-sql by
this push:
new be6f138729f [tmp] use table to get hive schema
be6f138729f is described below
commit be6f138729f58aa9a6baf44c13c846bc85597997
Author: morningman <[email protected]>
AuthorDate: Mon Apr 14 14:19:04 2025 +0800
[tmp] use table to get hive schema
---
.../doris/datasource/hive/HMSExternalTable.java | 24 +++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HMSExternalTable.java
b/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HMSExternalTable.java
index b17493989fd..efd1c7c762a 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HMSExternalTable.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HMSExternalTable.java
@@ -61,6 +61,7 @@ import org.apache.doris.thrift.TTableDescriptor;
import org.apache.doris.thrift.TTableType;
import com.google.common.collect.BiMap;
+import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
@@ -77,6 +78,7 @@ import
org.apache.hadoop.hive.metastore.api.DoubleColumnStatsData;
import org.apache.hadoop.hive.metastore.api.FieldSchema;
import org.apache.hadoop.hive.metastore.api.LongColumnStatsData;
import org.apache.hadoop.hive.metastore.api.Partition;
+import org.apache.hadoop.hive.metastore.api.Table;
import org.apache.hadoop.hive.metastore.api.StringColumnStatsData;
import org.apache.hadoop.hive.ql.io.AcidUtils;
import org.apache.hudi.common.table.HoodieTableMetaClient;
@@ -592,7 +594,7 @@ public class HMSExternalTable extends ExternalTable
implements MTMVRelatedTableI
} else if (dlaType.equals(DLAType.HUDI)) {
return getHudiSchema();
} else {
- return getHiveSchema();
+ return getHiveSchema2();
}
}
@@ -618,6 +620,26 @@ public class HMSExternalTable extends ExternalTable
implements MTMVRelatedTableI
return Optional.of(hudiSchemaCacheValue);
}
+ private static List<FieldSchema> getSchemaFromTable(Table table) {
+ ImmutableList.Builder<FieldSchema> schema = ImmutableList.builder();
+ schema.addAll(table.getSd().getCols());
+ schema.addAll(table.getPartitionKeys());
+ return schema.build();
+ }
+
+ private Optional<SchemaCacheValue> getHiveSchema2() {
+ List<FieldSchema> schema = getSchemaFromTable(this.remoteTable);
+ List<Column> columns = Lists.newArrayListWithCapacity(schema.size());
+ for (FieldSchema field : schema) {
+ String fieldName = field.getName().toLowerCase(Locale.ROOT);
+ columns.add(new Column(fieldName,
+
HiveMetaStoreClientHelper.hiveTypeToDorisType(field.getType()), true, null,
+ true, null, field.getComment(), true, -1));
+ }
+ List<Column> partitionColumns = initPartitionColumns(columns);
+ return Optional.of(new HMSSchemaCacheValue(columns, partitionColumns));
+ }
+
private Optional<SchemaCacheValue> getHiveSchema() {
HMSCachedClient client = ((HMSExternalCatalog) catalog).getClient();
List<FieldSchema> schema = client.getSchema(dbName, name);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]