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

Correct aggregators violating names #16615

Merged
merged 4 commits into from
Jul 12, 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 @@ -32,7 +32,6 @@
import org.apache.calcite.sql.type.SqlTypeFamily;
import org.apache.calcite.sql.type.SqlTypeName;
import org.apache.calcite.util.Optionality;
import org.apache.druid.java.util.common.StringUtils;
import org.apache.druid.query.aggregation.AggregatorFactory;
import org.apache.druid.segment.column.ColumnType;
import org.apache.druid.sql.calcite.aggregation.Aggregation;
Expand Down Expand Up @@ -130,7 +129,7 @@ public Aggregation toDruidAggregation(

// create the factory
AggregatorFactory aggregatorFactory = factoryCreator.create(
StringUtils.format("%s:agg", name),
name,
sumColumnName,
size,
scale,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ protected void testCompressedBigDecimalAggWithNumberParseHelper(
.intervals(new MultipleIntervalSegmentSpec(ImmutableList.of(Filtration.eternity())))
.granularity(Granularities.ALL)
.aggregators(
factoryCreator.create("a0:agg", "m1", 9, 9, false),
factoryCreator.create("a1:agg", "m2", 9, 9, false),
factoryCreator.create("a2:agg", "dim1", 9, 9, false)
factoryCreator.create("a0", "m1", 9, 9, false),
factoryCreator.create("a1", "m2", 9, 9, false),
factoryCreator.create("a2", "dim1", 9, 9, false)

)
.context(QUERY_CONTEXT_DEFAULT)
Expand All @@ -190,7 +190,7 @@ protected void testCompressedBigDecimalAggWithStrictNumberParseHelper(
.dataSource(CalciteTests.DATASOURCE1)
.intervals(new MultipleIntervalSegmentSpec(ImmutableList.of(Filtration.eternity())))
.granularity(Granularities.ALL)
.aggregators(factoryCreator.create("a0:agg", "dim1", 9, 9, true))
.aggregators(factoryCreator.create("a0", "dim1", 9, 9, true))
.context(QUERY_CONTEXT_DEFAULT)
.build()
),
Expand Down Expand Up @@ -218,9 +218,9 @@ public void testCompressedBigDecimalAggDefaultNumberParseAndCustomSizeAndScaleHe
.intervals(new MultipleIntervalSegmentSpec(ImmutableList.of(Filtration.eternity())))
.granularity(Granularities.ALL)
.aggregators(
factoryCreator.create("a0:agg", "m1", 9, 3, false),
factoryCreator.create("a1:agg", "m2", 9, 3, false),
factoryCreator.create("a2:agg", "dim1", 9, 3, false)
factoryCreator.create("a0", "m1", 9, 3, false),
factoryCreator.create("a1", "m2", 9, 3, false),
factoryCreator.create("a2", "dim1", 9, 3, false)
)
.context(QUERY_CONTEXT_DEFAULT)
.build()
Expand Down Expand Up @@ -249,9 +249,9 @@ public void testCompressedBigDecimalAggDefaultScaleHelper(
.intervals(new MultipleIntervalSegmentSpec(ImmutableList.of(Filtration.eternity())))
.granularity(Granularities.ALL)
.aggregators(
factoryCreator.create("a0:agg", "m1", 9, 9, false),
factoryCreator.create("a1:agg", "m2", 9, 9, false),
factoryCreator.create("a2:agg", "dim1", 9, 9, false)
factoryCreator.create("a0", "m1", 9, 9, false),
factoryCreator.create("a1", "m2", 9, 9, false),
factoryCreator.create("a2", "dim1", 9, 9, false)
)
.context(QUERY_CONTEXT_DEFAULT)
.build()
Expand All @@ -275,9 +275,9 @@ public void testCompressedBigDecimalAggDefaultSizeAndScaleHelper(
.intervals(new MultipleIntervalSegmentSpec(ImmutableList.of(Filtration.eternity())))
.granularity(Granularities.ALL)
.aggregators(
factoryCreator.create("a0:agg", "m1", 6, 9, false),
factoryCreator.create("a1:agg", "m2", 6, 9, false),
factoryCreator.create("a2:agg", "dim1", 6, 9, false)
factoryCreator.create("a0", "m1", 6, 9, false),
factoryCreator.create("a1", "m2", 6, 9, false),
factoryCreator.create("a2", "dim1", 6, 9, false)
)
.context(QUERY_CONTEXT_DEFAULT)
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.apache.calcite.sql.SqlKind;
import org.apache.calcite.sql.type.SqlTypeFamily;
import org.apache.calcite.util.Optionality;
import org.apache.druid.java.util.common.StringUtils;
import org.apache.druid.query.aggregation.AggregatorFactory;
import org.apache.druid.query.aggregation.tdigestsketch.TDigestSketchAggregatorFactory;
import org.apache.druid.query.aggregation.tdigestsketch.TDigestSketchUtils;
Expand Down Expand Up @@ -79,7 +78,6 @@ public Aggregation toDruidAggregation(
}

final AggregatorFactory aggregatorFactory;
final String aggName = StringUtils.format("%s:agg", name);

Integer compression = TDigestSketchAggregatorFactory.DEFAULT_COMPRESSION;
if (aggregateCall.getArgList().size() > 1) {
Expand Down Expand Up @@ -116,7 +114,7 @@ public Aggregation toDruidAggregation(
// No existing match found. Create a new one.
if (input.isDirectColumnAccess()) {
aggregatorFactory = new TDigestSketchAggregatorFactory(
aggName,
name,
input.getDirectColumn(),
compression
);
Expand All @@ -125,7 +123,7 @@ public Aggregation toDruidAggregation(
input,
ColumnType.FLOAT
);
aggregatorFactory = new TDigestSketchAggregatorFactory(aggName, virtualColumnName, compression);
aggregatorFactory = new TDigestSketchAggregatorFactory(name, virtualColumnName, compression);
}

return Aggregation.create(aggregatorFactory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public void testComputingSketchOnNumericValues()
.intervals(new MultipleIntervalSegmentSpec(ImmutableList.of(Filtration.eternity())))
.granularity(Granularities.ALL)
.aggregators(ImmutableList.of(
new TDigestSketchAggregatorFactory("a0:agg", "m1", 200)
new TDigestSketchAggregatorFactory("a0", "m1", 200)
))
.context(QUERY_CONTEXT_DEFAULT)
.build()
Expand Down Expand Up @@ -205,7 +205,7 @@ public void testComputingSketchOnNumericValuesWithCastedCompressionParameter()
.intervals(new MultipleIntervalSegmentSpec(ImmutableList.of(Filtration.eternity())))
.granularity(Granularities.ALL)
.aggregators(ImmutableList.of(
new TDigestSketchAggregatorFactory("a0:agg", "m1", 200)
new TDigestSketchAggregatorFactory("a0", "m1", 200)
))
.context(QUERY_CONTEXT_DEFAULT)
.build()
Expand Down Expand Up @@ -242,7 +242,7 @@ public void testComputingSketchOnCastedString()
)
)
.aggregators(ImmutableList.of(
new TDigestSketchAggregatorFactory("a0:agg", "v0", 200)
new TDigestSketchAggregatorFactory("a0", "v0", 200)
))
.context(QUERY_CONTEXT_DEFAULT)
.build()
Expand Down Expand Up @@ -275,7 +275,7 @@ public void testDefaultCompressionForTDigestGenerateSketchAgg()
.intervals(new MultipleIntervalSegmentSpec(ImmutableList.of(Filtration.eternity())))
.granularity(Granularities.ALL)
.aggregators(ImmutableList.of(
new TDigestSketchAggregatorFactory("a0:agg", "m1", TDigestSketchAggregatorFactory.DEFAULT_COMPRESSION)
new TDigestSketchAggregatorFactory("a0", "m1", TDigestSketchAggregatorFactory.DEFAULT_COMPRESSION)
))
.context(QUERY_CONTEXT_DEFAULT)
.build()
Expand Down Expand Up @@ -357,7 +357,7 @@ public void testGeneratingSketchAndComputingQuantileOnFly()
.setDimensions(new DefaultDimensionSpec("dim1", "d0"))
.setAggregatorSpecs(
ImmutableList.of(
new TDigestSketchAggregatorFactory("a0:agg", "m1", 200)
new TDigestSketchAggregatorFactory("a0", "m1", 200)
)
)
.setContext(QUERY_CONTEXT_DEFAULT)
Expand All @@ -368,7 +368,7 @@ public void testGeneratingSketchAndComputingQuantileOnFly()
.setGranularity(Granularities.ALL)
.setAggregatorSpecs(
ImmutableList.of(
new TDigestSketchAggregatorFactory("_a0:agg", "a0:agg", 100)
new TDigestSketchAggregatorFactory("_a0:agg", "a0", 100)
)
)
.setPostAggregatorSpecs(
Expand Down Expand Up @@ -534,7 +534,7 @@ public void testEmptyTimeseriesResults()
.filters(numericEquality("dim2", 0L, ColumnType.LONG))
.granularity(Granularities.ALL)
.aggregators(ImmutableList.of(
new TDigestSketchAggregatorFactory("a0:agg", "m1", TDigestSketchAggregatorFactory.DEFAULT_COMPRESSION),
new TDigestSketchAggregatorFactory("a0", "m1", TDigestSketchAggregatorFactory.DEFAULT_COMPRESSION),
new TDigestSketchAggregatorFactory("a1:agg", "qsketch_m1", 100)
))
.postAggregators(
Expand Down Expand Up @@ -571,7 +571,7 @@ public void testGroupByAggregatorDefaultValues()
.setAggregatorSpecs(
aggregators(
new FilteredAggregatorFactory(
new TDigestSketchAggregatorFactory("a0:agg", "m1", TDigestSketchAggregatorFactory.DEFAULT_COMPRESSION),
new TDigestSketchAggregatorFactory("a0", "m1", TDigestSketchAggregatorFactory.DEFAULT_COMPRESSION),
equality("dim1", "nonexistent", ColumnType.STRING)
),
new FilteredAggregatorFactory(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.apache.calcite.sql.SqlFunctionCategory;
import org.apache.calcite.sql.SqlKind;
import org.apache.calcite.sql.type.SqlTypeFamily;
import org.apache.druid.java.util.common.StringUtils;
import org.apache.druid.query.aggregation.AggregatorFactory;
import org.apache.druid.query.aggregation.datasketches.SketchQueryContext;
import org.apache.druid.query.aggregation.datasketches.quantiles.DoublesSketchAggregatorFactory;
Expand Down Expand Up @@ -89,7 +88,6 @@ public Aggregation toDruidAggregation(
}

final AggregatorFactory aggregatorFactory;
final String histogramName = StringUtils.format("%s:agg", name);
final int k;

if (aggregateCall.getArgList().size() >= 2) {
Expand All @@ -108,7 +106,7 @@ public Aggregation toDruidAggregation(
// No existing match found. Create a new one.
if (input.isDirectColumnAccess()) {
aggregatorFactory = new DoublesSketchAggregatorFactory(
histogramName,
name,
input.getDirectColumn(),
k,
DoublesSketchApproxQuantileSqlAggregator.getMaxStreamLengthFromQueryContext(plannerContext.queryContext()),
Expand All @@ -120,7 +118,7 @@ public Aggregation toDruidAggregation(
ColumnType.FLOAT
);
aggregatorFactory = new DoublesSketchAggregatorFactory(
histogramName,
name,
virtualColumnName,
k,
DoublesSketchApproxQuantileSqlAggregator.getMaxStreamLengthFromQueryContext(plannerContext.queryContext()),
Expand Down
Loading
Loading