Skip to content

Commit 7ead7c7

Browse files
committed
feat(exasol): implement Table.nunique
1 parent 63c20c0 commit 7ead7c7

File tree

3 files changed

+12
-16
lines changed

3 files changed

+12
-16
lines changed

ibis/backends/sql/compilers/exasol.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,11 @@ def visit_CountStar(self, op, *, arg, where):
189189
return self.f.count(STAR)
190190

191191
def visit_CountDistinctStar(self, op, *, arg, where):
192-
raise com.UnsupportedOperationError(
193-
"COUNT(DISTINCT *) is not supported in Exasol"
194-
)
192+
cols = [sg.column(k, quoted=self.quoted) for k in op.arg.schema.keys()]
193+
if where is not None:
194+
cols = [self.if_(where, c, NULL) for c in cols]
195+
row = sge.Tuple(expressions=cols)
196+
return self.f.count(sge.Distinct(expressions=[row]))
195197

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

ibis/backends/tests/test_aggregation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from ibis import literal as L
1414
from ibis.backends.tests.errors import (
1515
ClickHouseDatabaseError,
16+
ExaQueryError,
1617
GoogleBadRequest,
1718
ImpalaHiveServer2Error,
1819
MySQLNotSupportedError,
@@ -790,7 +791,6 @@ def test_arbitrary(backend, alltypes, df, filtered):
790791
raises=com.OperationNotDefinedError,
791792
reason="no one has attempted implementation yet",
792793
)
793-
@pytest.mark.notimpl(["exasol"], raises=com.UnsupportedOperationError)
794794
def test_count_distinct_star(alltypes, df, ibis_cond, pandas_cond):
795795
table = alltypes[["int_col", "double_col", "string_col"]]
796796
expr = table.nunique(where=ibis_cond(table))

ibis/backends/tests/test_generic.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -782,10 +782,7 @@ def test_table_info_large(con):
782782
reason="quantile and mode is not supported",
783783
)
784784
@pytest.mark.notimpl(
785-
[
786-
"exasol",
787-
"druid",
788-
],
785+
["druid"],
789786
raises=com.OperationNotDefinedError,
790787
reason="Mode and StandardDev is not supported",
791788
)
@@ -829,10 +826,10 @@ def test_table_info_large(con):
829826
pytest.mark.notimpl(
830827
[
831828
"clickhouse",
829+
"exasol",
830+
"impala",
832831
"pyspark",
833-
"clickhouse",
834832
"risingwave",
835-
"impala",
836833
],
837834
raises=com.OperationNotDefinedError,
838835
reason="mode is not supported",
@@ -911,10 +908,10 @@ def test_table_info_large(con):
911908
pytest.mark.notimpl(
912909
[
913910
"clickhouse",
911+
"exasol",
912+
"impala",
914913
"pyspark",
915-
"clickhouse",
916914
"risingwave",
917-
"impala",
918915
],
919916
raises=com.OperationNotDefinedError,
920917
reason="mode is not supported",
@@ -958,10 +955,7 @@ def test_table_describe(alltypes, selector, expected_columns):
958955
reason="quantile is not supported",
959956
)
960957
@pytest.mark.notimpl(
961-
[
962-
"exasol",
963-
"druid",
964-
],
958+
["druid"],
965959
raises=com.OperationNotDefinedError,
966960
reason="StandardDev is not supported",
967961
)

0 commit comments

Comments
 (0)