File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed
airflow/providers/google/cloud/transfers
tests/providers/google/cloud/transfers Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change 20
20
import json
21
21
import warnings
22
22
from tempfile import NamedTemporaryFile
23
- from typing import Optional , Sequence , Union
23
+ from typing import Dict , Optional , Sequence , Union
24
24
25
25
import pyarrow as pa
26
26
import pyarrow .parquet as pq
@@ -278,7 +278,8 @@ def _convert_parquet_schema(self, cursor):
278
278
}
279
279
280
280
columns = [field [0 ] for field in cursor .description ]
281
- bq_types = [self .field_to_bigquery (field ) for field in cursor .description ]
281
+ bq_fields = [self .field_to_bigquery (field ) for field in cursor .description ]
282
+ bq_types = [bq_field .get ('type' ) if bq_field is not None else None for bq_field in bq_fields ]
282
283
pq_types = [type_map .get (bq_type , pa .string ()) for bq_type in bq_types ]
283
284
parquet_schema = pa .schema (zip (columns , pq_types ))
284
285
return parquet_schema
@@ -288,7 +289,7 @@ def query(self):
288
289
"""Execute DBAPI query."""
289
290
290
291
@abc .abstractmethod
291
- def field_to_bigquery (self , field ):
292
+ def field_to_bigquery (self , field ) -> Dict [ str , str ] :
292
293
"""Convert a DBAPI field to BigQuery schema format."""
293
294
294
295
@abc .abstractmethod
Original file line number Diff line number Diff line change 17
17
18
18
import json
19
19
import unittest
20
+ from typing import Dict
20
21
from unittest import mock
21
22
from unittest .mock import MagicMock , Mock
22
23
62
63
63
64
64
65
class DummySQLToGCSOperator (BaseSQLToGCSOperator ):
65
- def field_to_bigquery (self , field ):
66
- pass
66
+ def field_to_bigquery (self , field ) -> Dict [str , str ]:
67
+ return {
68
+ 'name' : field [0 ],
69
+ 'type' : 'STRING' ,
70
+ 'mode' : 'NULLABLE' ,
71
+ }
67
72
68
73
def convert_type (self , value , schema_type ):
69
74
return 'convert_type_return_value'
You can’t perform that action at this time.
0 commit comments