Skip to content

Commit fdb9886

Browse files
committed
Document limitations of pushding case as range queries
Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
1 parent a5fdd66 commit fdb9886

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

docs/user/ppl/functions/condition.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,16 @@ Argument type: all the supported data type, (NOTE : there is no comma before "el
227227

228228
Return type: any
229229

230+
Limitations
231+
>>>>>>>>>>>
232+
233+
When each condition is a field comparison with a numeric literal and each result expression is a string literal, the query will be optimized as `range aggregations <https://docs.opensearch.org/latest/aggregations/bucket/range>`_ if pushdown optimization is enabled. However, this optimization has the following limitations:
234+
235+
- Null values will not be grouped into any bucket of a range aggregation and will be ignored
236+
- The default ELSE clause will use the string literal ``"null"`` instead of actual NULL values
237+
238+
To avoid these edge-case limitations, set ``plugins.calcite.pushdown.enabled`` to false.
239+
230240
Example::
231241

232242
os> source=accounts | eval result = case(age > 35, firstname, age < 30, lastname else employer) | fields result, firstname, lastname, age, employer

integ-test/src/test/java/org/opensearch/sql/calcite/remote/CalcitePPLCaseFunctionIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ public void testCaseAggWithNullValues() throws IOException {
458458
+ "| stats avg(age) by age_category",
459459
TEST_INDEX_STATE_COUNTRY_WITH_NULL));
460460
verifySchema(actual, schema("avg(age)", "double"), schema("age_category", "string"));
461-
// TODO: There is such discrepancy because range aggregations will ignore null values
461+
// There is such discrepancy because range aggregations will ignore null values
462462
if (isPushdownDisabled()) {
463463
verifyDataRows(
464464
actual,

0 commit comments

Comments
 (0)