Skip to content
This repository was archived by the owner on Nov 12, 2025. It is now read-only.

Commit 77b373b

Browse files
authored
test: fix unit tests affected by pyarrow changes (#28)
* testing: fix unit tests affected by pyarrow changes. Previously, tests attempted to set field metadata in cases where there was no metadata values to communicate. Changes in pyarrow consider this invalid as there's an expectation that metadata should be coercable to bytes. This change alters testing behavior to only propagate column description metadata when it is present.
1 parent b059924 commit 77b373b

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
extras = {
3131
"pandas": "pandas>=0.17.1",
3232
"fastavro": "fastavro>=0.21.2",
33-
"pyarrow": "pyarrow>=0.13.0, != 0.14.0",
33+
"pyarrow": "pyarrow>=0.15.0",
3434
}
3535

3636
package_root = os.path.abspath(os.path.dirname(__file__))

tests/unit/test_reader_v1.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,14 @@ def _bq_to_avro_schema(bq_columns):
233233

234234
def _bq_to_arrow_schema(bq_columns):
235235
def bq_col_as_field(column):
236-
doc = column.get("description")
236+
metadata = None
237+
if column.get("description") is not None:
238+
metadata = {"description": column.get("description")}
237239
name = column["name"]
238240
type_ = BQ_TO_ARROW_TYPES[column["type"]]
239241
mode = column.get("mode", "nullable").lower()
240242

241-
return pyarrow.field(name, type_, mode == "nullable", {"description": doc})
243+
return pyarrow.field(name, type_, mode == "nullable", metadata)
242244

243245
return pyarrow.schema(bq_col_as_field(c) for c in bq_columns)
244246

tests/unit/test_reader_v1beta1.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,14 @@ def _bq_to_avro_schema(bq_columns):
234234

235235
def _bq_to_arrow_schema(bq_columns):
236236
def bq_col_as_field(column):
237-
doc = column.get("description")
237+
metadata = None
238+
if column.get("description") is not None:
239+
metadata = {"description": column.get("description")}
238240
name = column["name"]
239241
type_ = BQ_TO_ARROW_TYPES[column["type"]]
240242
mode = column.get("mode", "nullable").lower()
241243

242-
return pyarrow.field(name, type_, mode == "nullable", {"description": doc})
244+
return pyarrow.field(name, type_, mode == "nullable", metadata)
243245

244246
return pyarrow.schema(bq_col_as_field(c) for c in bq_columns)
245247

0 commit comments

Comments
 (0)