You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@beam.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2020/03/01 06:13:00 UTC

[jira] [Work logged] (BEAM-9384) Add SchemaRegistry.getSchemaCoder to get SchemaCoders for registered types

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

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

                Author: ASF GitHub Bot
            Created on: 01/Mar/20 06:12
            Start Date: 01/Mar/20 06:12
    Worklog Time Spent: 10m 
      Work Description: iemejia commented on pull request #10974: [BEAM-9384] Add SchemaRegistry.getSchemaCoder to get SchemaCoders for registered types
URL: https://github.com/apache/beam/pull/10974#discussion_r386080476
 
 

 ##########
 File path: sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/SchemaRegistry.java
 ##########
 @@ -288,6 +281,38 @@ public void registerSchemaProvider(SchemaProvider schemaProvider) {
     return getProviderResult((SchemaProvider p) -> p.fromRowFunction(typeDescriptor));
   }
 
+  /**
+   * Retrieve a {@link SchemaCoder} for a given {@link Class} type. If no schema exists, throws
+   * {@link * NoSuchSchemaException}.
+   */
+  public <T> SchemaCoder<T> getSchemaCoder(Class<T> clazz) throws NoSuchSchemaException {
+    return getSchemaCoder(TypeDescriptor.of(clazz));
+  }
+
+  /**
+   * Retrieve a {@link SchemaCoder} for a given {@link TypeDescriptor} type. If no schema exists,
+   * throws {@link * NoSuchSchemaException}.
+   */
+  public <T> SchemaCoder<T> getSchemaCoder(TypeDescriptor<T> typeDescriptor)
+      throws NoSuchSchemaException {
+    return SchemaCoder.of(
+        getSchema(typeDescriptor),
+        typeDescriptor,
+        getToRowFunction(typeDescriptor),
+        getFromRowFunction(typeDescriptor));
 
 Review comment:
   Interesting. I have not thought about making KafkaRecord 'schema' like good point. There are some consequences on that that are still not clear to me (like how will we deal with the runtime resolution part of Schemas for KV that we do now with the Confluent Schema Registry support. I am going to give it a try and ping you once I have something in the other PR #10978. Let's continue that discussion there. 
 
----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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

    Worklog Id:     (was: 395542)
    Time Spent: 5h  (was: 4h 50m)

> Add SchemaRegistry.getSchemaCoder to get SchemaCoders for registered types
> --------------------------------------------------------------------------
>
>                 Key: BEAM-9384
>                 URL: https://issues.apache.org/jira/browse/BEAM-9384
>             Project: Beam
>          Issue Type: Improvement
>          Components: sdk-java-core
>            Reporter: Ismaël Mejía
>            Assignee: Ismaël Mejía
>            Priority: Minor
>          Time Spent: 5h
>  Remaining Estimate: 0h
>
> PTransforms that are parameterized by types may be able to infer a valid SchemaCoder for a given type from the SchemaRegistry (if a Schema for the given type is available). This method will provide a unified place to do that.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)