Akshat-Jain commented on code in PR #16665:
URL: https://github.com/apache/druid/pull/16665#discussion_r1657121600
##########
sql/src/test/java/org/apache/druid/sql/calcite/util/TestDataBuilder.java:
##########
@@ -960,6 +967,178 @@ public static SpecificSegmentsQuerySegmentWalker
createMockWalker(
.build(),
arraysIndex
);
+
+ attachIndexesForDrillTestDatasources(querySegmentWalker, tmpDir);
Review Comment:
Can you suggest how to do this only for the drill tests? 🤔
##########
sql/src/test/java/org/apache/druid/sql/calcite/util/TestDataBuilder.java:
##########
@@ -960,6 +967,178 @@ public static SpecificSegmentsQuerySegmentWalker
createMockWalker(
.build(),
arraysIndex
);
+
+ attachIndexesForDrillTestDatasources(querySegmentWalker, tmpDir);
+ return querySegmentWalker;
+ }
+
+ private static void
attachIndexesForDrillTestDatasources(SpecificSegmentsQuerySegmentWalker
segmentWalker, File tmpDir)
+ {
+ attachIndexForDrillTestDatasource(segmentWalker,
CalciteTests.TBL_WITH_NULLS_PARQUET, tmpDir);
+ attachIndexForDrillTestDatasource(segmentWalker,
CalciteTests.SML_TBL_PARQUET, tmpDir);
+ attachIndexForDrillTestDatasource(segmentWalker,
CalciteTests.ALL_TYPES_UNIQ_PARQUET, tmpDir);
+ attachIndexForDrillTestDatasource(segmentWalker,
CalciteTests.FEW_ROWS_ALL_DATA_PARQUET, tmpDir);
+ attachIndexForDrillTestDatasource(segmentWalker,
CalciteTests.T_ALL_TYPE_PARQUET, tmpDir);
+ }
+
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ private static void attachIndexForDrillTestDatasource(
+ SpecificSegmentsQuerySegmentWalker segmentWalker,
+ String dataSource,
+ File tmpDir
+ )
+ {
+ final QueryableIndex queryableIndex =
getQueryableIndexForDrillDatasource(dataSource, tmpDir);
+
+ segmentWalker.add(
+ DataSegment.builder()
+ .dataSource(dataSource)
+ .interval(Intervals.ETERNITY)
+ .version("1")
+ .shardSpec(new NumberedShardSpec(0, 0))
+ .size(0)
+ .build(),
+ queryableIndex);
+ }
+
+ public static QueryableIndex getQueryableIndexForDrillDatasource(String
datasource, File parentTempDir)
+ {
+ final IncrementalIndexSchema indexSchema = new
IncrementalIndexSchema.Builder()
+ .withDimensionsSpec(getDimensionSpecForDrillDatasource(datasource))
+ .withRollup(false)
+ .build();
+ Iterable<InputRow> inputRowsForDrillDatasource =
getInputRowsForDrillDatasource(datasource);
+ return IndexBuilder
+ .create()
+ .tmpDir(new File(parentTempDir, datasource))
+
.segmentWriteOutMediumFactory(OffHeapMemorySegmentWriteOutMediumFactory.instance())
+ .schema(indexSchema)
+ .rows(inputRowsForDrillDatasource)
+ .buildMMappedIndex();
+ }
+
+ private static DimensionsSpec getDimensionSpecForDrillDatasource(String
datasource)
Review Comment:
This part is mostly just refactoring, and done in a similar way as how it's
done for other datasources in this file to keep things consistent. 😅
##########
sql/src/test/java/org/apache/druid/sql/calcite/util/TestDataBuilder.java:
##########
@@ -960,6 +967,178 @@ public static SpecificSegmentsQuerySegmentWalker
createMockWalker(
.build(),
arraysIndex
);
+
+ attachIndexesForDrillTestDatasources(querySegmentWalker, tmpDir);
Review Comment:
Oh I can override `createQuerySegmentWalker()` in the ComponentSupplier
class, that should work 😅
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]