You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by ro...@apache.org on 2016/11/04 00:21:22 UTC

[2/3] incubator-beam git commit: Document the input and output of type conversions

Document the input and output of type conversions


Project: http://git-wip-us.apache.org/repos/asf/incubator-beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-beam/commit/456f9263
Tree: http://git-wip-us.apache.org/repos/asf/incubator-beam/tree/456f9263
Diff: http://git-wip-us.apache.org/repos/asf/incubator-beam/diff/456f9263

Branch: refs/heads/python-sdk
Commit: 456f9263f67c9fb504b633bf84b757ea1a48ee6e
Parents: d66cb17
Author: Sourabh Bajaj <so...@google.com>
Authored: Wed Nov 2 17:53:34 2016 -0700
Committer: Robert Bradshaw <ro...@google.com>
Committed: Thu Nov 3 14:58:38 2016 -0700

----------------------------------------------------------------------
 sdks/python/apache_beam/io/bigquery.py | 9 +++++++++
 1 file changed, 9 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/456f9263/sdks/python/apache_beam/io/bigquery.py
----------------------------------------------------------------------
diff --git a/sdks/python/apache_beam/io/bigquery.py b/sdks/python/apache_beam/io/bigquery.py
index b626432..9c1ee27 100644
--- a/sdks/python/apache_beam/io/bigquery.py
+++ b/sdks/python/apache_beam/io/bigquery.py
@@ -831,27 +831,36 @@ class BigQueryWrapper(object):
       # return True for both!).
       value = from_json_value(cell.v)
       if field.type == 'STRING':
+        # Input: "XYZ" --> Output: "XYZ"
         value = value
       elif field.type == 'BOOLEAN':
+        # Input: "true" --> Output: True
         value = value == 'true'
       elif field.type == 'INTEGER':
+        # Input: "123" --> Output: 123
         value = int(value)
       elif field.type == 'FLOAT':
+        # Input: "1.23" --> Output: 1.23
         value = float(value)
       elif field.type == 'TIMESTAMP':
         # The UTC should come from the timezone library but this is a known
         # issue in python 2.7 so we'll just hardcode it as we're reading using
         # utcfromtimestamp. This is just to match the output from the dataflow
         # runner with the local runner.
+        # Input: 1478134176.985864 --> Output: "2016-11-03 00:49:36.985864 UTC"
         dt = datetime.datetime.utcfromtimestamp(float(value))
         value = dt.strftime('%Y-%m-%d %H:%M:%S.%f UTC')
       elif field.type == 'BYTES':
+        # Input: "YmJi" --> Output: "YmJi"
         value = value
       elif field.type == 'DATE':
+        # Input: "2016-11-03" --> Output: "2016-11-03"
         value = value
       elif field.type == 'DATETIME':
+        # Input: "2016-11-03T00:49:36" --> Output: "2016-11-03T00:49:36"
         value = value
       elif field.type == 'TIME':
+        # Input: "00:49:36" --> Output: "00:49:36"
         value = value
       else:
         # Note that a schema field object supports also a RECORD type. However