|
| 1 | +import pandas as pd |
| 2 | + |
| 3 | + |
| 4 | +class TestGeometry: |
| 5 | + def test_fetchall(self, duckdb_cursor): |
| 6 | + duckdb_cursor.execute("SELECT 'POINT(1 2)'::GEOMETRY AS geom") |
| 7 | + results = duckdb_cursor.fetchall() |
| 8 | + assert isinstance(results[0][0], bytes) |
| 9 | + |
| 10 | + def test_fetchnumpy(self, duckdb_cursor): |
| 11 | + duckdb_cursor.execute("SELECT 'POINT(1 2)'::GEOMETRY AS geom") |
| 12 | + results = duckdb_cursor.fetchnumpy() |
| 13 | + assert isinstance(results["geom"][0], (bytes, bytearray)) |
| 14 | + |
| 15 | + def test_df(self, duckdb_cursor): |
| 16 | + duckdb_cursor.execute("SELECT 'POINT(1 2)'::GEOMETRY AS geom") |
| 17 | + df = duckdb_cursor.df() |
| 18 | + assert isinstance(df["geom"].iloc[0], (bytes, bytearray)) |
| 19 | + |
| 20 | + def test_null(self, duckdb_cursor): |
| 21 | + duckdb_cursor.execute("SELECT NULL::GEOMETRY AS geom") |
| 22 | + results = duckdb_cursor.fetchall() |
| 23 | + assert results[0][0] is None |
| 24 | + |
| 25 | + def test_multiple_rows(self, duckdb_cursor): |
| 26 | + duckdb_cursor.execute("SELECT 'POINT(1 2)'::GEOMETRY AS geom UNION ALL SELECT NULL::GEOMETRY") |
| 27 | + df = duckdb_cursor.df() |
| 28 | + assert df.shape[0] == 2 |
| 29 | + assert isinstance(df["geom"].iloc[0], (bytes, bytearray)) |
| 30 | + assert pd.isna(df["geom"].iloc[1]) |
0 commit comments