Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable pushdown of a few aggregation functions for ClickHouse Connector #21840

Merged
merged 1 commit into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,12 @@
import io.trino.plugin.jdbc.SliceWriteFunction;
import io.trino.plugin.jdbc.WriteMapping;
import io.trino.plugin.jdbc.aggregation.ImplementAvgFloatingPoint;
import io.trino.plugin.jdbc.aggregation.ImplementCorr;
import io.trino.plugin.jdbc.aggregation.ImplementCount;
import io.trino.plugin.jdbc.aggregation.ImplementCountAll;
import io.trino.plugin.jdbc.aggregation.ImplementCountDistinct;
import io.trino.plugin.jdbc.aggregation.ImplementCovariancePop;
import io.trino.plugin.jdbc.aggregation.ImplementCovarianceSamp;
import io.trino.plugin.jdbc.aggregation.ImplementMinMax;
import io.trino.plugin.jdbc.aggregation.ImplementSum;
import io.trino.plugin.jdbc.expression.JdbcConnectorExpressionRewriterBuilder;
Expand Down Expand Up @@ -242,10 +246,14 @@ public ClickHouseClient(
ImmutableSet.<AggregateFunctionRule<JdbcExpression, ParameterizedExpression>>builder()
.add(new ImplementCountAll(bigintTypeHandle))
.add(new ImplementCount(bigintTypeHandle))
.add(new ImplementCountDistinct(bigintTypeHandle, false))
.add(new ImplementMinMax(false)) // TODO: Revisit once https://github.com/trinodb/trino/issues/7100 is resolved
.add(new ImplementSum(ClickHouseClient::toTypeHandle))
.add(new ImplementAvgFloatingPoint())
.add(new ImplementAvgBigint())
.add(new ImplementCorr())
.add(new ImplementCovarianceSamp())
.add(new ImplementCovariancePop())
.build());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ public class TestClickHouseConnectorTest
protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior)
{
return switch (connectorBehavior) {
case SUPPORTS_PREDICATE_PUSHDOWN_WITH_VARCHAR_EQUALITY,
SUPPORTS_TRUNCATE -> true;
case SUPPORTS_AGGREGATION_PUSHDOWN_CORRELATION,
case SUPPORTS_AGGREGATION_PUSHDOWN_COVARIANCE,
SUPPORTS_AGGREGATION_PUSHDOWN_COUNT_DISTINCT,
SUPPORTS_AGGREGATION_PUSHDOWN_COVARIANCE,
SUPPORTS_AGGREGATION_PUSHDOWN_REGRESSION,
SUPPORTS_AGGREGATION_PUSHDOWN_CORRELATION,
SUPPORTS_PREDICATE_PUSHDOWN_WITH_VARCHAR_EQUALITY,
SUPPORTS_TRUNCATE -> true;
case SUPPORTS_AGGREGATION_PUSHDOWN_REGRESSION,
SUPPORTS_AGGREGATION_PUSHDOWN_STDDEV,
SUPPORTS_AGGREGATION_PUSHDOWN_VARIANCE,
SUPPORTS_ARRAY,
Expand Down