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

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

                Author: ASF GitHub Bot
            Created on: 06/Apr/19 00:56
            Start Date: 06/Apr/19 00:56
    Worklog Time Spent: 10m 
      Work Description: tvalentyn commented on pull request #8047: [BEAM-6769] 
write bytes to bigquery in python 2
URL: https://github.com/apache/beam/pull/8047#discussion_r272776978
 
 

 ##########
 File path: sdks/python/apache_beam/io/gcp/big_query_query_to_table_it_test.py
 ##########
 @@ -48,12 +49,13 @@
 NEW_TYPES_OUTPUT_SCHEMA = (
     '{"fields": [{"name": "bytes","type": "BYTES"},'
     '{"name": "date","type": "DATE"},{"name": "time","type": "TIME"}]}')
-NEW_TYPES_OUTPUT_VERIFY_QUERY = ('SELECT date FROM `%s`;')
-# There are problems with query time and bytes with current version of 
bigquery.
+NEW_TYPES_OUTPUT_VERIFY_QUERY = ('SELECT bytes, date, time FROM `%s`;')
 NEW_TYPES_OUTPUT_EXPECTED = [
-    (datetime.date(2000, 1, 1),),
-    (datetime.date(2011, 1, 1),),
-    (datetime.date(3000, 12, 31),)]
+    (b'xyw=', datetime.date(2011, 1, 1), datetime.time(23, 59, 59, 999999),),
 
 Review comment:
   Let's remove the `=` sign after `xyw` and others here to avoid confusion 
that these strings need to be base64-encoded (odd-length base64 encoded strings 
are padded with `=`).
   Also, let's replace one of the usecases with a utf-8-decodable 
byte-sequence. This use-case will help to make sure that this sequence doesn't 
get accidentally decoded somewhere. For example, we can use 
`b'\xe4\xbd\xa0\xe5\xa5\xbd'`. 
 
----------------------------------------------------------------
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:
us...@infra.apache.org


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

    Worklog Id:     (was: 223969)
    Time Spent: 3h 50m  (was: 3h 40m)

> BigQuery IO does not support bytes in Python 3
> ----------------------------------------------
>
>                 Key: BEAM-6769
>                 URL: https://issues.apache.org/jira/browse/BEAM-6769
>             Project: Beam
>          Issue Type: Sub-task
>          Components: sdk-py-core
>            Reporter: Juta Staes
>            Assignee: Juta Staes
>            Priority: Major
>          Time Spent: 3h 50m
>  Remaining Estimate: 0h
>
> In Python 2 you could write bytes data to BigQuery. This is tested in
>  
> [https://github.com/apache/beam/blob/master/sdks/python/apache_beam/io/gcp/big_query_query_to_table_it_test.py#L186]
> Python 3 does not support
> {noformat}
> json.dumps({'test': b'test'}){noformat}
> which is used to encode the data in
>  
> [https://github.com/apache/beam/blob/master/sdks/python/apache_beam/io/gcp/bigquery_tools.py#L959]
>  
> How should writing bytes to BigQuery be handled in Python 3?
>  * Forbid writing bytes into BigQuery on Python 3
>  * Guess the encoding (utf-8?)
>  * Pass the encoding to BigQuery
> cc: [~tvalentyn]



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

Reply via email to