This is an automated email from the ASF dual-hosted git repository.
yashmayya pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push:
new f2c715a9373 Fix table name parsing for window queries (#18616)
f2c715a9373 is described below
commit f2c715a93736584c2d42622831afd26b0dfb3e21
Author: Cc <[email protected]>
AuthorDate: Mon Jun 1 06:53:30 2026 +0800
Fix table name parsing for window queries (#18616)
Co-authored-by: wolfkill <[email protected]>
---
.../main/java/org/apache/pinot/sql/parsers/CalciteSqlParser.java | 9 ++++++++-
.../org/apache/pinot/common/utils/request/RequestUtilsTest.java | 5 ++++-
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git
a/pinot-common/src/main/java/org/apache/pinot/sql/parsers/CalciteSqlParser.java
b/pinot-common/src/main/java/org/apache/pinot/sql/parsers/CalciteSqlParser.java
index 544384660f9..d3eb407480d 100644
---
a/pinot-common/src/main/java/org/apache/pinot/sql/parsers/CalciteSqlParser.java
+++
b/pinot-common/src/main/java/org/apache/pinot/sql/parsers/CalciteSqlParser.java
@@ -46,6 +46,7 @@ import org.apache.calcite.sql.SqlOrderBy;
import org.apache.calcite.sql.SqlSelect;
import org.apache.calcite.sql.SqlSelectKeyword;
import org.apache.calcite.sql.SqlSetOption;
+import org.apache.calcite.sql.SqlWindow;
import org.apache.calcite.sql.fun.SqlBetweenOperator;
import org.apache.calcite.sql.fun.SqlCase;
import org.apache.calcite.sql.fun.SqlLikeOperator;
@@ -813,8 +814,14 @@ public class CalciteSqlParser {
if (node instanceof SqlDataTypeSpec) {
// This is to handle expression like: CAST(col AS INT)
return RequestUtils.getLiteralExpression(((SqlDataTypeSpec)
node).getTypeName().getSimple());
- } else {
+ } else if (node instanceof SqlWindow) {
+ // Window definitions appear as operands of OVER calls. PinotQuery
does not model window frames directly, but
+ // compiling them as literals keeps parsing/table-name extraction
from failing on multi-stage window queries.
+ return RequestUtils.getLiteralExpression(node.toString());
+ } else if (node instanceof SqlBasicCall) {
return compileFunctionExpression((SqlBasicCall) node);
+ } else {
+ throw new SqlCompilationException("Unsupported sql node - " + node);
}
}
}
diff --git
a/pinot-common/src/test/java/org/apache/pinot/common/utils/request/RequestUtilsTest.java
b/pinot-common/src/test/java/org/apache/pinot/common/utils/request/RequestUtilsTest.java
index d3a41aaf9da..f2724289cb4 100644
---
a/pinot-common/src/test/java/org/apache/pinot/common/utils/request/RequestUtilsTest.java
+++
b/pinot-common/src/test/java/org/apache/pinot/common/utils/request/RequestUtilsTest.java
@@ -74,7 +74,10 @@ public class RequestUtilsTest {
{"select foo from countries where bar > 1", Set.of("countries")},
{"select 1", null},
{"SET useMultiStageEngine=true; SELECT table1.foo, table2.bar FROM "
- + "table1 JOIN table2 ON table1.id = table2.id LIMIT 10;",
Set.of("table1", "table2")}
+ + "table1 JOIN table2 ON table1.id = table2.id LIMIT 10;",
Set.of("table1", "table2")},
+ {"SET useMultiStageEngine=true; SELECT foo, occurredAt, "
+ + "LAG(occurredAt) OVER (PARTITION BY foo ORDER BY occurredAt)
AS laggedAt FROM events",
+ Set.of("events")}
};
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]