[ 
https://issues.apache.org/jira/browse/HIVE-26395?focusedWorklogId=791090&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-791090
 ]

ASF GitHub Bot logged work on HIVE-26395:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 14/Jul/22 18:26
            Start Date: 14/Jul/22 18:26
    Worklog Time Spent: 10m 
      Work Description: kasakrisz commented on code in PR #3443:
URL: https://github.com/apache/hive/pull/3443#discussion_r921375990


##########
ql/src/java/org/apache/hadoop/hive/ql/io/parquet/serde/ParquetHiveSerDe.java:
##########
@@ -234,4 +251,161 @@ StructTypeInfo prune() {
       return (StructTypeInfo) TypeInfoFactory.getStructTypeInfo(newNames, 
newTypes);
     }
   }
+
+  // ReadSchema interface implementation
+  private String convertGroupType(GroupType group) throws SerDeException {
+    boolean first = true;
+    StringBuilder sb = new StringBuilder(serdeConstants.STRUCT_TYPE_NAME + 
"<");
+    for (Type field: group.getFields()) {
+      if (first) {
+        first = false;
+      } else {
+        sb.append(",");
+      }
+      // fieldName:typeName
+      sb.append(field.getName() + ":" + convertParquetTypeToFieldType(field));

Review Comment:
   nit.:
   ```
   
sb.append(field.getName()).sb.append(":").sb.append(convertParquetTypeToFieldType(field));
   ```



##########
ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java:
##########
@@ -13477,6 +13480,23 @@ private boolean hasConstraints(final List<FieldSchema> 
partCols, final List<SQLD
     }
     return false;
   }
+
+  boolean doesSupportSchemaInference(String fileFormat) throws 
SemanticException {
+    StorageFormatFactory storageFormatFactory = new StorageFormatFactory();
+    StorageFormatDescriptor descriptor = storageFormatFactory.get(fileFormat);
+    if (descriptor == null) {
+      throw new SemanticException("CREATE TABLE LIKE FILE is not supported by 
the '" + likeFileFormat + "' file format");

Review Comment:
   Could you please create error messages for this in 
   
https://github.com/apache/hive/blob/c6b07f27903f7d6856a6edf1b5d756119fa522c1/common/src/java/org/apache/hadoop/hive/ql/ErrorMsg.java#L44
   String formatting is supported:
   
https://github.com/apache/hive/blob/c6b07f27903f7d6856a6edf1b5d756119fa522c1/common/src/java/org/apache/hadoop/hive/ql/ErrorMsg.java#L481
   





Issue Time Tracking
-------------------

    Worklog Id:     (was: 791090)
    Time Spent: 0.5h  (was: 20m)

> Support CREATE TABLE LIKE FILE for PARQUET
> ------------------------------------------
>
>                 Key: HIVE-26395
>                 URL: https://issues.apache.org/jira/browse/HIVE-26395
>             Project: Hive
>          Issue Type: New Feature
>          Components: HiveServer2
>            Reporter: John Sherman
>            Assignee: John Sherman
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> The intent is to allow a user to create a table and derive the schema from a 
> user provided parquet file. A secondary goal is to generalize this support so 
> other SerDes/formats could implement the feature easily.
> The proposed syntax is:
> CREATE TABLE <tableName> LIKE FILE <fileFormat> 'path to file';
> Example being:
> {code:java}
> CREATE TABLE like_test_all_types LIKE FILE PARQUET 
> '${system:test.tmp.dir}/test_all_types/000000_0';{code}
> with partitioning
> {code}
> CREATE TABLE like_test_partitioning LIKE FILE PARQUET 
> '${system:test.tmp.dir}/test_all_types/000000_0' PARTITIONED BY (year STRING, 
> month STRING);
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to