Skip to content

Commit

Permalink
chore: comment out geoalchemy stuff and make the tests functional
Browse files Browse the repository at this point in the history
  • Loading branch information
kszucs committed Dec 21, 2023
1 parent 72186df commit 73fc14f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 29 deletions.
12 changes: 6 additions & 6 deletions ibis/backends/base/sqlglot/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1112,12 +1112,12 @@ def visit_FillNa(self, op, *, parent, replacements):
]
return sg.select(*exprs).from_(parent)

@visit_node.register(ops.View)
def visit_View(self, op, *, child, name: str):
# TODO: find a way to do this without creating a temporary view
backend = op.child.to_expr()._find_backend()
backend._create_temp_view(table_name=name, source=sg.select(STAR).from_(child))
return sg.table(name, quoted=self.quoted)
# @visit_node.register(ops.View)
# def visit_View(self, op, *, child, name: str):
# # TODO: find a way to do this without creating a temporary view
# backend = op.child.to_expr()._find_backend()
# backend._create_temp_view(table_name=name, source=sg.select(STAR).from_(child))
# return sg.table(name, quoted=self.quoted)

@visit_node.register(ops.SQLStringView)
def visit_SQLStringView(self, op, *, query: str, name: str, child):
Expand Down
2 changes: 1 addition & 1 deletion ibis/backends/base/sqlglot/rewrites.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Select(ops.Relation):
sort_keys: VarTuple[ops.SortKey] = ()

@attribute
def fields(self):
def values(self):
return self.selections

@attribute
Expand Down
8 changes: 4 additions & 4 deletions ibis/backends/duckdb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import ibis.expr.types as ir
from ibis import util
from ibis.backends.base import CanCreateSchema
from ibis.backends.base.sql.alchemy.geospatial import geospatial_supported
# from ibis.backends.base.sql.alchemy.geospatial import geospatial_supported
from ibis.backends.base.sqlglot import SQLGlotBackend
from ibis.backends.base.sqlglot.compiler import STAR, C, F
from ibis.backends.base.sqlglot.datatypes import DuckDBType
Expand Down Expand Up @@ -722,7 +722,7 @@ def read_geo(
if source.startswith(("http://", "https://", "s3://")):
self._load_extensions(["httpfs"])

source_expr = sg.select(STAR).from_(
source_expr = sg.select(STAR).from_(
self.compiler.f.st_read(
source,
*(sg.to_identifier(key).eq(val) for key, val in kwargs.items()),
Expand Down Expand Up @@ -1385,8 +1385,8 @@ def fetch_from_cursor(
}
)
df = DuckDBPandasData.convert_table(df, schema)
if not df.empty and geospatial_supported:
return self._to_geodataframe(df, schema)
# if not df.empty and geospatial_supported:
# return self._to_geodataframe(df, schema)
return df

# TODO(gforsyth): this may not need to be specialized in the future
Expand Down
36 changes: 18 additions & 18 deletions ibis/backends/duckdb/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def preload(self):

@property
def ddl_script(self) -> Iterator[str]:
from ibis.backends.base.sql.alchemy.geospatial import geospatial_supported
# from ibis.backends.base.sql.alchemy.geospatial import geospatial_supported

parquet_dir = self.data_dir / "parquet"
geojson_dir = self.data_dir / "geojson"
Expand All @@ -60,23 +60,23 @@ def ddl_script(self) -> Iterator[str]:
SELECT * FROM read_parquet('{parquet_dir / f'{table}.parquet'}')
"""
)
if geospatial_supported and not SANDBOXED:
for table in TEST_TABLES_GEO:
yield (
f"""
CREATE OR REPLACE TABLE {table} AS
SELECT * FROM st_read('{geojson_dir / f'{table}.geojson'}')
"""
)
yield (
"""
CREATE or REPLACE TABLE geo (name VARCHAR, geom GEOMETRY);
INSERT INTO geo VALUES
('Point', ST_GeomFromText('POINT(-100 40)')),
('Linestring', ST_GeomFromText('LINESTRING(0 0, 1 1, 2 1, 2 2)')),
('Polygon', ST_GeomFromText('POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))'));
"""
)
# if geospatial_supported and not SANDBOXED:
# for table in TEST_TABLES_GEO:
# yield (
# f"""
# CREATE OR REPLACE TABLE {table} AS
# SELECT * FROM st_read('{geojson_dir / f'{table}.geojson'}')
# """
# )
# yield (
# """
# CREATE or REPLACE TABLE geo (name VARCHAR, geom GEOMETRY);
# INSERT INTO geo VALUES
# ('Point', ST_GeomFromText('POINT(-100 40)')),
# ('Linestring', ST_GeomFromText('LINESTRING(0 0, 1 1, 2 1, 2 2)')),
# ('Polygon', ST_GeomFromText('POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))'));
# """
# )
yield from super().ddl_script

@staticmethod
Expand Down

0 comments on commit 73fc14f

Please sign in to comment.