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

ASF GitHub Bot logged work on BEAM-6701:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 19/Feb/19 18:57
            Start Date: 19/Feb/19 18:57
    Worklog Time Spent: 10m 
      Work Description: reuvenlax commented on pull request #7865: [BEAM-6701] 
Add logical types to schema
URL: https://github.com/apache/beam/pull/7865#discussion_r258181911
 
 

 ##########
 File path: sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/Schema.java
 ##########
 @@ -531,19 +633,41 @@ public static final FieldType row(Schema schema) {
       return FieldType.forTypeName(TypeName.ROW).setRowSchema(schema).build();
     }
 
+    /** Creates a logical type based on a primitive field type. */
+    public static final <InputT, BaseT> FieldType logicalType(
+        LogicalType<InputT, BaseT> logicalType) {
+      return FieldType.forTypeName(TypeName.LOGICAL_TYPE)
+          .setLogicalType(logicalType)
+          .build()
+          .withMetadata(LOGICAL_TYPE_IDENTIFIER, logicalType.getIdentifier())
+          .withMetadata(LOGICAL_TYPE_ARGUMENT, logicalType.getArgument());
+    }
+
     /** Returns a copy of the descriptor with metadata set. */
-    public FieldType withMetadata(@Nullable byte[] metadata) {
-      return toBuilder().setMetadata(metadata).build();
+    public FieldType withMetadata(String key, byte[] metadata) {
 
 Review comment:
   Sorry, it got messed up. Fixed now.
 
----------------------------------------------------------------
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:
[email protected]


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

    Worklog Id:     (was: 200817)
    Time Spent: 3h 10m  (was: 3h)

> Create LogicalType for Schema fields
> ------------------------------------
>
>                 Key: BEAM-6701
>                 URL: https://issues.apache.org/jira/browse/BEAM-6701
>             Project: Beam
>          Issue Type: Sub-task
>          Components: sdk-java-core
>            Reporter: Reuven Lax
>            Assignee: Reuven Lax
>            Priority: Major
>          Time Spent: 3h 10m
>  Remaining Estimate: 0h
>
> This will allow users to create their own logical types to store in schema 
> fields, backed by one of the fundamental schema field types. Today SQL hacks 
> on top of the field metadata to distinguish its types. LogicalTypes would 
> allow for a more principled way of doing this.



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

Reply via email to