Skip to content

Commit 894ce90

Browse files
committed
feat(duckdb): implement approx_median
1 parent 03c89ad commit 894ce90

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

ibis/backends/duckdb/registry.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,11 @@ def _regex_extract(t, expr):
167167
ops.RegexExtract: _regex_extract,
168168
ops.RegexReplace: fixed_arity(sa.func.regexp_replace, 3),
169169
ops.StringContains: fixed_arity(sa.func.contains, 2),
170+
ops.CMSMedian: reduction(
171+
# without inline text, duckdb fails with
172+
# RuntimeError: INTERNAL Error: Invalid PhysicalType for GetTypeIdSize # noqa: E501
173+
lambda arg: sa.func.approx_quantile(arg, sa.text(str(0.5)))
174+
),
170175
ops.HLLCardinality: reduction(sa.func.approx_count_distinct),
171176
}
172177
)

ibis/backends/tests/test_client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ def test_verify(ddl_backend, ddl_con):
337337
assert ddl_backend.api.verify(expr)
338338

339339

340+
@pytest.mark.never(["duckdb"], reason="duckdb supports approximate median")
340341
def test_not_verify(alchemy_con, alchemy_backend):
341342
# There is no expression that can't be compiled to any backend
342343
# Testing `not verify()` only for an expression not supported in postgres

0 commit comments

Comments
 (0)