Skip to content

feat: support uploading local geo data #1036

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Oct 18, 2024
6 changes: 2 additions & 4 deletions bigframes/session/__init__.py
Original file line number Diff line number Diff line change
@@ -707,10 +707,8 @@ def _read_pandas_inline(
try:
local_block = blocks.Block.from_local(pandas_dataframe, self)
inline_df = dataframe.DataFrame(local_block)
except pa.ArrowInvalid as e:
raise pa.ArrowInvalid(
f"Could not convert with a BigQuery type: `{e}`. "
) from e
except pa.ArrowInvalid: # Thrown by arrow for unsupported types, such as geo.
return None
except ValueError: # Thrown by ibis for some unhandled types
return None
except pa.ArrowTypeError: # Thrown by arrow for types without mapping (geo).
14 changes: 14 additions & 0 deletions tests/system/small/test_series.py
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@
import pandas as pd
import pyarrow as pa # type: ignore
import pytest
import shapely # type: ignore

import bigframes.pandas
import bigframes.series as series
@@ -213,6 +214,19 @@ def test_series_construct_from_list_escaped_strings():
pd.testing.assert_series_equal(bf_result.to_pandas(), pd_result)


def test_series_construct_geodata():
pd_series = pd.Series(
[shapely.Point(1, 1), shapely.Point(2, 2), shapely.Point(3, 3)],
dtype=gpd.array.GeometryDtype(),
)

series = bigframes.pandas.Series(pd_series)

pd.testing.assert_series_equal(
pd_series, series.to_pandas(), check_index_type=False
)


@pytest.mark.parametrize(
["col_name", "expected_dtype"],
[