Throw soft exception in case of empty signature while building Scan Query (#16502)

This commit is contained in:
Sree Charan Manamala 2024-05-29 13:11:54 +05:30 committed by GitHub
parent 27cfe12f4a
commit 6bbf9613f8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 41 additions and 14 deletions

View File

@ -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(

View File

@ -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)