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 @@ -134,7 +134,7 @@ public CompressedNestedDataComplexColumn(
Supplier<TStringDictionary> stringDictionary,
Supplier<FixedIndexed<Long>> longDictionarySupplier,
Supplier<FixedIndexed<Double>> doubleDictionarySupplier,
Supplier<FrontCodedIntArrayIndexed> arrayDictionarySupplier,
@Nullable Supplier<FrontCodedIntArrayIndexed> arrayDictionarySupplier,
SmooshedFileMapper fileMapper,
BitmapSerdeFactory bitmapSerdeFactory,
ByteOrder byteOrder,
Expand Down Expand Up @@ -220,6 +220,9 @@ public Indexed<Double> getDoubleDictionary()
@Override
public Indexed<Object[]> getArrayDictionary()
{
if (arrayDictionarySupplier == null) {
return Indexed.empty();
}
Iterable<Object[]> arrays = () -> {
final TStringDictionary stringDictionary = stringDictionarySupplier.get();
final FixedIndexed<Long> longDictionary = longDictionarySupplier.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.apache.druid.query.aggregation.AggregatorFactory;
import org.apache.druid.query.aggregation.CountAggregatorFactory;
import org.apache.druid.query.expression.TestExprMacroTable;
import org.apache.druid.segment.AutoTypeColumnSchema;
import org.apache.druid.segment.IncrementalIndexSegment;
import org.apache.druid.segment.IndexBuilder;
import org.apache.druid.segment.IndexSpec;
Expand Down Expand Up @@ -92,15 +93,30 @@ public class NestedDataTestUtils
.useSchemaDiscovery(true)
.build();

public static final DimensionsSpec TSV_SCHEMA =
public static final DimensionsSpec TSV_V4_SCHEMA =
DimensionsSpec.builder()
.setDimensions(
Arrays.asList(
new NestedDataDimensionSchema("dim"),
new NestedDataDimensionSchema("nest_json"),
new NestedDataDimensionSchema("nester_json"),
new NestedDataDimensionSchema("variant_json"),
new NestedDataDimensionSchema("list_json")
new NestedDataDimensionSchema("list_json"),
new NestedDataDimensionSchema("nonexistent")
)
)
.build();

public static final DimensionsSpec TSV_SCHEMA =
DimensionsSpec.builder()
.setDimensions(
Arrays.asList(
new AutoTypeColumnSchema("dim"),
new AutoTypeColumnSchema("nest_json"),
new AutoTypeColumnSchema("nester_json"),
new AutoTypeColumnSchema("variant_json"),
new AutoTypeColumnSchema("list_json"),
new AutoTypeColumnSchema("nonexistent")
)
)
.build();
Expand All @@ -110,12 +126,6 @@ public class NestedDataTestUtils
null
);

public static final InputRowSchema SIMPLE_DATA_TSV_SCHEMA = new InputRowSchema(
TIMESTAMP_SPEC,
TSV_SCHEMA,
null
);

public static DelimitedInputFormat SIMPLE_DATA_TSV_INPUT_FORMAT = new DelimitedInputFormat(
Arrays.asList(
"timestamp",
Expand Down Expand Up @@ -161,6 +171,22 @@ public static List<Segment> createSimpleSegmentsTsv(
tempFolder,
closer,
Granularities.NONE,
TSV_SCHEMA,
true
);
}

public static List<Segment> createSimpleSegmentsTsvV4(
TemporaryFolder tempFolder,
Closer closer
)
throws Exception
{
return createSimpleNestedTestDataTsvSegments(
tempFolder,
closer,
Granularities.NONE,
TSV_V4_SCHEMA,
true
);
}
Expand All @@ -169,6 +195,7 @@ public static List<Segment> createSimpleNestedTestDataTsvSegments(
TemporaryFolder tempFolder,
Closer closer,
Granularity granularity,
DimensionsSpec dimensionsSpec,
boolean rollup
) throws Exception
{
Expand All @@ -178,7 +205,7 @@ public static List<Segment> createSimpleNestedTestDataTsvSegments(
SIMPLE_DATA_TSV_FILE,
SIMPLE_DATA_TSV_INPUT_FORMAT,
TIMESTAMP_SPEC,
SIMPLE_DATA_TSV_SCHEMA.getDimensionsSpec(),
dimensionsSpec,
SIMPLE_DATA_TSV_TRANSFORM,
COUNT,
granularity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,35 @@ public void testIngestAndScanSegmentsRealtimeWithFallback() throws Exception
Assert.assertEquals(resultsSegments.get(0).getEvents().toString(), resultsRealtime.get(0).getEvents().toString());
}

@Test
public void testIngestAndScanSegmentsTsvV4() throws Exception
{
Query<ScanResultValue> scanQuery = Druids.newScanQueryBuilder()
.dataSource("test_datasource")
.intervals(
new MultipleIntervalSegmentSpec(
Collections.singletonList(Intervals.ETERNITY)
)
)
.virtualColumns(
new NestedFieldVirtualColumn("nest", "$.x", "x"),
new NestedFieldVirtualColumn("nester", "$.x[0]", "x_0"),
new NestedFieldVirtualColumn("nester", "$.y.c[1]", "y_c_1")
)
.resultFormat(ScanQuery.ResultFormat.RESULT_FORMAT_COMPACTED_LIST)
.limit(100)
.context(ImmutableMap.of())
.build();
List<Segment> segs = NestedDataTestUtils.createSimpleSegmentsTsvV4(tempFolder, closer);

final Sequence<ScanResultValue> seq = helper.runQueryOnSegmentsObjs(segs, scanQuery);

List<ScanResultValue> results = seq.toList();
Assert.assertEquals(1, results.size());
Assert.assertEquals(8, ((List) results.get(0).getEvents()).size());
logResults(results);
}

@Test
public void testIngestAndScanSegmentsTsv() throws Exception
{
Expand Down