Skip to content

Commit

Permalink
feat(exasol): implement cov/corr
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrist committed Aug 19, 2024
1 parent 2c84722 commit 5637d8f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
15 changes: 14 additions & 1 deletion ibis/backends/sql/compilers/exasol.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class ExasolCompiler(SQLGlotCompiler):
ops.ArrayUnion,
ops.ArrayZip,
ops.BitwiseNot,
ops.Covariance,
ops.CumeDist,
ops.DateAdd,
ops.DateSub,
Expand Down Expand Up @@ -120,6 +119,20 @@ def visit_NonNullLiteral(self, op, *, value, dtype):
def visit_Date(self, op, *, arg):
return self.cast(arg, dt.date)

def visit_Correlation(self, op, *, left, right, how, where):
if how == "sample":
raise com.UnsupportedOperationError(
"Exasol only implements `pop` correlation coefficient"
)

if (left_type := op.left.dtype).is_boolean():
left = self.cast(left, dt.Int32(nullable=left_type.nullable))

if (right_type := op.right.dtype).is_boolean():
right = self.cast(right, dt.Int32(nullable=right_type.nullable))

return self.agg.corr(left, right, where=where)

def visit_GroupConcat(self, op, *, arg, sep, where, order_by):
if where is not None:
arg = self.if_(where, arg, NULL)
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 @@ -1013,7 +1013,7 @@ def test_quantile(
raises=com.OperationNotDefinedError,
),
pytest.mark.notyet(
["postgres", "duckdb", "snowflake", "risingwave"],
["postgres", "duckdb", "snowflake", "risingwave", "exasol"],
raises=com.UnsupportedOperationError,
reason="backend only implements population correlation coefficient",
),
Expand Down Expand Up @@ -1114,7 +1114,7 @@ def test_quantile(
),
],
)
@pytest.mark.notimpl(["mssql", "exasol"], raises=com.OperationNotDefinedError)
@pytest.mark.notimpl(["mssql"], raises=com.OperationNotDefinedError)
def test_corr_cov(
con,
batting,
Expand Down

0 comments on commit 5637d8f

Please sign in to comment.