clintropolis commented on code in PR #18403:
URL: https://github.com/apache/druid/pull/18403#discussion_r2342017506


##########
processing/src/main/java/org/apache/druid/segment/projections/Projections.java:
##########
@@ -383,17 +388,30 @@ public static ProjectionMatchBuilder 
matchQueryVirtualColumn(
       // virtual column and underlying expression itself, but this will do for 
now
       final Granularity virtualGranularity = 
Granularities.fromVirtualColumn(queryVirtualColumn);
       if (virtualGranularity != null) {
-        if 
(virtualGranularity.isFinerThan(projection.getEffectiveGranularity())) {
-          return null;
-        }
         // same granularity, replace virtual column directly by remapping it 
to the physical column
         if (projection.getEffectiveGranularity().equals(virtualGranularity)) {
           return matchBuilder.remapColumn(queryVirtualColumn.getOutputName(), 
ColumnHolder.TIME_COLUMN_NAME)
                              
.addReferencedPhysicalColumn(ColumnHolder.TIME_COLUMN_NAME);
+        } else if (Granularities.ALL.equals(virtualGranularity)
+                   || 
Granularities.NONE.equals(projection.getEffectiveGranularity())) {
+          // if virtual gran is ALL or projection gran is NONE, it's 
guaranteed that projection gran can be mapped to virtual gran
+          return 
matchBuilder.addReferencedPhysicalColumn(ColumnHolder.TIME_COLUMN_NAME);
+        } else if (virtualGranularity instanceof PeriodGranularity
+                   && projection.getEffectiveGranularity() instanceof 
PeriodGranularity) {
+          PeriodGranularity virtualGran = (PeriodGranularity) 
virtualGranularity;
+          PeriodGranularity projectionGran = (PeriodGranularity) 
projection.getEffectiveGranularity();
+          byte[] combinedKey = StringUtils.toUtf8(projectionGran + "->" + 
virtualGran);

Review Comment:
   it might be better to use `getCacheKey()` from the granularities instead of 
toString conversion, this whole bit could be 
   ```
   byte[] combinedKey = new 
CacheKeyBuilder(0).appendCacheable(projectionGran).appendCacheable(virtualGran).build()
   ```



##########
processing/src/main/java/org/apache/druid/data/input/impl/AggregateProjectionSpec.java:
##########
@@ -218,10 +223,9 @@ private static ProjectionOrdering 
computeOrdering(VirtualColumns virtualColumns,
 
     String timeColumnName = null;
     Granularity granularity = null;
-    // try to find the __time column equivalent, which might be a time_floor 
expression to model granularity
-    // bucketing. The time column is decided as the finest granularity on 
__time detected. If the projection does
-    // not have a time-like column, the granularity will be handled as ALL for 
the projection and all projection
-    // rows will use a synthetic timestamp of the minimum timestamp of the 
incremental index
+
+    // determine the granularity and time column name for the projection, 
based on the first time-like grouping column.
+    // if there are multiple time-like grouping columns, they must be 
"coarser" than the first time-like grouping column.

Review Comment:
   this comment is stale now since it no longer requires time to be first and 
additional time groupings to be coarser



-- 
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]

Reply via email to