Skip to content

Commit 18a6c76

Browse files
committed
fix sqlgot compiler
1 parent b44d520 commit 18a6c76

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

tests/unit/core/compile/sqlglot/snapshots/test_geo_compiler/test_st_regionstats/out.sql renamed to tests/unit/core/compile/sqlglot/snapshots/test_compile_geo/test_st_regionstats/out.sql

File renamed without changes.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
WITH `bfcte_0` AS (
2+
SELECT
3+
*
4+
FROM UNNEST(ARRAY<STRUCT<`bfcol_0` STRING, `bfcol_1` INT64>>[STRUCT('POINT(1 1)', 0)])
5+
), `bfcte_1` AS (
6+
SELECT
7+
*,
8+
ST_REGIONSTATS(`bfcol_0`, 'ee://some/raster/uri') AS `bfcol_2`
9+
FROM `bfcte_0`
10+
), `bfcte_2` AS (
11+
SELECT
12+
*,
13+
`bfcol_2`.`min` AS `bfcol_5`,
14+
`bfcol_2`.`max` AS `bfcol_6`,
15+
`bfcol_2`.`sum` AS `bfcol_7`,
16+
`bfcol_2`.`count` AS `bfcol_8`,
17+
`bfcol_2`.`mean` AS `bfcol_9`,
18+
`bfcol_2`.`area` AS `bfcol_10`
19+
FROM `bfcte_1`
20+
)
21+
SELECT
22+
`bfcol_5` AS `min`,
23+
`bfcol_6` AS `max`,
24+
`bfcol_7` AS `sum`,
25+
`bfcol_8` AS `count`,
26+
`bfcol_9` AS `mean`,
27+
`bfcol_10` AS `area`
28+
FROM `bfcte_2`
29+
ORDER BY
30+
`bfcol_1` ASC NULLS LAST

tests/unit/core/compile/sqlglot/test_geo_compiler.py renamed to tests/unit/core/compile/sqlglot/test_compile_geo.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,13 @@ def test_st_regionstats(compiler_session, snapshot):
3131
)
3232
assert "area" in result.struct.dtypes.index
3333
snapshot.assert_match(result.struct.explode().sql, "out.sql")
34+
35+
36+
def test_st_regionstats_without_optional_args(compiler_session, snapshot):
37+
geos = gpd.GeoSeries(["POINT(1 1)"], session=compiler_session)
38+
result = bbq.st_regionstats(
39+
geos,
40+
"ee://some/raster/uri",
41+
)
42+
assert "area" in result.struct.dtypes.index
43+
snapshot.assert_match(result.struct.explode().sql, "out.sql")

0 commit comments

Comments
 (0)