[ 
https://issues.apache.org/jira/browse/PARQUET-1253?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16468895#comment-16468895
 ] 

ASF GitHub Bot commented on PARQUET-1253:
-----------------------------------------

gszadovszky commented on a change in pull request #463: PARQUET-1253: Support 
for new logical type representation
URL: https://github.com/apache/parquet-mr/pull/463#discussion_r187055416
 
 

 ##########
 File path: 
parquet-column/src/main/java/org/apache/parquet/schema/LogicalTypeAnnotation.java
 ##########
 @@ -36,42 +36,152 @@
 import org.apache.parquet.format.TimeType;
 import org.apache.parquet.format.TimestampType;
 
+import java.util.List;
 import java.util.Objects;
 
-public interface LogicalTypeAnnotation {
+public abstract class LogicalTypeAnnotation {
+  public enum LogicalTypes {
+    MAP {
+      @Override
+      protected LogicalTypeAnnotation fromString(List<String> params) {
+        return mapType();
+      }
+    },
+    LIST {
+      @Override
+      protected LogicalTypeAnnotation fromString(List<String> params) {
+        return listType();
+      }
+    },
+    UTF8 {
+      @Override
+      protected LogicalTypeAnnotation fromString(List<String> params) {
+        return stringType();
+      }
+    },
+    MAP_KEY_VALUE {
+      @Override
+      protected LogicalTypeAnnotation fromString(List<String> params) {
+        return MapKeyValueTypeAnnotation.getInstance();
+      }
+    },
+    ENUM {
+      @Override
+      protected LogicalTypeAnnotation fromString(List<String> params) {
+        return enumType();
+      }
+    },
+    DECIMAL {
+      @Override
+      protected LogicalTypeAnnotation fromString(List<String> params) {
+        if (params.size() != 2) {
+          throw new RuntimeException("Expecting 2 parameters for decimal 
logical type, got " + params.size());
+        }
+        return decimalType(Integer.valueOf(params.get(1)), 
Integer.valueOf(params.get(0)));
+      }
+    },
+    DATE {
+      @Override
+      protected LogicalTypeAnnotation fromString(List<String> params) {
+        return dateType();
+      }
+    },
+    TIME {
+      @Override
+      protected LogicalTypeAnnotation fromString(List<String> params) {
+        if (params.size() != 2) {
+          throw new RuntimeException("Expecting 2 parameters for time logical 
type, got " + params.size());
+        }
+        return timeType(Boolean.parseBoolean(params.get(1)), 
TimeUnit.valueOf(params.get(0)));
+      }
+    },
+    TIMESTAMP {
+      @Override
+      protected LogicalTypeAnnotation fromString(List<String> params) {
+        if (params.size() != 2) {
+          throw new RuntimeException("Expecting 2 parameters for timestamp 
logical type, got " + params.size());
+        }
+        return timestampType(Boolean.parseBoolean(params.get(1)), 
TimeUnit.valueOf(params.get(0)));
+      }
+    },
+    INT {
+      @Override
+      protected LogicalTypeAnnotation fromString(List<String> params) {
+        if (params.size() != 2) {
+          throw new RuntimeException("Expecting 2 parameters for integer 
logical type, got " + params.size());
+        }
+        return intType(Integer.valueOf(params.get(0)), 
Boolean.parseBoolean(params.get(1)));
+      }
+    },
+    JSON {
+      @Override
+      protected LogicalTypeAnnotation fromString(List<String> params) {
+        return jsonType();
+      }
+    },
+    BSON {
+      @Override
+      protected LogicalTypeAnnotation fromString(List<String> params) {
+        return bsonType();
+      }
+    },
+    INTERVAL {
+      @Override
+      protected LogicalTypeAnnotation fromString(List<String> params) {
+        return IntervalLogicalTypeAnnotation.getInstance();
+      }
+    };
+
+    protected abstract LogicalTypeAnnotation fromString(List<String> params);
+  }
+
   /**
    * Convert this parquet-mr logical type to parquet-format LogicalType.
    *
    * @return the parquet-format LogicalType representation of this logical 
type implementation
    */
-  LogicalType toLogicalType();
+  public abstract LogicalType toLogicalType();
 
   /**
    * Convert this parquet-mr logical type to parquet-format ConvertedType.
    *
    * @return the parquet-format ConvertedType representation of this logical 
type implementation
    */
-  ConvertedType toConvertedType();
+  public abstract ConvertedType toConvertedType();
 
   /**
    * Convert this logical type to old logical type representation in 
parquet-mr (if there's any).
    * Those logical type implementations, which don't have a corresponding 
mapping should return null.
    *
    * @return the OriginalType representation of the new logical type, or null 
if there's none
    */
-  OriginalType toOriginalType();
+  public abstract OriginalType toOriginalType();
 
   /**
    * Visits this logical type with the given visitor
    *
    * @param logicalTypeAnnotationVisitor the visitor to visit this type
    */
-  void accept(LogicalTypeAnnotationVisitor logicalTypeAnnotationVisitor);
+  public abstract void accept(LogicalTypeAnnotationVisitor 
logicalTypeAnnotationVisitor);
+
+  public abstract LogicalTypes getType();
 
 Review comment:
   Sorry, I meant `getType()`.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Support for new logical type representation
> -------------------------------------------
>
>                 Key: PARQUET-1253
>                 URL: https://issues.apache.org/jira/browse/PARQUET-1253
>             Project: Parquet
>          Issue Type: Improvement
>          Components: parquet-mr
>            Reporter: Nandor Kollar
>            Assignee: Nandor Kollar
>            Priority: Major
>
> Latest parquet-format 
> [introduced|https://github.com/apache/parquet-format/commit/863875e0be3237c6aa4ed71733d54c91a51deabe#diff-0f9d1b5347959e15259da7ba8f4b6252]
>  a new representation for logical types. As of now this is not yet supported 
> in parquet-mr, thus there's no way to use parametrized UTC normalized 
> timestamp data types. When reading and writing Parquet files, besides 
> 'converted_type' parquet-mr should use the new 'logicalType' field in 
> SchemaElement to tell the current logical type annotation. To maintain 
> backward compatibility, the semantic of converted_type shouldn't change.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to