You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2022/10/17 22:46:17 UTC

[GitHub] [druid] clintropolis commented on a diff in pull request #13085: Refactoring the data source before unnest

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


##########
sql/src/main/java/org/apache/druid/sql/calcite/planner/PlannerContext.java:
##########
@@ -77,6 +78,7 @@
   private final String sql;
   private final DruidOperatorTable operatorTable;
   private final ExprMacroTable macroTable;
+  private final JoinableFactoryWrapper jfw;

Review Comment:
   super super nit: tiny variable name doesn't seem very consistent with other names 😅 



##########
processing/src/main/java/org/apache/druid/query/DataSource.java:
##########
@@ -83,8 +89,40 @@
    * Returns true if this datasource represents concrete data that can be scanned via a
    * {@link org.apache.druid.segment.Segment} adapter of some kind. True for e.g. 'table' but not for 'query' or 'join'.
    *
-   * @see org.apache.druid.query.planning.DataSourceAnalysis#isConcreteBased() which uses this
-   * @see org.apache.druid.query.planning.DataSourceAnalysis#isConcreteTableBased() which uses this
+   * @see DataSourceAnalysis#isConcreteBased() which uses this
+   * @see DataSourceAnalysis#isConcreteTableBased() which uses this
    */
   boolean isConcrete();
+
+  /**
+   * Returns a segment function on to how to segment should be modified.
+   *
+   * @param query the input query
+   * @param cpuTimeAcc the cpu time accumulator
+   * @return the segment function
+   */
+  Function<SegmentReference, SegmentReference> createSegmentMapFunction(Query query, AtomicLong cpuTimeAcc);
+
+  /**
+   * Returns an updated datasource based on the specified new source.
+   *
+   * @param newSource the new datasource to be used to update an existing query
+   * @return the updated datasource to be used
+   */
+  DataSource withUpdatedDataSource(DataSource newSource);
+
+  /**
+   * Compute a cache key prefix for a data source. This includes the data sources that participate in the RHS of a
+   * join as well as any query specific constructs associated with join data source such as base table filter. This key prefix
+   * can be used in segment level cache or result level cache. The function can return following
+   * - Non-empty byte array - If there is join datasource involved and caching is possible. The result includes
+   * join condition expression, join type and cache key returned by joinable factory for each {@link PreJoinableClause}
+   * - NULL - There is a join but caching is not possible. It may happen if one of the participating datasource
+   * in the JOIN is not cacheable.
+   *
+   * @return the cache key to be used as part of query cache key
+   * @throws {@link IAE} if this operation is called on a non-join data source
+   */
+  byte[] getCacheKey();

Review Comment:
   >throws {@link IAE} if this operation is called on a non-join data source
   the javadocs are maybe not true exactly? it looks like most implementations are currently returning empty bytes.
   
   Im also a bit tunsure how great this naming is given that it should only be used for joins afaik, and not used at all for cache keys otherwise. it seems sort of seems like it would be important for all query types, but calling it something specific to joins also seems short sighted... Not sure what exactly to do here.. maybe this needs a wider discussion about what kinds of datasources need to implement this and what do not which would help clear this up



##########
server/src/main/java/org/apache/druid/server/LocalQuerySegmentWalker.java:
##########
@@ -94,12 +93,13 @@ public <T> QueryRunner<T> getQueryRunnerForIntervals(final Query<T> query, final
 
     final AtomicLong cpuAccumulator = new AtomicLong(0L);
 
-    final Function<SegmentReference, SegmentReference> segmentMapFn = joinableFactoryWrapper.createSegmentMapFn(
-        analysis.getJoinBaseTableFilter().map(Filters::toFilter).orElse(null),
-        analysis.getPreJoinableClauses(),
-        cpuAccumulator,
-        analysis.getBaseQuery().orElse(query)
-    );
+    Function<SegmentReference, SegmentReference> segmentMapFn = analysis

Review Comment:
   super nit: `final` to match other lines 😅 



-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org