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

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

                Author: ASF GitHub Bot
            Created on: 07/Feb/19 00:18
            Start Date: 07/Feb/19 00:18
    Worklog Time Spent: 10m 
      Work Description: chamikaramj commented on pull request #7441: 
[BEAM-6392] Add support for the BigQuery read API to BigQueryIO.
URL: https://github.com/apache/beam/pull/7441#discussion_r254505832
 
 

 ##########
 File path: 
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryAvroUtils.java
 ##########
 @@ -177,27 +250,47 @@ private static Object convertRequiredField(
     // Per https://cloud.google.com/bigquery/docs/reference/v2/tables#schema, 
the type field
     // is required, so it may not be null.
     String bqType = fieldSchema.getType();
-    Type expectedAvroType = BIG_QUERY_TO_AVRO_TYPES.get(bqType);
-    verifyNotNull(expectedAvroType, "Unsupported BigQuery type: %s", bqType);
+    ImmutableCollection<Type> expectedAvroTypes = 
BIG_QUERY_TO_AVRO_TYPES.get(bqType);
+    verifyNotNull(expectedAvroTypes, "Unsupported BigQuery type: %s", bqType);
     verify(
-        avroType == expectedAvroType,
-        "Expected Avro schema type %s, not %s, for BigQuery %s field %s",
-        expectedAvroType,
-        avroType,
+        expectedAvroTypes.contains(avroType),
+        "Expected Avro schema types %s for BigQuery %s field %s, but received 
%s",
+        expectedAvroTypes,
         bqType,
-        fieldSchema.getName());
+        fieldSchema.getName(),
+        avroType);
     // For historical reasons, don't validate avroLogicalType except for with 
NUMERIC.
     // BigQuery represents NUMERIC in Avro format as BYTES with a DECIMAL 
logical type.
-    switch (fieldSchema.getType()) {
+    switch (bqType) {
       case "STRING":
-      case "DATE":
       case "DATETIME":
-      case "TIME":
       case "GEOGRAPHY":
         // Avro will use a CharSequence to represent String objects, but it 
may not always use
         // java.lang.String; for example, it may prefer 
org.apache.avro.util.Utf8.
         verify(v instanceof CharSequence, "Expected CharSequence (String), got 
%s", v.getClass());
         return v.toString();
+      case "DATE":
+        if (avroType == Type.INT) {
+          verify(v instanceof Integer, "Expected Integer, got %s", 
v.getClass());
 
 Review comment:
   For the record (based on offline chat), this change just generalizes the 
current behavior and does not break backwards compatibility.
 
----------------------------------------------------------------
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: 195445)
    Time Spent: 2h 50m  (was: 2h 40m)

> Add support for new BigQuery streaming read API to BigQueryIO
> -------------------------------------------------------------
>
>                 Key: BEAM-6392
>                 URL: https://issues.apache.org/jira/browse/BEAM-6392
>             Project: Beam
>          Issue Type: New Feature
>          Components: io-java-gcp
>            Reporter: Kenneth Jung
>            Assignee: Kenneth Jung
>            Priority: Major
>          Time Spent: 2h 50m
>  Remaining Estimate: 0h
>
> BigQuery has developed a new streaming egress API which will soon reach 
> public availability. Add support for the new API in BigQueryIO.



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

Reply via email to