Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
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;
Expand Down Expand Up @@ -803,8 +804,14 @@ private static Expression toExpression(SqlNode node) {
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);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ public Object[][] queryProvider() {
{"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")}
};
}

Expand Down
Loading