Skip to content

Commit

Permalink
feat(duckdb): implement approx_median
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed May 23, 2022
1 parent 03c89ad commit 894ce90
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ibis/backends/duckdb/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ def _regex_extract(t, expr):
ops.RegexExtract: _regex_extract,
ops.RegexReplace: fixed_arity(sa.func.regexp_replace, 3),
ops.StringContains: fixed_arity(sa.func.contains, 2),
ops.CMSMedian: reduction(
# without inline text, duckdb fails with
# RuntimeError: INTERNAL Error: Invalid PhysicalType for GetTypeIdSize # noqa: E501
lambda arg: sa.func.approx_quantile(arg, sa.text(str(0.5)))
),
ops.HLLCardinality: reduction(sa.func.approx_count_distinct),
}
)
Expand Down
1 change: 1 addition & 0 deletions ibis/backends/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ def test_verify(ddl_backend, ddl_con):
assert ddl_backend.api.verify(expr)


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

0 comments on commit 894ce90

Please sign in to comment.