[
https://issues.apache.org/jira/browse/BEAM-6139?focusedWorklogId=173062&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-173062
]
ASF GitHub Bot logged work on BEAM-6139:
----------------------------------------
Author: ASF GitHub Bot
Created on: 07/Dec/18 21:03
Start Date: 07/Dec/18 21:03
Worklog Time Spent: 10m
Work Description: chamikaramj closed pull request #7144: [BEAM-6139]
Adding support for BQ GEOGRAPHY data type
URL: https://github.com/apache/beam/pull/7144
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/sdks/python/apache_beam/io/gcp/bigquery.py
b/sdks/python/apache_beam/io/gcp/bigquery.py
index f8f9d80ea157..dd70ac14ef9b 100644
--- a/sdks/python/apache_beam/io/gcp/bigquery.py
+++ b/sdks/python/apache_beam/io/gcp/bigquery.py
@@ -98,7 +98,8 @@
TableFieldSchema: Describes the schema (type, name) for one field.
Has several attributes, including 'name' and 'type'. Common values for
- the type attribute are: 'STRING', 'INTEGER', 'FLOAT', 'BOOLEAN', 'NUMERIC'.
+ the type attribute are: 'STRING', 'INTEGER', 'FLOAT', 'BOOLEAN', 'NUMERIC',
+ 'GEOGRAPHY'.
All possible values are described at:
https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types
@@ -111,6 +112,9 @@
As of Beam 2.7.0, the NUMERIC data type is supported. This data type supports
high-precision decimal numbers (precision of 38 digits, scale of 9 digits).
+The GEOGRAPHY data type works with Well-Known Text (See
+https://en.wikipedia.org/wiki/Well-known_text) format for reading and writing
+to BigQuery.
"""
from __future__ import absolute_import
@@ -1243,6 +1247,8 @@ def _convert_cell_value_to_dict(self, value, field):
return self.convert_row_to_dict(value, field)
elif field.type == 'NUMERIC':
return decimal.Decimal(value)
+ elif field.type == 'GEOGRAPHY':
+ return value
else:
raise RuntimeError('Unexpected field type: %s' % field.type)
diff --git a/sdks/python/apache_beam/io/gcp/bigquery_test.py
b/sdks/python/apache_beam/io/gcp/bigquery_test.py
index ffd6a6f04748..b9ad27a1578a 100644
--- a/sdks/python/apache_beam/io/gcp/bigquery_test.py
+++ b/sdks/python/apache_beam/io/gcp/bigquery_test.py
@@ -99,20 +99,23 @@ def test_row_as_table_row(self):
('f', 'FLOAT'),
('b', 'BOOLEAN'),
('n', 'NUMERIC'),
- ('r', 'RECORD')]
+ ('r', 'RECORD'),
+ ('g', 'GEOGRAPHY')]
data_definition = [
'abc',
123,
123.456,
True,
decimal.Decimal('987654321.987654321'),
- {'a': 'b'}]
+ {'a': 'b'},
+ 'LINESTRING(1 2, 3 4, 5 6, 7 8)']
str_def = ('{"s": "abc", '
'"i": 123, '
'"f": 123.456, '
'"b": true, '
'"n": "987654321.987654321", '
- '"r": {"a": "b"}}')
+ '"r": {"a": "b"}, '
+ '"g": "LINESTRING(1 2, 3 4, 5 6, 7 8)"}')
schema = bigquery.TableSchema(
fields=[bigquery.TableFieldSchema(name=k, type=v)
for k, v in schema_definition])
----------------------------------------------------------------
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: 173062)
Time Spent: 1h 50m (was: 1h 40m)
> Support for GEOGRAPHY data type in BQ sources
> ---------------------------------------------
>
> Key: BEAM-6139
> URL: https://issues.apache.org/jira/browse/BEAM-6139
> Project: Beam
> Issue Type: Bug
> Components: io-java-gcp, sdk-py-core
> Reporter: Pablo Estrada
> Assignee: Pablo Estrada
> Priority: Major
> Time Spent: 1h 50m
> Remaining Estimate: 0h
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)