Skip to content
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 @@ -35,7 +35,6 @@
import org.apache.druid.query.aggregation.datasketches.theta.SketchMergeAggregatorFactory;
import org.apache.druid.query.expression.TestExprMacroTable;
import org.apache.druid.segment.AutoTypeColumnSchema;
import org.apache.druid.segment.VirtualColumns;
import org.apache.druid.segment.generator.GeneratorBasicSchemas;
import org.apache.druid.segment.generator.GeneratorSchemaInfo;
import org.apache.druid.segment.transform.ExpressionTransform;
Expand Down Expand Up @@ -162,34 +161,47 @@ public class SqlBenchmarkDatasets
makeDimensionsSpec(expressionsSchema),
expressionsSchema.getAggsArray(),
Arrays.asList(
new AggregateProjectionSpec(
"string2_hourly_sums_hll",
VirtualColumns.create(
Granularities.toVirtualColumn(Granularities.HOUR, "__gran")
),
Arrays.asList(
new StringDimensionSchema("string2"),
new LongDimensionSchema("__gran")
),
new AggregatorFactory[]{
new LongSumAggregatorFactory("long4_sum", "long4"),
new DoubleSumAggregatorFactory("double2_sum", "double2"),
new HllSketchBuildAggregatorFactory("hll_string5", "string5", null, null, null, false, true)
}
),
new AggregateProjectionSpec(
"string2_long2_sums",
VirtualColumns.EMPTY,
Arrays.asList(
new StringDimensionSchema("string2"),
new LongDimensionSchema("long2")
),
new AggregatorFactory[]{
new LongSumAggregatorFactory("long4_sum", "long4"),
new DoubleSumAggregatorFactory("double2_sum", "double2"),
new HllSketchBuildAggregatorFactory("hll_string5", "string5", null, null, null, false, true)
}
)
AggregateProjectionSpec.builder("string2_hourly_sums_hll")
.virtualColumns(
Granularities.toVirtualColumn(Granularities.HOUR, "__gran")
)
.groupingColumns(
new StringDimensionSchema("string2"),
new LongDimensionSchema("__gran")
)
.aggregators(
new LongSumAggregatorFactory("long4_sum", "long4"),
new DoubleSumAggregatorFactory("double2_sum", "double2"),
new HllSketchBuildAggregatorFactory(
"hll_string5",
"string5",
null,
null,
null,
false,
true
)
)
.build(),
AggregateProjectionSpec.builder("string2_long2_sums")
.groupingColumns(
new StringDimensionSchema("string2"),
new LongDimensionSchema("long2")
)
.aggregators(
new LongSumAggregatorFactory("long4_sum", "long4"),
new DoubleSumAggregatorFactory("double2_sum", "double2"),
new HllSketchBuildAggregatorFactory(
"hll_string5",
"string5",
null,
null,
null,
false,
true
)
)
.build()
),
Granularities.NONE
)
Expand Down Expand Up @@ -407,15 +419,17 @@ public BenchmarkSchema asAutoDimensions()
),
aggregators,
projections.stream()
.map(projection -> new AggregateProjectionSpec(
projection.getName(),
projection.getVirtualColumns(),
projection.getGroupingColumns()
.stream()
.map(dim -> new AutoTypeColumnSchema(dim.getName(), null))
.collect(Collectors.toList()),
projection.getAggregators()
)).collect(Collectors.toList()),
.map(
projection ->
AggregateProjectionSpec.builder(projection)
.groupingColumns(
projection.getGroupingColumns()
.stream()
.map(dim -> new AutoTypeColumnSchema(dim.getName(), null))
.collect(Collectors.toList())
)
.build()
).collect(Collectors.toList()),
queryGranularity
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
import org.apache.druid.java.util.common.io.Closer;
import org.apache.druid.query.DruidProcessingConfig;
import org.apache.druid.query.QueryContexts;
import org.apache.druid.query.aggregation.AggregatorFactory;
import org.apache.druid.query.aggregation.datasketches.hll.HllSketchBuildAggregatorFactory;
import org.apache.druid.query.aggregation.datasketches.hll.HllSketchHolder;
import org.apache.druid.query.aggregation.datasketches.hll.HllSketchModule;
Expand Down Expand Up @@ -98,36 +97,43 @@ public class DatasketchesProjectionTest extends InitializedNullHandlingTest
private static final Closer CLOSER = Closer.create();

private static final List<AggregateProjectionSpec> PROJECTIONS = Collections.singletonList(
new AggregateProjectionSpec(
"a_projection",
VirtualColumns.create(
Granularities.toVirtualColumn(Granularities.HOUR, "__gran")
),
Arrays.asList(
new LongDimensionSchema("__gran"),
new StringDimensionSchema("a")
),
new AggregatorFactory[]{
new HllSketchBuildAggregatorFactory("_b_hll", "b", null, null, null, null, false),
new SketchMergeAggregatorFactory("_b_theta", "b", null, null, false, null),
new DoublesSketchAggregatorFactory("_d_doubles", "d", null),
new ArrayOfDoublesSketchAggregatorFactory("_bcd_aod", "b", null, Arrays.asList("c", "d"), null),
new KllDoublesSketchAggregatorFactory("_d_kll", "d", null, null)
}
)
AggregateProjectionSpec.builder("a_projection")
.virtualColumns(
Granularities.toVirtualColumn(Granularities.HOUR, "__gran")
)
.groupingColumns(
new LongDimensionSchema("__gran"),
new StringDimensionSchema("a")
)
.aggregators(
new HllSketchBuildAggregatorFactory("_b_hll", "b", null, null, null, null, false),
new SketchMergeAggregatorFactory("_b_theta", "b", null, null, false, null),
new DoublesSketchAggregatorFactory("_d_doubles", "d", null),
new ArrayOfDoublesSketchAggregatorFactory(
"_bcd_aod",
"b",
null,
Arrays.asList("c", "d"),
null
),
new KllDoublesSketchAggregatorFactory("_d_kll", "d", null, null)
)
.build()
);

private static final List<AggregateProjectionSpec> AUTO_PROJECTIONS = PROJECTIONS.stream().map(projection -> {
return new AggregateProjectionSpec(
projection.getName(),
projection.getVirtualColumns(),
projection.getGroupingColumns()
.stream()
.map(x -> new AutoTypeColumnSchema(x.getName(), null))
.collect(Collectors.toList()),
projection.getAggregators()
);
}).collect(Collectors.toList());
private static final List<AggregateProjectionSpec> AUTO_PROJECTIONS =
PROJECTIONS.stream()
.map(
projection ->
AggregateProjectionSpec.builder(projection)
.groupingColumns(
projection.getGroupingColumns()
.stream()
.map(x -> new AutoTypeColumnSchema(x.getName(), null))
.collect(Collectors.toList())
)
.build()
).collect(Collectors.toList());

@Parameterized.Parameters(name = "name: {0}, sortByDim: {3}, autoSchema: {4}")
public static Collection<?> constructorFeeder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@
import org.apache.druid.jackson.DefaultObjectMapper;
import org.apache.druid.java.util.common.granularity.Granularities;
import org.apache.druid.metadata.TestDerbyConnector;
import org.apache.druid.query.aggregation.AggregatorFactory;
import org.apache.druid.query.aggregation.CountAggregatorFactory;
import org.apache.druid.segment.VirtualColumns;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
Expand Down Expand Up @@ -94,21 +92,16 @@ public void tearDown()
public void testCreate() throws DuplicateKeyException, NotFoundException
{
final DatasourceProjectionMetadata projectionMetadata = new DatasourceProjectionMetadata(
new AggregateProjectionSpec(
"projection",
VirtualColumns.create(
Granularities.toVirtualColumn(
Granularities.HOUR,
Granularities.GRANULARITY_VIRTUAL_COLUMN_NAME
)
),
ImmutableList.of(
new StringDimensionSchema("dim")
),
new AggregatorFactory[]{
new CountAggregatorFactory("count")
}
)
AggregateProjectionSpec.builder("projection")
.virtualColumns(
Granularities.toVirtualColumn(
Granularities.HOUR,
Granularities.GRANULARITY_VIRTUAL_COLUMN_NAME
)
)
.groupingColumns(new StringDimensionSchema("dim"))
.aggregators(new CountAggregatorFactory("count"))
.build()
);

List<Object> jsonProjectionSpec = JSON_MAPPER.convertValue(ImmutableList.of(projectionMetadata), List.class);
Expand Down
Loading
Loading