clintropolis commented on code in PR #18965:
URL: https://github.com/apache/druid/pull/18965#discussion_r2743242191
##########
sql/src/main/java/org/apache/druid/sql/calcite/expression/Expressions.java:
##########
@@ -831,25 +831,43 @@ private static DimFilter toSimpleLeafFilter(
/**
* Translates to an "expression" type leaf filter. Used as a fallback if we
can't use a simple leaf filter.
+ * If the expression contains specialized nodes (e.g. JSON_VALUE), a virtual
column is created to benefit
+ * from specialization. Otherwise, the expression is inlined directly.
*/
@Nullable
private static DimFilter toExpressionLeafFilter(
final PlannerContext plannerContext,
final RowSignature rowSignature,
+ @Nullable final VirtualColumnRegistry virtualColumnRegistry,
final RexNode rexNode
)
{
final DruidExpression druidExpression = toDruidExpression(plannerContext,
rowSignature, rexNode);
- if (druidExpression != null) {
+ if (druidExpression == null) {
+ return null;
+ }
+
+ if (virtualColumnRegistry != null &&
druidExpression.containsSpecializedNodes()) {
+ // Use a virtual column so we can take advantage of specialization.
+ final String virtualColumnName =
virtualColumnRegistry.getOrCreateVirtualColumnForExpression(
+ druidExpression,
+ ColumnType.LONG
+ );
+ final String vcExpression = "\"" + virtualColumnName + "\"";
Review Comment:
first impression is it looks a bit weird that the expression filter is just
an identifier expr a pointer to a vc, but internally that is basically what
happens anyway so it seems fine to me after getting past the strangeness, and
this i think would also allow expr re-use between filters and other things so
:+1:
--
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]