You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/05/17 02:55:06 UTC

[GitHub] [incubator-doris] qidaye commented on a diff in pull request #9593: [Feature]Support create hive table without column info.

qidaye commented on code in PR #9593:
URL: https://github.com/apache/incubator-doris/pull/9593#discussion_r874314680


##########
fe/fe-core/src/main/java/org/apache/doris/catalog/HiveTable.java:
##########
@@ -74,6 +89,92 @@ public Map<String, String> getHiveProperties() {
         return hiveProperties;
     }
 
+    @Override
+    public List<Column> getBaseSchema(boolean full) {
+        if (isLocalSchema) {
+            return super.getBaseSchema(full);
+        }
+        List<Column> hiveMetastoreSchema = Lists.newArrayList();
+        try {
+            for (FieldSchema field : HiveMetaStoreClientHelper.getSchema(this)) {
+                field.getType();
+                hiveMetastoreSchema.add(new Column(field.getName(), convertToDorisType(field.getType()),
+                        true, null, true, null, field.getComment()));
+            }
+        } catch (DdlException e) {
+            LOG.warn("Failed to get schema of hive table. DB {}, Table {}. {}",
+                    this.hiveDb, this.hiveTable, e.getMessage());
+            return null;
+        }
+        fullSchema = hiveMetastoreSchema;
+        return fullSchema;
+    }
+
+    public Column getColumn(String name) {

Review Comment:
   Unused function.



##########
fe/fe-core/src/main/java/org/apache/doris/catalog/HiveTable.java:
##########
@@ -74,6 +89,92 @@ public Map<String, String> getHiveProperties() {
         return hiveProperties;
     }
 
+    @Override
+    public List<Column> getBaseSchema(boolean full) {
+        if (isLocalSchema) {
+            return super.getBaseSchema(full);
+        }
+        List<Column> hiveMetastoreSchema = Lists.newArrayList();
+        try {
+            for (FieldSchema field : HiveMetaStoreClientHelper.getSchema(this)) {
+                field.getType();
+                hiveMetastoreSchema.add(new Column(field.getName(), convertToDorisType(field.getType()),
+                        true, null, true, null, field.getComment()));
+            }
+        } catch (DdlException e) {
+            LOG.warn("Failed to get schema of hive table. DB {}, Table {}. {}",
+                    this.hiveDb, this.hiveTable, e.getMessage());
+            return null;
+        }
+        fullSchema = hiveMetastoreSchema;
+        return fullSchema;
+    }
+
+    public Column getColumn(String name) {
+        if (isLocalSchema) {
+            return nameToColumn.get(name);
+        }
+        Column col = null;
+        if (fullSchema == null || fullSchema.size() == 0) {
+            getBaseSchema(true);
+        }
+        for (Column column : fullSchema) {
+            if (column.getName().equals(name)) {
+                return column;
+            }
+        }
+        return col;
+    }
+
+    private Type convertToDorisType(String hiveType) {

Review Comment:
   `boolean`, `timestamp` are missing.



##########
fe/fe-core/src/main/java/org/apache/doris/catalog/HiveTable.java:
##########
@@ -74,6 +89,92 @@ public Map<String, String> getHiveProperties() {
         return hiveProperties;
     }
 
+    @Override
+    public List<Column> getBaseSchema(boolean full) {
+        if (isLocalSchema) {
+            return super.getBaseSchema(full);
+        }
+        List<Column> hiveMetastoreSchema = Lists.newArrayList();
+        try {
+            for (FieldSchema field : HiveMetaStoreClientHelper.getSchema(this)) {
+                field.getType();

Review Comment:
   unused code.



-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org