This is an automated email from the ASF dual-hosted git repository.
rubenql pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/calcite.git
The following commit(s) were added to refs/heads/main by this push:
new 2176dfc27b [CALCITE-6682] Framing unsupported error message lacks
LAG/LEAD functions
2176dfc27b is described below
commit 2176dfc27b03858e4874b01d2203655e68536d3b
Author: Claude Brisson <[email protected]>
AuthorDate: Fri Nov 8 09:49:31 2024 +0100
[CALCITE-6682] Framing unsupported error message lacks LAG/LEAD functions
---
.../src/main/java/org/apache/calcite/runtime/CalciteResource.java | 2 +-
.../org/apache/calcite/runtime/CalciteResource.properties | 2 +-
core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java | 8 +++++++-
3 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/core/src/main/java/org/apache/calcite/runtime/CalciteResource.java
b/core/src/main/java/org/apache/calcite/runtime/CalciteResource.java
index adccdf563e..e35be6fee9 100644
--- a/core/src/main/java/org/apache/calcite/runtime/CalciteResource.java
+++ b/core/src/main/java/org/apache/calcite/runtime/CalciteResource.java
@@ -502,7 +502,7 @@ public interface CalciteResource {
@BaseMessage("QUALIFY expression ''{0}'' must contain a window function")
ExInst<SqlValidatorException>
qualifyExpressionMustContainWindowFunction(String a0);
- @BaseMessage("ROW/RANGE not allowed with RANK, DENSE_RANK, ROW_NUMBER or
PERCENTILE_CONT/DISC functions")
+ @BaseMessage("ROW/RANGE not allowed with RANK, DENSE_RANK, ROW_NUMBER,
PERCENTILE_CONT/DISC or LAG/LEAD functions")
ExInst<SqlValidatorException> rankWithFrame();
@BaseMessage("RANK or DENSE_RANK functions require ORDER BY clause in window
specification")
diff --git
a/core/src/main/resources/org/apache/calcite/runtime/CalciteResource.properties
b/core/src/main/resources/org/apache/calcite/runtime/CalciteResource.properties
index 264cf56a89..214acea201 100644
---
a/core/src/main/resources/org/apache/calcite/runtime/CalciteResource.properties
+++
b/core/src/main/resources/org/apache/calcite/runtime/CalciteResource.properties
@@ -171,7 +171,7 @@ DuplicateWindowName=Duplicate window names not allowed
EmptyWindowSpec=Empty window specification not allowed
DupWindowSpec=Duplicate window specification not allowed in the same window
clause
QualifyExpressionMustContainWindowFunction=QUALIFY expression ''{0}'' must
contain a window function
-RankWithFrame=ROW/RANGE not allowed with RANK, DENSE_RANK, ROW_NUMBER or
PERCENTILE_CONT/DISC functions
+RankWithFrame=ROW/RANGE not allowed with RANK, DENSE_RANK, ROW_NUMBER,
PERCENTILE_CONT/DISC or LAG/LEAD functions
FuncNeedsOrderBy=RANK or DENSE_RANK functions require ORDER BY clause in
window specification
PartitionNotAllowed=PARTITION BY not allowed with existing window reference
OrderByOverlap=ORDER BY not allowed in both base and referenced windows
diff --git a/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java
b/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java
index 75bd3498ad..94e26cdf00 100644
--- a/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java
+++ b/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java
@@ -158,7 +158,7 @@ public class SqlValidatorTest extends SqlValidatorTestCase {
"Set operator cannot combine streaming and non-streaming inputs";
private static final String ROW_RANGE_NOT_ALLOWED_WITH_RANK =
- "ROW/RANGE not allowed with RANK, DENSE_RANK, ROW_NUMBER or
PERCENTILE_CONT/DISC functions";
+ "ROW/RANGE not allowed with RANK, DENSE_RANK, ROW_NUMBER,
PERCENTILE_CONT/DISC or LAG/LEAD functions";
private static final String RANK_REQUIRES_ORDER_BY = "RANK or DENSE_RANK "
+ "functions require ORDER BY clause in window specification";
@@ -3082,6 +3082,12 @@ public class SqlValidatorTest extends
SqlValidatorTestCase {
winSql("select dense_rank() over w from emp\n"
+ "window w as (order by empno ^rows^ 2 preceding)")
.fails(ROW_RANGE_NOT_ALLOWED_WITH_RANK);
+ winSql("select lag(deptno,1) over w from emp\n"
+ + "window w as (order by empno ^rows^ 2 preceding)")
+ .fails(ROW_RANGE_NOT_ALLOWED_WITH_RANK);
+ winSql("select lead(deptno,1) over w from emp\n"
+ + "window w as (order by empno ^rows^ 2 preceding)")
+ .fails(ROW_RANGE_NOT_ALLOWED_WITH_RANK);
if (defined.contains("PERCENT_RANK")) {
winSql("select percent_rank() over w from emp\n"
+ "window w as (order by empno)")