Skip to content

Commit

Permalink
ignore type
Browse files Browse the repository at this point in the history
  • Loading branch information
EDsCODE committed Feb 11, 2025
1 parent 569cdca commit 05e5ffe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,12 @@ def row_tuples_to_arrow(rows: Sequence[RowAny], columns: TTableSchemaColumns, tz

if issubclass(py_type, bytes) or issubclass(py_type, str):
# For bytes/str columns, ensure any dict values are serialized to JSON strings
columnar_known_types[field.name] = [
# Convert to numpy array after processing
processed_values = [
None if x is None else json_dumps(x) if isinstance(x, dict | list) else x
for x in columnar_known_types[field.name]
]
columnar_known_types[field.name] = np.array(processed_values, dtype=object)

# If there are unknown type columns, first create a table to infer their types
if columnar_unknown_types:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def test_row_tuples_to_arrow_string_column_with_dict():
columns = {"string_col": {"name": "string_col", "data_type": "text", "nullable": True}}

# This should now succeed and serialize the dictionary to JSON
table = row_tuples_to_arrow(rows, columns, "UTC")
table = row_tuples_to_arrow(rows, columns, "UTC") # type: ignore

# Verify the results
assert table.column("string_col")[0].as_py() == ""
Expand Down

0 comments on commit 05e5ffe

Please sign in to comment.