This is an automated email from the ASF dual-hosted git repository.

kgyrtkirk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/druid.git


The following commit(s) were added to refs/heads/master by this push:
     new 6bbf9613f89 Throw soft exception in case of empty signature while 
building Scan Query (#16502)
6bbf9613f89 is described below

commit 6bbf9613f894aebea36faac7adbff3a0d9a83045
Author: Sree Charan Manamala <[email protected]>
AuthorDate: Wed May 29 13:11:54 2024 +0530

    Throw soft exception in case of empty signature while building Scan Query 
(#16502)
---
 .../apache/druid/sql/calcite/rel/DruidQuery.java   |  3 +-
 .../druid/sql/calcite/CalciteWindowQueryTest.java  | 52 ++++++++++++++++------
 2 files changed, 41 insertions(+), 14 deletions(-)

diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/rel/DruidQuery.java 
b/sql/src/main/java/org/apache/druid/sql/calcite/rel/DruidQuery.java
index 691e9518659..5bcec39a1e8 100644
--- a/sql/src/main/java/org/apache/druid/sql/calcite/rel/DruidQuery.java
+++ b/sql/src/main/java/org/apache/druid/sql/calcite/rel/DruidQuery.java
@@ -1602,7 +1602,8 @@ public class DruidQuery
 
     if (outputRowSignature.size() == 0) {
       // Should never do a scan query without any columns that we're 
interested in. This is probably a planner bug.
-      throw new ISE("Cannot convert to Scan query without any columns.");
+      this.plannerContext.setPlanningError("Cannot convert to Scan query 
without any columns.");
+      return null;
     }
 
     final Pair<DataSource, Filtration> dataSourceFiltrationPair = 
getFiltration(
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 16706335515..f5e161b3a6a 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
@@ -233,23 +233,49 @@ public class CalciteWindowQueryTest extends 
BaseCalciteQueryTest
     }
   }
 
+  @Test
+  public void testEmptyWindowInSubquery()
+  {
+    testBuilder()
+        .sql(
+            "select c from (\n"
+            + "  select channel, row_number() over () as c\n"
+            + "  from wikipedia\n"
+            + "  group by channel\n"
+            + ") LIMIT 5"
+        )
+        .queryContext(ImmutableMap.of(
+            PlannerContext.CTX_ENABLE_WINDOW_FNS, true,
+            QueryContexts.ENABLE_DEBUG, true,
+            QueryContexts.WINDOWING_STRICT_VALIDATION, false
+        ))
+        .expectedResults(ImmutableList.of(
+            new Object[]{1L},
+            new Object[]{2L},
+            new Object[]{3L},
+            new Object[]{4L},
+            new Object[]{5L}
+        ))
+        .run();
+  }
+
   @Test
   public void testWindow()
   {
     testBuilder()
-            .sql("SELECT\n" +
-                    "(rank() over (order by count(*) desc)),\n" +
-                    "(rank() over (order by count(*) desc))\n" +
-                    "FROM \"wikipedia\"")
-            .queryContext(ImmutableMap.of(
-                    PlannerContext.CTX_ENABLE_WINDOW_FNS, true,
-                    QueryContexts.ENABLE_DEBUG, true,
-                    QueryContexts.WINDOWING_STRICT_VALIDATION, false
-            ))
-            .expectedResults(ImmutableList.of(
-                    new Object[]{1L, 1L}
-            ))
-            .run();
+        .sql("SELECT\n" +
+             "(rank() over (order by count(*) desc)),\n" +
+             "(rank() over (order by count(*) desc))\n" +
+             "FROM \"wikipedia\"")
+        .queryContext(ImmutableMap.of(
+            PlannerContext.CTX_ENABLE_WINDOW_FNS, true,
+            QueryContexts.ENABLE_DEBUG, true,
+            QueryContexts.WINDOWING_STRICT_VALIDATION, false
+        ))
+        .expectedResults(ImmutableList.of(
+            new Object[]{1L, 1L}
+        ))
+        .run();
   }
 
   private WindowOperatorQuery getWindowOperatorQuery(List<Query<?>> queries)


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to