Skip to content

Commit f3f733f

Browse files
committed
enable engine tests
1 parent bc0edac commit f3f733f

File tree

3 files changed

+47
-15
lines changed

3 files changed

+47
-15
lines changed

tests/system/small/engines/test_aggregation.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,23 @@ def test_engines_unary_aggregates(
8585
assert_equivalence_execution(node, REFERENCE_ENGINE, engine)
8686

8787

88-
@pytest.mark.parametrize(
89-
"op",
90-
[agg_ops.MedianOp],
91-
)
92-
def test_sql_engines_unary_aggregates(
88+
def test_sql_engines_median_op_aggregates(
9389
scalars_array_value: array_value.ArrayValue,
9490
bigquery_client: bigquery.Client,
95-
op,
9691
):
97-
# TODO: this is not working??
98-
node = apply_agg_to_all_valid(scalars_array_value, op).node
92+
node = apply_agg_to_all_valid(
93+
scalars_array_value,
94+
agg_ops.MedianOp(),
95+
# Exclude columns are not supported by Ibis.
96+
excluded_cols=[
97+
"bytes_col",
98+
"date_col",
99+
"datetime_col",
100+
"time_col",
101+
"timestamp_col",
102+
"string_col",
103+
],
104+
).node
99105
left_engine = direct_gbq_execution.DirectGbqExecutor(bigquery_client)
100106
right_engine = direct_gbq_execution.DirectGbqExecutor(
101107
bigquery_client, compiler="sqlglot"
Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,30 @@
11
WITH `bfcte_0` AS (
22
SELECT
3-
`int64_col` AS `bfcol_0`
3+
`bytes_col` AS `bfcol_0`,
4+
`date_col` AS `bfcol_1`,
5+
`datetime_col` AS `bfcol_2`,
6+
`int64_col` AS `bfcol_3`,
7+
`string_col` AS `bfcol_4`,
8+
`time_col` AS `bfcol_5`,
9+
`timestamp_col` AS `bfcol_6`
410
FROM `bigframes-dev`.`sqlglot_test`.`scalar_types`
511
), `bfcte_1` AS (
612
SELECT
7-
APPROX_QUANTILES(`bfcol_0`, 2)[OFFSET(1)] AS `bfcol_1`
13+
APPROX_QUANTILES(`bfcol_3`, 2)[OFFSET(1)] AS `bfcol_7`,
14+
APPROX_QUANTILES(`bfcol_0`, 2)[OFFSET(1)] AS `bfcol_8`,
15+
APPROX_QUANTILES(`bfcol_1`, 2)[OFFSET(1)] AS `bfcol_9`,
16+
APPROX_QUANTILES(`bfcol_2`, 2)[OFFSET(1)] AS `bfcol_10`,
17+
APPROX_QUANTILES(`bfcol_5`, 2)[OFFSET(1)] AS `bfcol_11`,
18+
APPROX_QUANTILES(`bfcol_6`, 2)[OFFSET(1)] AS `bfcol_12`,
19+
APPROX_QUANTILES(`bfcol_4`, 2)[OFFSET(1)] AS `bfcol_13`
820
FROM `bfcte_0`
921
)
1022
SELECT
11-
`bfcol_1` AS `int64_col`
23+
`bfcol_7` AS `int64_col`,
24+
`bfcol_8` AS `bytes_col`,
25+
`bfcol_9` AS `date_col`,
26+
`bfcol_10` AS `datetime_col`,
27+
`bfcol_11` AS `time_col`,
28+
`bfcol_12` AS `timestamp_col`,
29+
`bfcol_13` AS `string_col`
1230
FROM `bfcte_1`

tests/unit/core/compile/sqlglot/aggregations/test_unary_compiler.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,18 @@ def test_max(scalar_types_df: bpd.DataFrame, snapshot):
5757

5858

5959
def test_median(scalar_types_df: bpd.DataFrame, snapshot):
60-
col_name = "int64_col"
61-
bf_df = scalar_types_df[[col_name]]
62-
agg_expr = agg_ops.MedianOp().as_expr(col_name)
63-
sql = _apply_unary_agg_ops(bf_df, [agg_expr], [col_name])
60+
bf_df = scalar_types_df
61+
ops_map = {
62+
"int64_col": agg_ops.MedianOp().as_expr("int64_col"),
63+
# Includes columns are not supported by Ibis but supported by BigQuery.
64+
"bytes_col": agg_ops.MedianOp().as_expr("bytes_col"),
65+
"date_col": agg_ops.MedianOp().as_expr("date_col"),
66+
"datetime_col": agg_ops.MedianOp().as_expr("datetime_col"),
67+
"time_col": agg_ops.MedianOp().as_expr("time_col"),
68+
"timestamp_col": agg_ops.MedianOp().as_expr("timestamp_col"),
69+
"string_col": agg_ops.MedianOp().as_expr("string_col"),
70+
}
71+
sql = _apply_unary_agg_ops(bf_df, list(ops_map.values()), list(ops_map.keys()))
6472

6573
snapshot.assert_match(sql, "out.sql")
6674

0 commit comments

Comments
 (0)