From c353ccfdeff39dae99e1ebe5ce34bbacc7dd083f Mon Sep 17 00:00:00 2001 From: Zoltan Haindrich Date: Fri, 8 Dec 2023 10:41:16 +0100 Subject: [PATCH] Windowed min aggregates null-s as 0 (#15371) --- .../epinephelinae/ParallelCombiner.java | 8 +- .../DefaultFramedOnHeapAggregatable.java | 4 +- .../segment/ObjectBasedColumnSelector.java | 78 +++++++++++++++ .../druid/segment/ObjectColumnSelector.java | 66 ++++--------- .../segment/AutoTypeColumnIndexerTest.java | 2 - .../NestedDataColumnIndexerV4Test.java | 2 - .../segment/TestObjectColumnSelector.java | 2 +- .../TestObjectBasedColumnSelector.java | 94 +++++++++++++++++++ .../sql/calcite/CalciteWindowQueryTest.java | 27 ++++-- .../sql/calcite/DrillWindowQueryTest.java | 40 +------- .../tests/window/windowed_long_null.sqlTest | 28 ++++-- .../frameclause/subQueries/frmInSubQry_27.q | 2 +- 12 files changed, 235 insertions(+), 118 deletions(-) create mode 100644 processing/src/main/java/org/apache/druid/segment/ObjectBasedColumnSelector.java create mode 100644 processing/src/test/java/org/apache/druid/segment/virtual/TestObjectBasedColumnSelector.java diff --git a/processing/src/main/java/org/apache/druid/query/groupby/epinephelinae/ParallelCombiner.java b/processing/src/main/java/org/apache/druid/query/groupby/epinephelinae/ParallelCombiner.java index d00f6f47852..97ef49ece3a 100644 --- a/processing/src/main/java/org/apache/druid/query/groupby/epinephelinae/ParallelCombiner.java +++ b/processing/src/main/java/org/apache/druid/query/groupby/epinephelinae/ParallelCombiner.java @@ -43,7 +43,7 @@ import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector; import org.apache.druid.segment.ColumnSelectorFactory; import org.apache.druid.segment.ColumnValueSelector; import org.apache.druid.segment.DimensionSelector; -import org.apache.druid.segment.ObjectColumnSelector; +import org.apache.druid.segment.ObjectBasedColumnSelector; import org.apache.druid.segment.column.ColumnCapabilities; import javax.annotation.Nullable; @@ -471,9 +471,9 @@ public class ParallelCombiner } @Override - public ColumnValueSelector makeColumnValueSelector(String columnName) + public ColumnValueSelector makeColumnValueSelector(String columnName) { - return new ObjectColumnSelector() + return new ObjectBasedColumnSelector() { @Override public void inspectRuntimeShape(RuntimeShapeInspector inspector) @@ -482,7 +482,7 @@ public class ParallelCombiner } @Override - public Class classOfObject() + public Class classOfObject() { return Object.class; } diff --git a/processing/src/main/java/org/apache/druid/query/rowsandcols/semantic/DefaultFramedOnHeapAggregatable.java b/processing/src/main/java/org/apache/druid/query/rowsandcols/semantic/DefaultFramedOnHeapAggregatable.java index bb011ff7931..cb7ae58c935 100644 --- a/processing/src/main/java/org/apache/druid/query/rowsandcols/semantic/DefaultFramedOnHeapAggregatable.java +++ b/processing/src/main/java/org/apache/druid/query/rowsandcols/semantic/DefaultFramedOnHeapAggregatable.java @@ -31,7 +31,7 @@ import org.apache.druid.query.rowsandcols.column.ObjectArrayColumn; import org.apache.druid.segment.ColumnSelectorFactory; import org.apache.druid.segment.ColumnValueSelector; import org.apache.druid.segment.DimensionSelector; -import org.apache.druid.segment.ObjectColumnSelector; +import org.apache.druid.segment.ObjectBasedColumnSelector; import org.apache.druid.segment.column.ColumnCapabilities; import org.apache.druid.segment.column.ColumnCapabilitiesImpl; @@ -551,7 +551,7 @@ public class DefaultFramedOnHeapAggregatable implements FramedOnHeapAggregatable @Nonnull public ColumnValueSelector makeColumnValueSelector(@Nonnull String columnName) { - return new ObjectColumnSelector() + return new ObjectBasedColumnSelector() { @Override public void inspectRuntimeShape(RuntimeShapeInspector inspector) diff --git a/processing/src/main/java/org/apache/druid/segment/ObjectBasedColumnSelector.java b/processing/src/main/java/org/apache/druid/segment/ObjectBasedColumnSelector.java new file mode 100644 index 00000000000..7ebaf4c1600 --- /dev/null +++ b/processing/src/main/java/org/apache/druid/segment/ObjectBasedColumnSelector.java @@ -0,0 +1,78 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.druid.segment; + +import org.apache.druid.error.DruidException; + +/** + * Object based column selector. + * + * This abstract class provides a {@link ColumnValueSelector} based on the methods of {@link BaseObjectColumnValueSelector}. + */ +public abstract class ObjectBasedColumnSelector implements ColumnValueSelector +{ + private static final String COLUMN_IS_NULL_ERROR_MESSAGE = "Invalid usage pattern: method returning primitive called - but the column is null"; + + @Override + public final float getFloat() + { + T value = getObject(); + if (value == null) { + throw DruidException.defensive(COLUMN_IS_NULL_ERROR_MESSAGE); + } + return ((Number) value).floatValue(); + } + + @Override + public final double getDouble() + { + T value = getObject(); + if (value == null) { + throw DruidException.defensive(COLUMN_IS_NULL_ERROR_MESSAGE); + } + return ((Number) value).doubleValue(); + } + + @Override + public final long getLong() + { + T value = getObject(); + if (value == null) { + throw DruidException.defensive(COLUMN_IS_NULL_ERROR_MESSAGE); + } + return ((Number) value).longValue(); + } + + @Override + public final boolean isNull() + { + T object = getObject(); + if (object == null) { + return true; + } + if (object instanceof Number) { + return false; + } + throw DruidException.defensive( + "isNull() may only be called in case the underlying object is a Number but it was [%s]", + object.getClass().getName() + ); + } +} diff --git a/processing/src/main/java/org/apache/druid/segment/ObjectColumnSelector.java b/processing/src/main/java/org/apache/druid/segment/ObjectColumnSelector.java index d9a566e5ec9..62cbe0dd0c2 100644 --- a/processing/src/main/java/org/apache/druid/segment/ObjectColumnSelector.java +++ b/processing/src/main/java/org/apache/druid/segment/ObjectColumnSelector.java @@ -19,75 +19,43 @@ package org.apache.druid.segment; +import org.apache.druid.error.DruidException; + /** - * This class is convenient for implementation of "object-sourcing" {@link ColumnValueSelector}s, it provides default - * implementations for all {@link ColumnValueSelector}'s methods except {@link #getObject()} and {@link - * #classOfObject()}. + * Restricts selector usage to only allow {@link #getObject()}. * - * This class should appear ONLY in "extends" clause or anonymous class creation, but NOT in "user" code, where - * {@link BaseObjectColumnValueSelector} must be used instead. + * This class is convenient for implementation of "object-sourcing" + * {@link ColumnValueSelector}s. * - * This is a class rather than an interface unlike {@link LongColumnSelector}, {@link FloatColumnSelector} and {@link - * DoubleColumnSelector} solely in order to make {@link #isNull()} method final. + * This class should appear ONLY in "extends" clause or anonymous class + * creation, but NOT in "user" code, where {@link BaseObjectColumnValueSelector} + * must be used instead. */ public abstract class ObjectColumnSelector implements ColumnValueSelector { - /** - * @deprecated This method is marked as deprecated in ObjectColumnSelector to minimize the probability of accidental - * calling. "Polymorphism" of ObjectColumnSelector should be used only when operating on {@link ColumnValueSelector} - * objects. - */ - @Deprecated + private static final String EXCEPTION_MESSAGE = "This class has restricted API; use getObject() instead"; + @Override - public float getFloat() + public final float getFloat() { - T value = getObject(); - if (value == null) { - return 0; - } - return ((Number) value).floatValue(); + throw DruidException.defensive(EXCEPTION_MESSAGE); } - /** - * @deprecated This method is marked as deprecated in ObjectColumnSelector to minimize the probability of accidental - * calling. "Polymorphism" of ObjectColumnSelector should be used only when operating on {@link ColumnValueSelector} - * objects. - */ - @Deprecated @Override - public double getDouble() + public final double getDouble() { - T value = getObject(); - if (value == null) { - return 0; - } - return ((Number) value).doubleValue(); + throw DruidException.defensive(EXCEPTION_MESSAGE); } - /** - * @deprecated This method is marked as deprecated in ObjectColumnSelector to minimize the probability of accidental - * calling. "Polymorphism" of ObjectColumnSelector should be used only when operating on {@link ColumnValueSelector} - * objects. - */ - @Deprecated @Override - public long getLong() + public final long getLong() { - T value = getObject(); - if (value == null) { - return 0; - } - return ((Number) value).longValue(); + throw DruidException.defensive(EXCEPTION_MESSAGE); } - /** - * @deprecated This method is marked as deprecated in ObjectColumnSelector since it always returns false. - * There is no need to call this method. - */ - @Deprecated @Override public final boolean isNull() { - return false; + throw DruidException.defensive(EXCEPTION_MESSAGE); } } diff --git a/processing/src/test/java/org/apache/druid/segment/AutoTypeColumnIndexerTest.java b/processing/src/test/java/org/apache/druid/segment/AutoTypeColumnIndexerTest.java index 8058980e17f..59aedff5dbe 100644 --- a/processing/src/test/java/org/apache/druid/segment/AutoTypeColumnIndexerTest.java +++ b/processing/src/test/java/org/apache/druid/segment/AutoTypeColumnIndexerTest.java @@ -560,7 +560,6 @@ public class AutoTypeColumnIndexerTest extends InitializedNullHandlingTest () -> cursorList.get(1).getColumnSelectorFactory().makeDimensionSelector(dimensionSpec) ); Assert.assertEquals(StructuredData.wrap(2L), valueSelector.getObject()); - Assert.assertFalse(valueSelector.isNull()); columnSelectorFactory = cursorList.get(2).getColumnSelectorFactory(); valueSelector = columnSelectorFactory.makeColumnValueSelector(NESTED_COL); @@ -569,7 +568,6 @@ public class AutoTypeColumnIndexerTest extends InitializedNullHandlingTest () -> cursorList.get(2).getColumnSelectorFactory().makeDimensionSelector(dimensionSpec) ); Assert.assertEquals(StructuredData.wrap(ImmutableMap.of("x", 1.1, "y", 2L)), valueSelector.getObject()); - Assert.assertFalse(valueSelector.isNull()); columnSelectorFactory = cursorList.get(3).getColumnSelectorFactory(); valueSelector = columnSelectorFactory.makeColumnValueSelector(NESTED_COL); diff --git a/processing/src/test/java/org/apache/druid/segment/NestedDataColumnIndexerV4Test.java b/processing/src/test/java/org/apache/druid/segment/NestedDataColumnIndexerV4Test.java index b43616b4a4a..ec691867a31 100644 --- a/processing/src/test/java/org/apache/druid/segment/NestedDataColumnIndexerV4Test.java +++ b/processing/src/test/java/org/apache/druid/segment/NestedDataColumnIndexerV4Test.java @@ -551,7 +551,6 @@ public class NestedDataColumnIndexerV4Test extends InitializedNullHandlingTest () -> cursorList.get(1).getColumnSelectorFactory().makeDimensionSelector(dimensionSpec) ); Assert.assertEquals(StructuredData.wrap(2L), valueSelector.getObject()); - Assert.assertFalse(valueSelector.isNull()); columnSelectorFactory = cursorList.get(2).getColumnSelectorFactory(); valueSelector = columnSelectorFactory.makeColumnValueSelector(NESTED_COL); @@ -560,7 +559,6 @@ public class NestedDataColumnIndexerV4Test extends InitializedNullHandlingTest () -> cursorList.get(2).getColumnSelectorFactory().makeDimensionSelector(dimensionSpec) ); Assert.assertEquals(StructuredData.wrap(ImmutableMap.of("x", 1.1, "y", 2L)), valueSelector.getObject()); - Assert.assertFalse(valueSelector.isNull()); columnSelectorFactory = cursorList.get(3).getColumnSelectorFactory(); valueSelector = columnSelectorFactory.makeColumnValueSelector(NESTED_COL); diff --git a/processing/src/test/java/org/apache/druid/segment/TestObjectColumnSelector.java b/processing/src/test/java/org/apache/druid/segment/TestObjectColumnSelector.java index cfc51ac24a3..0f2223523e0 100644 --- a/processing/src/test/java/org/apache/druid/segment/TestObjectColumnSelector.java +++ b/processing/src/test/java/org/apache/druid/segment/TestObjectColumnSelector.java @@ -21,7 +21,7 @@ package org.apache.druid.segment; import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector; -public abstract class TestObjectColumnSelector extends ObjectColumnSelector +public abstract class TestObjectColumnSelector extends ObjectBasedColumnSelector { @Override public void inspectRuntimeShape(RuntimeShapeInspector inspector) diff --git a/processing/src/test/java/org/apache/druid/segment/virtual/TestObjectBasedColumnSelector.java b/processing/src/test/java/org/apache/druid/segment/virtual/TestObjectBasedColumnSelector.java new file mode 100644 index 00000000000..c7462b2c4d5 --- /dev/null +++ b/processing/src/test/java/org/apache/druid/segment/virtual/TestObjectBasedColumnSelector.java @@ -0,0 +1,94 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.druid.segment.virtual; + +import org.apache.druid.error.DruidException; +import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector; +import org.apache.druid.segment.ObjectBasedColumnSelector; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertThrows; +import static org.junit.Assert.assertTrue; + +public class TestObjectBasedColumnSelector +{ + static class MyObjectColumnSelector extends ObjectBasedColumnSelector + { + private Object obj; + + MyObjectColumnSelector(Object obj) + { + this.obj = obj; + } + + @Override + public void inspectRuntimeShape(RuntimeShapeInspector inspector) + { + } + + @Override + public Object getObject() + { + return obj; + } + + @Override + public Class classOfObject() + { + if (obj == null) { + return null; + } + return obj.getClass(); + } + } + + @Test + public void testNull() + { + MyObjectColumnSelector selector = new MyObjectColumnSelector(null); + assertThrows(DruidException.class, () -> selector.getFloat()); + assertThrows(DruidException.class, () -> selector.getDouble()); + assertThrows(DruidException.class, () -> selector.getLong()); + assertTrue(selector.isNull()); + } + + @Test + public void testLong() + { + MyObjectColumnSelector selector = new MyObjectColumnSelector(Long.valueOf(11L)); + assertFalse(selector.isNull()); + assertEquals(11f, selector.getLong(), 0.0f); + } + + @Test + public void testInvalidIsNullUse() + { + MyObjectColumnSelector selector = new MyObjectColumnSelector(getClass()); + + DruidException e = assertThrows(DruidException.class, () -> selector.isNull()); + + assertEquals( + e.getMessage(), + "isNull() may only be called in case the underlying object is a Number but it was [java.lang.Class]" + ); + } +} diff --git a/sql/src/test/java/org/apache/druid/sql/calcite/CalciteWindowQueryTest.java b/sql/src/test/java/org/apache/druid/sql/calcite/CalciteWindowQueryTest.java index 765dab45b52..32ffda0cc39 100644 --- a/sql/src/test/java/org/apache/druid/sql/calcite/CalciteWindowQueryTest.java +++ b/sql/src/test/java/org/apache/druid/sql/calcite/CalciteWindowQueryTest.java @@ -130,16 +130,7 @@ public class CalciteWindowQueryTest extends BaseCalciteQueryTest maybeDumpActualResults(results.results); if (input.expectedOperators != null) { final WindowOperatorQuery query = getWindowOperatorQuery(results.recordedQueries); - for (int i = 0; i < input.expectedOperators.size(); ++i) { - final OperatorFactory expectedOperator = input.expectedOperators.get(i); - final OperatorFactory actualOperator = query.getOperators().get(i); - if (!expectedOperator.validateEquivalent(actualOperator)) { - assertEquals("Operator Mismatch, index[" + i + "]", - queryJackson.writeValueAsString(expectedOperator), - queryJackson.writeValueAsString(actualOperator)); - fail("validateEquivalent failed; but textual comparision of operators didn't reported the mismatch!"); - } - } + validateOperators(input.expectedOperators, query.getOperators()); } final RowSignature outputSignature = results.signature; @@ -179,6 +170,22 @@ public class CalciteWindowQueryTest extends BaseCalciteQueryTest assertResultsValid(ResultMatchMode.RELAX_NULLS, input.expectedResults, results); } + private void validateOperators(List expectedOperators, List currentOperators) + throws Exception + { + for (int i = 0; i < expectedOperators.size(); ++i) { + final OperatorFactory expectedOperator = expectedOperators.get(i); + final OperatorFactory actualOperator = currentOperators.get(i); + if (!expectedOperator.validateEquivalent(actualOperator)) { + assertEquals("Operator Mismatch, index[" + i + "]", + queryJackson.writeValueAsString(expectedOperator), + queryJackson.writeValueAsString(actualOperator)); + fail("validateEquivalent failed; but textual comparision of operators didn't reported the mismatch!"); + } + } + assertEquals("Operator count mismatch!", expectedOperators.size(), currentOperators.size()); + } + private void maybeDumpActualResults(List results) throws Exception { if (DUMP_ACTUAL_RESULTS) { diff --git a/sql/src/test/java/org/apache/druid/sql/calcite/DrillWindowQueryTest.java b/sql/src/test/java/org/apache/druid/sql/calcite/DrillWindowQueryTest.java index 0a82564e644..5d2098b760e 100644 --- a/sql/src/test/java/org/apache/druid/sql/calcite/DrillWindowQueryTest.java +++ b/sql/src/test/java/org/apache/druid/sql/calcite/DrillWindowQueryTest.java @@ -4980,7 +4980,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest windowQueryTest(); } - @NotYetSupported(Modes.RESULT_COUNT_MISMATCH) @DrillTest("aggregates/testW_Nulls_10") @Test public void test_aggregates_testW_Nulls_10() @@ -5140,7 +5139,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest windowQueryTest(); } - @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("aggregates/testW_Nulls_2") @Test public void test_aggregates_testW_Nulls_2() @@ -5228,7 +5226,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest windowQueryTest(); } - @NotYetSupported(Modes.RESULT_COUNT_MISMATCH) @DrillTest("aggregates/testW_Nulls_3") @Test public void test_aggregates_testW_Nulls_3() @@ -5236,7 +5233,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest windowQueryTest(); } - @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("aggregates/testW_Nulls_4") @Test public void test_aggregates_testW_Nulls_4() @@ -5283,7 +5279,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest windowQueryTest(); } - @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("aggregates/winFnQry_61") @Test public void test_aggregates_winFnQry_61() @@ -5291,7 +5286,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest windowQueryTest(); } - @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("aggregates/winFnQry_62") @Test public void test_aggregates_winFnQry_62() @@ -5419,7 +5413,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest windowQueryTest(); } - @NotYetSupported(Modes.RESULT_COUNT_MISMATCH) @DrillTest("aggregates/winFnQry_79") @Test public void test_aggregates_winFnQry_79() @@ -5427,7 +5420,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest windowQueryTest(); } - @NotYetSupported(Modes.RESULT_COUNT_MISMATCH) @DrillTest("aggregates/winFnQry_80") @Test public void test_aggregates_winFnQry_80() @@ -5435,7 +5427,7 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest windowQueryTest(); } - @NotYetSupported(Modes.RESULT_COUNT_MISMATCH) + @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("aggregates/winFnQry_81") @Test public void test_aggregates_winFnQry_81() @@ -5863,7 +5855,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest windowQueryTest(); } - @NotYetSupported(Modes.RESULT_COUNT_MISMATCH) @DrillTest("frameclause/subQueries/frmInSubQry_17") @Test public void test_frameclause_subQueries_frmInSubQry_17() @@ -5871,7 +5862,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest windowQueryTest(); } - @NotYetSupported(Modes.RESULT_COUNT_MISMATCH) @DrillTest("frameclause/subQueries/frmInSubQry_20") @Test public void test_frameclause_subQueries_frmInSubQry_20() @@ -5887,7 +5877,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest windowQueryTest(); } - @NotYetSupported(Modes.RESULT_COUNT_MISMATCH) @DrillTest("frameclause/subQueries/frmInSubQry_27") @Test public void test_frameclause_subQueries_frmInSubQry_27() @@ -5903,7 +5892,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest windowQueryTest(); } - @NotYetSupported(Modes.RESULT_COUNT_MISMATCH) @DrillTest("frameclause/subQueries/frmInSubQry_30") @Test public void test_frameclause_subQueries_frmInSubQry_30() @@ -6641,7 +6629,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest windowQueryTest(); } - @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("frameclause/defaultFrame/RBUPACR_bgint_1") @Test public void test_frameclause_defaultFrame_RBUPACR_bgint_1() @@ -6649,7 +6636,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest windowQueryTest(); } - @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("frameclause/defaultFrame/RBUPACR_bgint_2") @Test public void test_frameclause_defaultFrame_RBUPACR_bgint_2() @@ -6657,7 +6643,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest windowQueryTest(); } - @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("frameclause/defaultFrame/RBUPACR_bgint_3") @Test public void test_frameclause_defaultFrame_RBUPACR_bgint_3() @@ -6702,7 +6687,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest windowQueryTest(); } - @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("frameclause/defaultFrame/RBUPACR_dbl_1") @Test public void test_frameclause_defaultFrame_RBUPACR_dbl_1() @@ -6710,7 +6694,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest windowQueryTest(); } - @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("frameclause/defaultFrame/RBUPACR_dbl_2") @Test public void test_frameclause_defaultFrame_RBUPACR_dbl_2() @@ -6718,7 +6701,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest windowQueryTest(); } - @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("frameclause/defaultFrame/RBUPACR_dbl_3") @Test public void test_frameclause_defaultFrame_RBUPACR_dbl_3() @@ -6741,7 +6723,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest windowQueryTest(); } - @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("frameclause/defaultFrame/RBUPACR_dt_1") @Test public void test_frameclause_defaultFrame_RBUPACR_dt_1() @@ -6749,7 +6730,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest windowQueryTest(); } - @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("frameclause/defaultFrame/RBUPACR_dt_2") @Test public void test_frameclause_defaultFrame_RBUPACR_dt_2() @@ -6772,7 +6752,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest windowQueryTest(); } - @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("frameclause/defaultFrame/RBUPACR_int10") @Test public void test_frameclause_defaultFrame_RBUPACR_int10() @@ -6795,7 +6774,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest windowQueryTest(); } - @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("frameclause/defaultFrame/RBUPACR_int8") @Test public void test_frameclause_defaultFrame_RBUPACR_int8() @@ -6803,7 +6781,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest windowQueryTest(); } - @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("frameclause/defaultFrame/RBUPACR_int9") @Test public void test_frameclause_defaultFrame_RBUPACR_int9() @@ -6872,7 +6849,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest windowQueryTest(); } - @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("frameclause/multipl_wnwds/sum_mulwds") @Test public void test_frameclause_multipl_wnwds_sum_mulwds() @@ -7020,7 +6996,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest windowQueryTest(); } - @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("frameclause/RBUPACR/RBUPACR_bgint_1") @Test public void test_frameclause_RBUPACR_RBUPACR_bgint_1() @@ -7028,7 +7003,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest windowQueryTest(); } - @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("frameclause/RBUPACR/RBUPACR_bgint_2") @Test public void test_frameclause_RBUPACR_RBUPACR_bgint_2() @@ -7036,7 +7010,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest windowQueryTest(); } - @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("frameclause/RBUPACR/RBUPACR_bgint_3") @Test public void test_frameclause_RBUPACR_RBUPACR_bgint_3() @@ -7081,7 +7054,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest windowQueryTest(); } - @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("frameclause/RBUPACR/RBUPACR_dbl_1") @Test public void test_frameclause_RBUPACR_RBUPACR_dbl_1() @@ -7089,7 +7061,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest windowQueryTest(); } - @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("frameclause/RBUPACR/RBUPACR_dbl_2") @Test public void test_frameclause_RBUPACR_RBUPACR_dbl_2() @@ -7097,7 +7068,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest windowQueryTest(); } - @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("frameclause/RBUPACR/RBUPACR_dbl_3") @Test public void test_frameclause_RBUPACR_RBUPACR_dbl_3() @@ -7120,7 +7090,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest windowQueryTest(); } - @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("frameclause/RBUPACR/RBUPACR_int10") @Test public void test_frameclause_RBUPACR_RBUPACR_int10() @@ -7718,7 +7687,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest windowQueryTest(); } - @NotYetSupported(Modes.T_ALLTYPES_ISSUES) @DrillTest("frameclause/multipl_wnwds/rnkNoFrm03") @Test public void test_frameclause_multipl_wnwds_rnkNoFrm03() @@ -7750,7 +7718,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest windowQueryTest(); } - @NotYetSupported(Modes.T_ALLTYPES_ISSUES) @DrillTest("frameclause/RBUPACR/RBUPACR_dt_1") @Test public void test_frameclause_RBUPACR_RBUPACR_dt_1() @@ -7758,7 +7725,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest windowQueryTest(); } - @NotYetSupported(Modes.T_ALLTYPES_ISSUES) @DrillTest("frameclause/RBUPACR/RBUPACR_dt_2") @Test public void test_frameclause_RBUPACR_RBUPACR_dt_2() @@ -7789,7 +7755,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest windowQueryTest(); } - @NotYetSupported(Modes.T_ALLTYPES_ISSUES) @DrillTest("frameclause/RBUPACR/RBUPACR_int8") @Test public void test_frameclause_RBUPACR_RBUPACR_int8() @@ -7797,7 +7762,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest windowQueryTest(); } - @NotYetSupported(Modes.T_ALLTYPES_ISSUES) @DrillTest("frameclause/RBUPACR/RBUPACR_int9") @Test public void test_frameclause_RBUPACR_RBUPACR_int9() @@ -7861,7 +7825,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest windowQueryTest(); } - @NotYetSupported(Modes.T_ALLTYPES_ISSUES) @DrillTest("nestedAggs/multiWin_6") @Test public void test_nestedAggs_multiWin_6() @@ -7869,7 +7832,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest windowQueryTest(); } - @NotYetSupported(Modes.T_ALLTYPES_ISSUES) @DrillTest("nestedAggs/multiWin_8") @Test public void test_nestedAggs_multiWin_8() diff --git a/sql/src/test/resources/calcite/tests/window/windowed_long_null.sqlTest b/sql/src/test/resources/calcite/tests/window/windowed_long_null.sqlTest index 65d6265769a..2288425b8e5 100644 --- a/sql/src/test/resources/calcite/tests/window/windowed_long_null.sqlTest +++ b/sql/src/test/resources/calcite/tests/window/windowed_long_null.sqlTest @@ -2,10 +2,11 @@ type: "operatorValidation" sql: | SELECT - l2, - MIN(l2) OVER(partition by l2) + l2,l1, + MIN(l2) OVER(partition by l2), + MIN(l2) OVER(partition by l2 order by l1) FROM druid.numfoo - WHERE l2 is null or l2 = -1111 or l2 = 0 + WHERE (l2 is null or l2 = -1111 or l2 = 0) and (l1 is null or l1 != 7) expectedOperators: @@ -21,10 +22,21 @@ expectedOperators: frame: { peerType: "ROWS", lowUnbounded: true, lowOffset: 0, uppUnbounded: true, uppOffset: 0 } aggregations: - { type: "longMin", name: "w0", fieldName: "l2" } + - type: "naiveSort" + columns: + - { column: l2, direction: ASC } + - { column: l1, direction: ASC } + - type: "naivePartition" + partitionColumns: [ "l2" ] + - type: "window" + processor: + type: "framedAgg" + frame: { peerType: "ROWS", lowUnbounded: true, lowOffset: 0, uppUnbounded: false, uppOffset: 0 } + aggregations: + - { type: "longMin", name: "w1", fieldName: "l2" } expectedResults: - - [null,null] - - [null,null] - - [null,null] - - [null,null] - - [0,0] \ No newline at end of file + - [null,null,null,null] + - [null,null,null,null] + - [null,null,null,null] + - [0,0,0,0] \ No newline at end of file diff --git a/sql/src/test/resources/drill/window/queries/frameclause/subQueries/frmInSubQry_27.q b/sql/src/test/resources/drill/window/queries/frameclause/subQueries/frmInSubQry_27.q index 399eb4c5667..ae1536a5967 100644 --- a/sql/src/test/resources/drill/window/queries/frameclause/subQueries/frmInSubQry_27.q +++ b/sql/src/test/resources/drill/window/queries/frameclause/subQueries/frmInSubQry_27.q @@ -4,4 +4,4 @@ SELECT * FROM "t_alltype.parquet" WINDOW W AS ( PARTITION BY c8 ORDER BY c1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) ) subQry -WHERE subQry.w_min > '1920-05-14' +WHERE MILLIS_TO_TIMESTAMP(subQry.w_min) > '1920-05-14'