diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/planner/DruidSqlValidator.java b/sql/src/main/java/org/apache/druid/sql/calcite/planner/DruidSqlValidator.java index 5a901c72296e..d7665604ecce 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/planner/DruidSqlValidator.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/planner/DruidSqlValidator.java @@ -22,7 +22,12 @@ import org.apache.calcite.adapter.java.JavaTypeFactory; import org.apache.calcite.prepare.BaseDruidSqlValidator; import org.apache.calcite.prepare.CalciteCatalogReader; +import org.apache.calcite.sql.SqlCall; +import org.apache.calcite.sql.SqlKind; +import org.apache.calcite.sql.SqlNode; import org.apache.calcite.sql.SqlOperatorTable; +import org.apache.calcite.sql.validate.SqlValidatorScope; +import org.apache.druid.error.InvalidSqlInput; /** * Druid extended SQL validator. (At present, it doesn't actually @@ -39,4 +44,23 @@ protected DruidSqlValidator( { super(opTab, catalogReader, typeFactory, validatorConfig); } + + @Override + public void validateCall(SqlCall call, SqlValidatorScope scope) + { + if (call.getKind() == SqlKind.NULLS_FIRST) { + SqlNode op0 = call.getOperandList().get(0); + if (op0.getKind() == SqlKind.DESCENDING) { + throw InvalidSqlInput.exception("DESCENDING ordering with NULLS FIRST is not supported!"); + } + } + if (call.getKind() == SqlKind.NULLS_LAST) { + SqlNode op0 = call.getOperandList().get(0); + if (op0.getKind() != SqlKind.DESCENDING) { + throw InvalidSqlInput.exception("ASCENDING ordering with NULLS LAST is not supported!"); + } + } + + super.validateCall(call, scope); + } } diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/planner/convertlet/DruidConvertletTable.java b/sql/src/main/java/org/apache/druid/sql/calcite/planner/convertlet/DruidConvertletTable.java index 59ad4ef24f05..eadd2e48268d 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/planner/convertlet/DruidConvertletTable.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/planner/convertlet/DruidConvertletTable.java @@ -67,6 +67,9 @@ public class DruidConvertletTable implements SqlRexConvertletTable .add(SqlStdOperatorTable.NULLIF) .add(SqlStdOperatorTable.COALESCE) .add(SqlLibraryOperators.NVL) + .add(SqlStdOperatorTable.DESC) + .add(SqlStdOperatorTable.NULLS_FIRST) + .add(SqlStdOperatorTable.NULLS_LAST) .build(); private final Map table; diff --git a/sql/src/test/java/org/apache/druid/sql/calcite/CalciteQueryTest.java b/sql/src/test/java/org/apache/druid/sql/calcite/CalciteQueryTest.java index 08fdbc3bfaa0..6f09e6372732 100644 --- a/sql/src/test/java/org/apache/druid/sql/calcite/CalciteQueryTest.java +++ b/sql/src/test/java/org/apache/druid/sql/calcite/CalciteQueryTest.java @@ -137,6 +137,9 @@ import java.util.Map; import java.util.stream.Collectors; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + public class CalciteQueryTest extends BaseCalciteQueryTest { @Test @@ -14247,4 +14250,24 @@ public void testLatestByOnStringColumnWithoutMaxBytesSpecified() new Object[] {"abc", defaultString, "def", defaultString, "def", defaultString} )); } + + @Test + public void testUnSupportedNullsFirst() + { + DruidException e = assertThrows(DruidException.class, () -> testBuilder() + .queryContext(ImmutableMap.of(PlannerContext.CTX_ENABLE_WINDOW_FNS, true)) + .sql("SELECT dim1,ROW_NUMBER() OVER (ORDER BY dim1 DESC NULLS FIRST) from druid.foo") + .run()); + assertEquals("DESCENDING ordering with NULLS FIRST is not supported!", e.getMessage()); + } + + @Test + public void testUnSupportedNullsLast() + { + DruidException e = assertThrows(DruidException.class, () -> testBuilder() + .queryContext(ImmutableMap.of(PlannerContext.CTX_ENABLE_WINDOW_FNS, true)) + .sql("SELECT dim1,ROW_NUMBER() OVER (ORDER BY dim1 NULLS LAST) from druid.foo") + .run()); + assertEquals("ASCENDING ordering with NULLS LAST is not supported!", e.getMessage()); + } } 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 969b59b5037e..b068c55c8e59 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 @@ -450,7 +450,8 @@ private static Object parseLongValue(final String val) } try { LocalTime v = LocalTime.parse(val); - return v.getMillisOfDay(); + Long l = (long) v.getMillisOfDay(); + return l; } catch (Exception e) { } @@ -4385,7 +4386,7 @@ public void test_nestedAggs_nstdWinView01() windowQueryTest(); } - @NotYetSupported(Modes.MISSING_DESC) + @NotYetSupported(Modes.NULLS_FIRST_LAST) @DrillTest("aggregates/winFnQry_63") @Test public void test_aggregates_winFnQry_63() @@ -4393,7 +4394,7 @@ public void test_aggregates_winFnQry_63() windowQueryTest(); } - @NotYetSupported(Modes.MISSING_DESC) + @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("aggregates/winFnQry_83") @Test public void test_aggregates_winFnQry_83() @@ -4401,7 +4402,7 @@ public void test_aggregates_winFnQry_83() windowQueryTest(); } - @NotYetSupported(Modes.MISSING_DESC) + @NotYetSupported(Modes.NULLS_FIRST_LAST) @DrillTest("frameclause/multipl_wnwds/mulwind_01") @Test public void test_frameclause_multipl_wnwds_mulwind_01() @@ -4409,7 +4410,7 @@ public void test_frameclause_multipl_wnwds_mulwind_01() windowQueryTest(); } - @NotYetSupported(Modes.MISSING_DESC) + @NotYetSupported(Modes.NULLS_FIRST_LAST) @DrillTest("frameclause/multipl_wnwds/mulwind_06") @Test public void test_frameclause_multipl_wnwds_mulwind_06() @@ -4417,7 +4418,7 @@ public void test_frameclause_multipl_wnwds_mulwind_06() windowQueryTest(); } - @NotYetSupported(Modes.MISSING_DESC) + @NotYetSupported(Modes.NULLS_FIRST_LAST) @DrillTest("frameclause/multipl_wnwds/mulwind_07") @Test public void test_frameclause_multipl_wnwds_mulwind_07() @@ -4425,7 +4426,6 @@ public void test_frameclause_multipl_wnwds_mulwind_07() windowQueryTest(); } - @NotYetSupported(Modes.MISSING_DESC) @DrillTest("lag_func/lag_Fn_108") @Test public void test_lag_func_lag_Fn_108() @@ -4433,7 +4433,6 @@ public void test_lag_func_lag_Fn_108() windowQueryTest(); } - @NotYetSupported(Modes.MISSING_DESC) @DrillTest("lag_func/lag_Fn_109") @Test public void test_lag_func_lag_Fn_109() @@ -4441,7 +4440,6 @@ public void test_lag_func_lag_Fn_109() windowQueryTest(); } - @NotYetSupported(Modes.MISSING_DESC) @DrillTest("lag_func/lag_Fn_69") @Test public void test_lag_func_lag_Fn_69() @@ -4449,7 +4447,6 @@ public void test_lag_func_lag_Fn_69() windowQueryTest(); } - @NotYetSupported(Modes.MISSING_DESC) @DrillTest("lead_func/lead_Fn_103") @Test public void test_lead_func_lead_Fn_103() @@ -4457,7 +4454,6 @@ public void test_lead_func_lead_Fn_103() windowQueryTest(); } - @NotYetSupported(Modes.MISSING_DESC) @DrillTest("lead_func/lead_Fn_104") @Test public void test_lead_func_lead_Fn_104() @@ -4465,7 +4461,6 @@ public void test_lead_func_lead_Fn_104() windowQueryTest(); } - @NotYetSupported(Modes.MISSING_DESC) @DrillTest("lead_func/lead_Fn_69") @Test public void test_lead_func_lead_Fn_69() @@ -4473,7 +4468,7 @@ public void test_lead_func_lead_Fn_69() windowQueryTest(); } - @NotYetSupported(Modes.MISSING_DESC) + @NotYetSupported(Modes.NULLS_FIRST_LAST) @DrillTest("nestedAggs/multiWin_7") @Test public void test_nestedAggs_multiWin_7() @@ -4993,7 +4988,7 @@ public void test_aggregates_winFnQry_7() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) + @NotYetSupported(Modes.RESULT_COUNT_MISMATCH) @DrillTest("aggregates/testW_Nulls_10") @Test public void test_aggregates_testW_Nulls_10() @@ -5001,7 +4996,7 @@ public void test_aggregates_testW_Nulls_10() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) + @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("aggregates/testW_Nulls_11") @Test public void test_aggregates_testW_Nulls_11() @@ -5153,7 +5148,7 @@ public void test_aggregates_testW_Nulls_29() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) + @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("aggregates/testW_Nulls_2") @Test public void test_aggregates_testW_Nulls_2() @@ -5241,7 +5236,7 @@ public void test_aggregates_testW_Nulls_39() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) + @NotYetSupported(Modes.RESULT_COUNT_MISMATCH) @DrillTest("aggregates/testW_Nulls_3") @Test public void test_aggregates_testW_Nulls_3() @@ -5249,7 +5244,7 @@ public void test_aggregates_testW_Nulls_3() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) + @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("aggregates/testW_Nulls_4") @Test public void test_aggregates_testW_Nulls_4() @@ -5257,7 +5252,7 @@ public void test_aggregates_testW_Nulls_4() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) + @NotYetSupported(Modes.COLUMN_NOT_FOUND) @DrillTest("aggregates/testW_Nulls_5") @Test public void test_aggregates_testW_Nulls_5() @@ -5265,7 +5260,7 @@ public void test_aggregates_testW_Nulls_5() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) + @NotYetSupported(Modes.COLUMN_NOT_FOUND) @DrillTest("aggregates/testW_Nulls_6") @Test public void test_aggregates_testW_Nulls_6() @@ -5273,7 +5268,7 @@ public void test_aggregates_testW_Nulls_6() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) + @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("aggregates/testW_Nulls_7") @Test public void test_aggregates_testW_Nulls_7() @@ -5281,7 +5276,6 @@ public void test_aggregates_testW_Nulls_7() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) @DrillTest("aggregates/testW_Nulls_8") @Test public void test_aggregates_testW_Nulls_8() @@ -5289,7 +5283,7 @@ public void test_aggregates_testW_Nulls_8() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) + @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("aggregates/testW_Nulls_9") @Test public void test_aggregates_testW_Nulls_9() @@ -5297,7 +5291,7 @@ public void test_aggregates_testW_Nulls_9() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) + @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("aggregates/winFnQry_61") @Test public void test_aggregates_winFnQry_61() @@ -5305,7 +5299,7 @@ public void test_aggregates_winFnQry_61() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) + @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("aggregates/winFnQry_62") @Test public void test_aggregates_winFnQry_62() @@ -5313,7 +5307,7 @@ public void test_aggregates_winFnQry_62() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) + @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("aggregates/winFnQry_64") @Test public void test_aggregates_winFnQry_64() @@ -5321,7 +5315,7 @@ public void test_aggregates_winFnQry_64() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) + @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("aggregates/winFnQry_65") @Test public void test_aggregates_winFnQry_65() @@ -5409,7 +5403,7 @@ public void test_aggregates_winFnQry_75() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) + @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("aggregates/winFnQry_76") @Test public void test_aggregates_winFnQry_76() @@ -5417,7 +5411,7 @@ public void test_aggregates_winFnQry_76() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) + @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("aggregates/winFnQry_77") @Test public void test_aggregates_winFnQry_77() @@ -5425,7 +5419,7 @@ public void test_aggregates_winFnQry_77() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) + @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("aggregates/winFnQry_78") @Test public void test_aggregates_winFnQry_78() @@ -5433,7 +5427,7 @@ public void test_aggregates_winFnQry_78() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) + @NotYetSupported(Modes.RESULT_COUNT_MISMATCH) @DrillTest("aggregates/winFnQry_79") @Test public void test_aggregates_winFnQry_79() @@ -5441,7 +5435,7 @@ public void test_aggregates_winFnQry_79() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) + @NotYetSupported(Modes.RESULT_COUNT_MISMATCH) @DrillTest("aggregates/winFnQry_80") @Test public void test_aggregates_winFnQry_80() @@ -5449,7 +5443,7 @@ public void test_aggregates_winFnQry_80() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) + @NotYetSupported(Modes.RESULT_COUNT_MISMATCH) @DrillTest("aggregates/winFnQry_81") @Test public void test_aggregates_winFnQry_81() @@ -5457,7 +5451,7 @@ public void test_aggregates_winFnQry_81() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) + @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("aggregates/winFnQry_82") @Test public void test_aggregates_winFnQry_82() @@ -5465,7 +5459,6 @@ public void test_aggregates_winFnQry_82() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) @DrillTest("lag_func/lag_Fn_10") @Test public void test_lag_func_lag_Fn_10() @@ -5473,7 +5466,6 @@ public void test_lag_func_lag_Fn_10() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) @DrillTest("lag_func/lag_Fn_11") @Test public void test_lag_func_lag_Fn_11() @@ -5481,7 +5473,6 @@ public void test_lag_func_lag_Fn_11() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) @DrillTest("lag_func/lag_Fn_12") @Test public void test_lag_func_lag_Fn_12() @@ -5489,7 +5480,6 @@ public void test_lag_func_lag_Fn_12() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) @DrillTest("lag_func/lag_Fn_13") @Test public void test_lag_func_lag_Fn_13() @@ -5497,7 +5487,6 @@ public void test_lag_func_lag_Fn_13() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) @DrillTest("lag_func/lag_Fn_14") @Test public void test_lag_func_lag_Fn_14() @@ -5505,7 +5494,7 @@ public void test_lag_func_lag_Fn_14() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) + @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("lag_func/lag_Fn_15") @Test public void test_lag_func_lag_Fn_15() @@ -5513,7 +5502,6 @@ public void test_lag_func_lag_Fn_15() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) @DrillTest("lag_func/lag_Fn_16") @Test public void test_lag_func_lag_Fn_16() @@ -5521,7 +5509,6 @@ public void test_lag_func_lag_Fn_16() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) @DrillTest("lag_func/lag_Fn_17") @Test public void test_lag_func_lag_Fn_17() @@ -5529,7 +5516,6 @@ public void test_lag_func_lag_Fn_17() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) @DrillTest("lag_func/lag_Fn_18") @Test public void test_lag_func_lag_Fn_18() @@ -5537,7 +5523,7 @@ public void test_lag_func_lag_Fn_18() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) + @NotYetSupported(Modes.UNSUPPORTED_NULL_ORDERING) @DrillTest("lag_func/lag_Fn_19") @Test public void test_lag_func_lag_Fn_19() @@ -5545,7 +5531,7 @@ public void test_lag_func_lag_Fn_19() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) + @NotYetSupported(Modes.UNSUPPORTED_NULL_ORDERING) @DrillTest("lag_func/lag_Fn_20") @Test public void test_lag_func_lag_Fn_20() @@ -5553,7 +5539,7 @@ public void test_lag_func_lag_Fn_20() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) + @NotYetSupported(Modes.UNSUPPORTED_NULL_ORDERING) @DrillTest("lag_func/lag_Fn_21") @Test public void test_lag_func_lag_Fn_21() @@ -5561,7 +5547,7 @@ public void test_lag_func_lag_Fn_21() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) + @NotYetSupported(Modes.UNSUPPORTED_NULL_ORDERING) @DrillTest("lag_func/lag_Fn_22") @Test public void test_lag_func_lag_Fn_22() @@ -5577,7 +5563,7 @@ public void test_lag_func_lag_Fn_23() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) + @NotYetSupported(Modes.UNSUPPORTED_NULL_ORDERING) @DrillTest("lag_func/lag_Fn_24") @Test public void test_lag_func_lag_Fn_24() @@ -5585,7 +5571,7 @@ public void test_lag_func_lag_Fn_24() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) + @NotYetSupported(Modes.UNSUPPORTED_NULL_ORDERING) @DrillTest("lag_func/lag_Fn_25") @Test public void test_lag_func_lag_Fn_25() @@ -5593,7 +5579,7 @@ public void test_lag_func_lag_Fn_25() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) + @NotYetSupported(Modes.UNSUPPORTED_NULL_ORDERING) @DrillTest("lag_func/lag_Fn_26") @Test public void test_lag_func_lag_Fn_26() @@ -5601,7 +5587,7 @@ public void test_lag_func_lag_Fn_26() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) + @NotYetSupported(Modes.UNSUPPORTED_NULL_ORDERING) @DrillTest("lag_func/lag_Fn_54") @Test public void test_lag_func_lag_Fn_54() @@ -5609,7 +5595,6 @@ public void test_lag_func_lag_Fn_54() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) @DrillTest("lag_func/lag_Fn_64") @Test public void test_lag_func_lag_Fn_64() @@ -5617,7 +5602,6 @@ public void test_lag_func_lag_Fn_64() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) @DrillTest("lag_func/lag_Fn_65") @Test public void test_lag_func_lag_Fn_65() @@ -5625,7 +5609,6 @@ public void test_lag_func_lag_Fn_65() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) @DrillTest("lag_func/lag_Fn_66") @Test public void test_lag_func_lag_Fn_66() @@ -5633,7 +5616,6 @@ public void test_lag_func_lag_Fn_66() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) @DrillTest("lag_func/lag_Fn_67") @Test public void test_lag_func_lag_Fn_67() @@ -5641,7 +5623,7 @@ public void test_lag_func_lag_Fn_67() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) + @NotYetSupported(Modes.UNSUPPORTED_NULL_ORDERING) @DrillTest("lag_func/lag_Fn_68") @Test public void test_lag_func_lag_Fn_68() @@ -5649,7 +5631,6 @@ public void test_lag_func_lag_Fn_68() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) @DrillTest("lag_func/lag_Fn_71") @Test public void test_lag_func_lag_Fn_71() @@ -5657,7 +5638,7 @@ public void test_lag_func_lag_Fn_71() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) + @NotYetSupported(Modes.UNSUPPORTED_NULL_ORDERING) @DrillTest("lag_func/lag_Fn_72") @Test public void test_lag_func_lag_Fn_72() @@ -5665,7 +5646,6 @@ public void test_lag_func_lag_Fn_72() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) @DrillTest("lead_func/lead_Fn_10") @Test public void test_lead_func_lead_Fn_10() @@ -5673,7 +5653,6 @@ public void test_lead_func_lead_Fn_10() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) @DrillTest("lead_func/lead_Fn_11") @Test public void test_lead_func_lead_Fn_11() @@ -5681,7 +5660,6 @@ public void test_lead_func_lead_Fn_11() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) @DrillTest("lead_func/lead_Fn_12") @Test public void test_lead_func_lead_Fn_12() @@ -5689,7 +5667,6 @@ public void test_lead_func_lead_Fn_12() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) @DrillTest("lead_func/lead_Fn_13") @Test public void test_lead_func_lead_Fn_13() @@ -5697,7 +5674,6 @@ public void test_lead_func_lead_Fn_13() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) @DrillTest("lead_func/lead_Fn_14") @Test public void test_lead_func_lead_Fn_14() @@ -5705,7 +5681,7 @@ public void test_lead_func_lead_Fn_14() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) + @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("lead_func/lead_Fn_15") @Test public void test_lead_func_lead_Fn_15() @@ -5713,7 +5689,6 @@ public void test_lead_func_lead_Fn_15() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) @DrillTest("lead_func/lead_Fn_16") @Test public void test_lead_func_lead_Fn_16() @@ -5721,7 +5696,6 @@ public void test_lead_func_lead_Fn_16() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) @DrillTest("lead_func/lead_Fn_17") @Test public void test_lead_func_lead_Fn_17() @@ -5729,7 +5703,6 @@ public void test_lead_func_lead_Fn_17() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) @DrillTest("lead_func/lead_Fn_18") @Test public void test_lead_func_lead_Fn_18() @@ -5737,7 +5710,7 @@ public void test_lead_func_lead_Fn_18() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) + @NotYetSupported(Modes.UNSUPPORTED_NULL_ORDERING) @DrillTest("lead_func/lead_Fn_19") @Test public void test_lead_func_lead_Fn_19() @@ -5753,7 +5726,7 @@ public void test_lead_func_lead_Fn_20() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) + @NotYetSupported(Modes.UNSUPPORTED_NULL_ORDERING) @DrillTest("lead_func/lead_Fn_21") @Test public void test_lead_func_lead_Fn_21() @@ -5761,7 +5734,7 @@ public void test_lead_func_lead_Fn_21() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) + @NotYetSupported(Modes.UNSUPPORTED_NULL_ORDERING) @DrillTest("lead_func/lead_Fn_22") @Test public void test_lead_func_lead_Fn_22() @@ -5793,7 +5766,6 @@ public void test_lead_func_lead_Fn_25() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) @DrillTest("lead_func/lead_Fn_64") @Test public void test_lead_func_lead_Fn_64() @@ -5801,7 +5773,6 @@ public void test_lead_func_lead_Fn_64() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) @DrillTest("lead_func/lead_Fn_65") @Test public void test_lead_func_lead_Fn_65() @@ -5809,7 +5780,6 @@ public void test_lead_func_lead_Fn_65() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) @DrillTest("lead_func/lead_Fn_66") @Test public void test_lead_func_lead_Fn_66() @@ -5817,7 +5787,6 @@ public void test_lead_func_lead_Fn_66() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) @DrillTest("lead_func/lead_Fn_67") @Test public void test_lead_func_lead_Fn_67() @@ -5825,7 +5794,7 @@ public void test_lead_func_lead_Fn_67() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) + @NotYetSupported(Modes.UNSUPPORTED_NULL_ORDERING) @DrillTest("lead_func/lead_Fn_68") @Test public void test_lead_func_lead_Fn_68() @@ -5833,7 +5802,6 @@ public void test_lead_func_lead_Fn_68() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) @DrillTest("lead_func/lead_Fn_71") @Test public void test_lead_func_lead_Fn_71() @@ -5841,7 +5809,7 @@ public void test_lead_func_lead_Fn_71() windowQueryTest(); } - @NotYetSupported(Modes.NULLS_FIRST_LAST) + @NotYetSupported(Modes.UNSUPPORTED_NULL_ORDERING) @DrillTest("lead_func/lead_Fn_72") @Test public void test_lead_func_lead_Fn_72() @@ -6463,7 +6431,6 @@ public void test_aggregates_winFnQry_8() windowQueryTest(); } - @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("aggregates/wo_OrdrBy_17") @Test public void test_aggregates_wo_OrdrBy_17() @@ -6471,7 +6438,6 @@ public void test_aggregates_wo_OrdrBy_17() windowQueryTest(); } - @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("aggregates/wo_OrdrBy_18") @Test public void test_aggregates_wo_OrdrBy_18() @@ -6479,7 +6445,6 @@ public void test_aggregates_wo_OrdrBy_18() windowQueryTest(); } - @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("aggregates/wo_OrdrBy_19") @Test public void test_aggregates_wo_OrdrBy_19() @@ -6487,7 +6452,6 @@ public void test_aggregates_wo_OrdrBy_19() windowQueryTest(); } - @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("aggregates/wo_OrdrBy_20") @Test public void test_aggregates_wo_OrdrBy_20() @@ -6495,7 +6459,6 @@ public void test_aggregates_wo_OrdrBy_20() windowQueryTest(); } - @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("aggregates/wo_OrdrBy_21") @Test public void test_aggregates_wo_OrdrBy_21() @@ -6679,7 +6642,6 @@ public void test_aggregates_woPrtnBy_9() windowQueryTest(); } - @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("first_val/firstValFn_17") @Test public void test_first_val_firstValFn_17() @@ -7597,7 +7559,6 @@ public void test_lead_func_lead_Fn_51() windowQueryTest(); } - @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("lead_func/lead_Fn_54") @Test public void test_lead_func_lead_Fn_54() @@ -7613,7 +7574,6 @@ public void test_lead_func_lead_Fn_60() windowQueryTest(); } - @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("lead_func/lead_Fn_63") @Test public void test_lead_func_lead_Fn_63() @@ -7637,7 +7597,6 @@ public void test_lead_func_lead_Fn_77() windowQueryTest(); } - @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("lead_func/lead_Fn_90") @Test public void test_lead_func_lead_Fn_90() @@ -7653,7 +7612,6 @@ public void test_lead_func_lead_Fn_96() windowQueryTest(); } - @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("lead_func/lead_Fn_9") @Test public void test_lead_func_lead_Fn_9() @@ -7669,7 +7627,6 @@ public void test_nestedAggs_basic_3() windowQueryTest(); } - @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("nestedAggs/basic_5") @Test public void test_nestedAggs_basic_5() @@ -7756,7 +7713,6 @@ public void test_nestedAggs_woutPrtnBy_5() windowQueryTest(); } - @NotYetSupported(Modes.RESULT_MISMATCH) @DrillTest("ntile_func/ntileFn_15") @Test public void test_ntile_func_ntileFn_15() @@ -7932,7 +7888,6 @@ public void test_lag_func_lag_Fn_60() windowQueryTest(); } - @NotYetSupported(Modes.T_ALLTYPES_ISSUES) @DrillTest("lag_func/lag_Fn_77") @Test public void test_lag_func_lag_Fn_77() @@ -7940,7 +7895,6 @@ public void test_lag_func_lag_Fn_77() windowQueryTest(); } - @NotYetSupported(Modes.T_ALLTYPES_ISSUES) @DrillTest("lag_func/lag_Fn_95") @Test public void test_lag_func_lag_Fn_95() diff --git a/sql/src/test/java/org/apache/druid/sql/calcite/NotYetSupported.java b/sql/src/test/java/org/apache/druid/sql/calcite/NotYetSupported.java index 32364f6a8b19..933359e96bf6 100644 --- a/sql/src/test/java/org/apache/druid/sql/calcite/NotYetSupported.java +++ b/sql/src/test/java/org/apache/druid/sql/calcite/NotYetSupported.java @@ -88,7 +88,8 @@ enum Modes INCORRECT_SYNTAX(DruidException.class, "Incorrect syntax near the keyword"), // at least c7 is represented oddly in the parquet file T_ALLTYPES_ISSUES(AssertionError.class, "(t_alltype|allTypsUniq|fewRowsAllData).parquet.*Verifier.verify"), - RESULT_MISMATCH(AssertionError.class, "assertResultsEquals"); + RESULT_MISMATCH(AssertionError.class, "assertResultsEquals"), + UNSUPPORTED_NULL_ORDERING(DruidException.class, "(A|DE)SCENDING ordering with NULLS (LAST|FIRST)"); public Class throwableClass; public String regex; diff --git a/sql/src/test/resources/calcite/tests/window/orderByDescNulls.sqlTest b/sql/src/test/resources/calcite/tests/window/orderByDescNulls.sqlTest new file mode 100644 index 000000000000..320b448c7488 --- /dev/null +++ b/sql/src/test/resources/calcite/tests/window/orderByDescNulls.sqlTest @@ -0,0 +1,45 @@ +type: "operatorValidation" + +sql: | + SELECT + cityName, + __time, + ROW_NUMBER() OVER (ORDER BY cityName desc nulls last, __time ) windowedDelta, + ROW_NUMBER() OVER (ORDER BY cityName nulls first, __time ) windowedDelta + FROM wikipedia + where page < '0' and channel like '#en%' + +expectedOperators: + - type: "naiveSort" + columns: + - column: "cityName" + direction: "DESC" + - column: "__time" + direction: "ASC" + - type: "naivePartition" + partitionColumns: [ ] + - type: "window" + processor: + type: "rowNumber" + outputColumn: "w0" + - type: "naiveSort" + columns: + - column: "cityName" + direction: "ASC" + - column: "__time" + direction: "ASC" + - type: "naivePartition" + partitionColumns: [ ] + - type: "window" + processor: + type: "rowNumber" + outputColumn: "w1" +expectedResults: + - [null,1442019358364,3,1] + - [null,1442021099146,4,2] + - [null,1442033539153,5,3] + - [null,1442095704125,6,4] + - [null,1442096110867,7,5] + - [null,1442100368226,8,6] + - ["Crescent City",1442035449448,2,7] + - ["Vinnytsya",1442100940306,1,8]