kfaraz commented on code in PR #17318:
URL: https://github.com/apache/druid/pull/17318#discussion_r1860115209
##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/indexing/MSQCompactionRunner.java:
##########
@@ -359,25 +362,31 @@ private static List<DimensionSpec> getAggregateDimensions(
private static ColumnMappings getColumnMappings(DataSchema dataSchema)
{
- List<ColumnMapping> columnMappings = dataSchema.getDimensionsSpec()
- .getDimensions()
- .stream()
- .map(dim -> new
ColumnMapping(
- dim.getName(),
dim.getName()))
-
.collect(Collectors.toList());
+ List<ColumnMapping> columnMappings = new ArrayList<>();
+ // For scan queries, a virtual column is created from __time if a custom
query granularity is provided. For
+ // group-by queries, as insert needs __time, it will always be one of the
dimensions. Since dimensions in groupby
+ // aren't allowed to have time column as the output name, we map time
dimension to TIME_VIRTUAL_COLUMN in
+ // dimensions, and map it back to the time column here.
+ String timeColumn = (isGroupBy(dataSchema) ||
!isQueryGranularityEmptyOrNone(dataSchema))
+ ? TIME_VIRTUAL_COLUMN
+ : ColumnHolder.TIME_COLUMN_NAME;
+ ColumnMapping timeColumnMapping = new ColumnMapping(timeColumn,
ColumnHolder.TIME_COLUMN_NAME);
+ if (dataSchema.getDimensionsSpec().isForceSegmentSortByTime()) {
+ // When not sorted by time, the __time column is missing from
dimensionsSpec
Review Comment:
```suggestion
// When sorted by time, the __time column is missing from
dimensionsSpec
```
--
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]