Skip to content

add druid.expressions.allowVectorizeFallback and default to false#17248

Merged
abhishekagarwal87 merged 4 commits intoapache:masterfrom
clintropolis:expression-fallback-config
Oct 5, 2024
Merged

add druid.expressions.allowVectorizeFallback and default to false#17248
abhishekagarwal87 merged 4 commits intoapache:masterfrom
clintropolis:expression-fallback-config

Conversation

@clintropolis
Copy link
Copy Markdown
Member

changes:

  • adds ExpressionProcessing.allowVectorizeFallback() and ExpressionProcessingConfig.allowVectorizeFallback(), defaulting to false until few remaining bugs can be fixed (mostly complex types and some odd interactions with mixed types)
  • add cannotVectorizeUnlessFallback functions to make it easy to toggle the default of this config, and easy to know what to delete when we remove it in the future

changes:
* adds ExpressionProcessing.allowVectorizeFallback() and ExpressionProcessingConfig.allowVectorizeFallback(), defaulting to false
* add cannotVectorizeUnlessFallback functions to make it easy to toggle the default of this config, and easy to know what to delete when we remove it in the future
|Key|Description|Default|
|---|-----------|-------|
|`druid.expressions.useStrictBooleans`|Controls the behavior of Druid boolean operators and functions, if set to `true` all boolean values are either `1` or `0`. This configuration has been deprecated and will be removed in a future release, taking on the `true` behavior. See [expression documentation](../querying/math-expr.md#logical-operator-modes) for more information.|true|
|`druid.expressions.allowNestedArrays`|If enabled, Druid array expressions can create nested arrays. This configuration has been deprecated and will be removed in a future release, taking on the `true` behavior.|true|
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this had already been removed? I don't see references to it in the code.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea, i forgot to delete the docs for it

@abhishekagarwal87 abhishekagarwal87 merged commit 04fe568 into apache:master Oct 5, 2024
@clintropolis clintropolis deleted the expression-fallback-config branch October 5, 2024 07:28
abhishekagarwal87 pushed a commit to abhishekagarwal87/druid that referenced this pull request Oct 5, 2024
…ache#17248)

changes:

adds ExpressionProcessing.allowVectorizeFallback() and ExpressionProcessingConfig.allowVectorizeFallback(), defaulting to false until few remaining bugs can be fixed (mostly complex types and some odd interactions with mixed types)
add cannotVectorizeUnlessFallback functions to make it easy to toggle the default of this config, and easy to know what to delete when we remove it in the future
kfaraz pushed a commit to kfaraz/druid that referenced this pull request Oct 6, 2024
…ache#17248)

changes:

adds ExpressionProcessing.allowVectorizeFallback() and ExpressionProcessingConfig.allowVectorizeFallback(), defaulting to false until few remaining bugs can be fixed (mostly complex types and some odd interactions with mixed types)
add cannotVectorizeUnlessFallback functions to make it easy to toggle the default of this config, and easy to know what to delete when we remove it in the future
abhishekagarwal87 added a commit that referenced this pull request Oct 6, 2024
…7248) (#17260)

changes:

adds ExpressionProcessing.allowVectorizeFallback() and ExpressionProcessingConfig.allowVectorizeFallback(), defaulting to false until few remaining bugs can be fixed (mostly complex types and some odd interactions with mixed types)
add cannotVectorizeUnlessFallback functions to make it easy to toggle the default of this config, and easy to know what to delete when we remove it in the future

Co-authored-by: Clint Wylie <cwylie@apache.org>
gianm added a commit to gianm/druid that referenced this pull request Sep 9, 2025
PR apache#16366 originally added fallback vectorization, a mechanism for
making all expressions vectorizable. Later, apache#17098 fixed some issues
that arose and apache#17248 disabled fallback vectorization in the out-of-box
configuration.

This patch fixes various remaining issues with inconsistent type handling
between the vectorized and nonvectorized expr implementations. It does not
yet re-enable fallback vectorization out of the box, due to remaining
inconsistencies with conditional exprs like "case_searched", "case_simple",
and "if".

1) Aligns the behavior of missing columns and literal nulls so they are
   always treated as null longs. This was already the case for vectorized
   identifiers, but non-vectorized identifiers and literal nulls were still
   represented as strings.

2) Replaces all occurrences of "ExprEval.of(null)" with either an explicit
   type, or a call to "ExprEval.ofMissing()". ofMissing is a new function
   for situations where an eval represents a null value of unknown type.
   It is equivalent to "ExprEval.ofLong(null)", but is a separate function
   for clarity at the call site.

3) Update "cast" to return the target type even for null values.

4) Update "greatest", "least", and "array" so they eval to types that
   match what is reported by "getOutputType".

5) Update "scalb" to coerce input strings as numbers, to better allow
   for type evolution and missing columns.

6) Update "reverse" to coerce inputs to strings, to better allow for
   type evolution and missing columns.
gianm added a commit that referenced this pull request Sep 18, 2025
* Additional expr type alignment.

PR #16366 originally added fallback vectorization, a mechanism for
making all expressions vectorizable. Later, #17098 fixed some issues
that arose and #17248 disabled fallback vectorization in the out-of-box
configuration.

This patch fixes various remaining issues with inconsistent type handling
between the vectorized and nonvectorized expr implementations. It does not
yet re-enable fallback vectorization out of the box, due to remaining
inconsistencies with conditional exprs like "case_searched", "case_simple",
and "if".

1) Aligns the behavior of missing columns and literal nulls so they are
   always treated as null longs. This was already the case for vectorized
   identifiers, but non-vectorized identifiers and literal nulls were still
   represented as strings.

2) Replaces all occurrences of "ExprEval.of(null)" with either an explicit
   type, or a call to "ExprEval.ofMissing()". ofMissing is a new function
   for situations where an eval represents a null value of unknown type.
   It is equivalent to "ExprEval.ofLong(null)", but is a separate function
   for clarity at the call site.

3) Update "cast" to return the target type even for null values.

4) Update "greatest", "least", and "array" so they eval to types that
   match what is reported by "getOutputType".

5) Update "scalb" to coerce input strings as numbers, to better allow
   for type evolution and missing columns.

6) Update "reverse" to coerce inputs to strings, to better allow for
   type evolution and missing columns.

* Restore fallback in testArrayFns.

* Fix issues.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants