Skip to content

Commit

Permalink
feat(exasol): implement median and approx_median
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrist committed Aug 16, 2024
1 parent ecbef94 commit 3cfc344
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions ibis/backends/sql/compilers/exasol.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class ExasolCompiler(SQLGlotCompiler):

UNSUPPORTED_OPS = (
ops.AnalyticVectorizedUDF,
ops.ApproxMedian,
ops.ArgMax,
ops.ArgMin,
ops.ArrayDistinct,
Expand All @@ -56,7 +55,6 @@ class ExasolCompiler(SQLGlotCompiler):
ops.IsInf,
ops.IsNan,
ops.Levenshtein,
ops.Median,
ops.MultiQuantile,
ops.RandomUUID,
ops.ReductionVectorizedUDF,
Expand Down Expand Up @@ -187,6 +185,11 @@ def visit_CountDistinctStar(self, op, *, arg, where):
"COUNT(DISTINCT *) is not supported in Exasol"
)

def visit_Median(self, op, *, arg, where):
return self.visit_Quantile(op, arg=arg, quantile=sge.convert(0.5), where=where)

visit_ApproxMedian = visit_Median

def visit_Quantile(self, op, *, arg, quantile, where):
suffix = "cont" if op.arg.dtype.is_numeric() else "disc"
funcname = f"percentile_{suffix}"
Expand Down
4 changes: 2 additions & 2 deletions ibis/backends/tests/test_aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1175,7 +1175,7 @@ def test_corr_cov(


@pytest.mark.notimpl(
["mysql", "sqlite", "mssql", "druid", "exasol"],
["mysql", "sqlite", "mssql", "druid"],
raises=com.OperationNotDefinedError,
)
@pytest.mark.notyet(["flink"], raises=com.OperationNotDefinedError)
Expand All @@ -1186,7 +1186,7 @@ def test_approx_median(alltypes):


@pytest.mark.notimpl(
["bigquery", "druid", "sqlite", "exasol"], raises=com.OperationNotDefinedError
["bigquery", "druid", "sqlite"], raises=com.OperationNotDefinedError
)
@pytest.mark.notyet(
["impala", "mysql", "mssql", "druid", "trino"],
Expand Down

0 comments on commit 3cfc344

Please sign in to comment.