Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/fdw.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/unittest/test_fdw.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down