From c8fa92102727c8b3477cef00d7fe61248b16945b Mon Sep 17 00:00:00 2001 From: Gabriel Bordeaux Date: Sat, 17 Sep 2022 17:35:07 -0400 Subject: [PATCH 1/4] Add support for PostGIS data types --- src/fdw.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/fdw.py b/src/fdw.py index 76b19c1..0ff362e 100644 --- a/src/fdw.py +++ b/src/fdw.py @@ -76,6 +76,8 @@ def setDatatypes(self): datatype('date', 'DATE', 'DATE'), datatype('time without time zone', 'TIME', 'TIME'), datatype('timestamp without time zone', 'DATETIME', 'DATETIME'), + datatype('geometry', 'GEOGRAPHY', None), # GEOGRAPHY does not exists in legacy SQL + datatype('geography', 'GEOGRAPHY', None), # GEOGRAPHY does not exists in legacy SQL ] def setConversionRules(self): @@ -441,7 +443,8 @@ def getBigQueryDatatype(self, column, dialect='standard'): if datatype.postgres == pgDatatype: # If the PostgreSQL data type matches the known data type # Returns equivalent BigQuery data type if dialect == 'legacy': - return datatype.bq_legacy + if datatype.bq_legacy: # If there is a matching type + return datatype.bq_legacy else: return datatype.bq_standard From ffa9a5cc2d0f229a07397d0ba97e790d9b989c7a Mon Sep 17 00:00:00 2001 From: Gabriel Bordeaux Date: Sat, 17 Sep 2022 17:35:29 -0400 Subject: [PATCH 2/4] Bump version number --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index a9d1917..380a76a 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setup( name='bigquery-fdw', - version='2.1', + version='2.2', description='BigQuery Foreign Data Wrapper for PostgreSQL', long_description=long_description, author='Gabriel Bordeaux', From 81ab9cb0c861e78e8147165dd67f0a056278c270 Mon Sep 17 00:00:00 2001 From: Gabriel Bordeaux Date: Sat, 17 Sep 2022 17:44:30 -0400 Subject: [PATCH 3/4] Fix assertion in Unit Test --- src/unittest/test_fdw.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unittest/test_fdw.py b/src/unittest/test_fdw.py index c27d52c..2fd42e6 100644 --- a/src/unittest/test_fdw.py +++ b/src/unittest/test_fdw.py @@ -63,7 +63,7 @@ def test_setDatatypes(self): self.assertIsInstance(datatype, tuple) self.assertIsInstance(datatype.postgres, str) self.assertIsInstance(datatype.bq_standard, str) - self.assertIsInstance(datatype.bq_legacy, str) + assert isinstance(datatype.bq_legacy, str) or datatype.bq_legacy is None def test_setConversionRules(self): self.fdw.setConversionRules() From 605631d57e3a4ac7fa88cc4699b354b7fb81b097 Mon Sep 17 00:00:00 2001 From: Gabriel Bordeaux Date: Sat, 17 Sep 2022 17:47:04 -0400 Subject: [PATCH 4/4] Code simplification --- src/fdw.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/fdw.py b/src/fdw.py index 0ff362e..abcfa1b 100644 --- a/src/fdw.py +++ b/src/fdw.py @@ -416,9 +416,10 @@ def getOperator(self, operator): operators = ['=', '<', '>', '<=', '>=', '!=', '<>', 'LIKE', 'NOT LIKE'] # Mapping between multicorn operators and BigQuery operators - mapping = {} - mapping['~~'] = 'LIKE' - mapping['!~~'] = 'NOT LIKE' + mapping = { + '~~': 'LIKE', + '!~~': 'NOT LIKE', + } if operator in operators: # Operator is natively supported return operator