diff --git a/src/fdw.py b/src/fdw.py index 76b19c1..abcfa1b 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): @@ -414,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 @@ -441,7 +444,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 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()