You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by "snuyanzin (via GitHub)" <gi...@apache.org> on 2026/04/19 11:06:09 UTC
[PR] [CALCITE-7480] Unparse of `MATCH_RECOGNIZE` with `PARTITION BY` or `ORDER BY` produces invalid SQL [calcite]
snuyanzin opened a new pull request, #4894:
URL: https://github.com/apache/calcite/pull/4894
## Jira Link
[CALCITE-7480](https://issues.apache.org/jira/browse/CALCITE-7480)
## Changes Proposed
The problem the PR is going to fix is invalid output SQL after unparsing of `MATCH_RECOGNIZE` with `ORDER BY` or `PARTITION BY`
example
```sql
SELECT *
FROM (SELECT empno, deptno from sales.emp)
MATCH_RECOGNIZE (
PARTITION BY empno
ORDER BY deptno
MEASURES
FINAL COUNT(A.deptno) AS deptno
PATTERN (A B)
DEFINE
A AS A.empno = 123
)
```
is being unparsed as
```sql
SELECT `T`.`EMPNO`, `T`.`DEPTNO`
FROM `CATALOG`.`SALES`.`EMP` AS `EMP_ALIAS` MATCH_RECOGNIZE(
PARTITION BY `*`.`EMPNO`
ORDER BY `*`.`DEPTNO`
MEASURES FINAL COUNT(`A`.`DEPTNO`) AS `DEPTNO`
PATTERN (`A` `B`)
DEFINE `A` AS PREV(`A`.`EMPNO`, 0) = 123) AS `T`
```
where
```sql
PARTITION BY `*`.`EMPNO`
ORDER BY `*`.`DEPTNO`
```
is not parsable anymore
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-7480] Unparse of `MATCH_RECOGNIZE` with `PARTITION BY` or `ORDER BY` produces invalid SQL [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4894:
URL: https://github.com/apache/calcite/pull/4894#discussion_r3107353171
##########
core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java:
##########
@@ -2600,6 +2600,59 @@ void testLikeAndSimilarFails() {
sql(expected6)
.withParserConfig(c -> c.withQuoting(Quoting.BACK_TICK)).ok();
+
+ // Test cases for [CALCITE-7480] https://issues.apache.org/jira/browse/CALCITE-7480
Review Comment:
If some external database accepts these, it would be nice to say it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-7480] Unparse of `MATCH_RECOGNIZE` with `PARTITION BY` or `ORDER BY` produces invalid SQL [calcite]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin merged PR #4894:
URL: https://github.com/apache/calcite/pull/4894
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-7480] Unparse of `MATCH_RECOGNIZE` with `PARTITION BY` or `ORDER BY` produces invalid SQL [calcite]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4894:
URL: https://github.com/apache/calcite/pull/4894#issuecomment-4275790293
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4894) **Quality Gate passed**
Issues
 [0 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4894&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4894&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4894&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [91.7% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4894&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4894&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4894)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-7480] Unparse of `MATCH_RECOGNIZE` with `PARTITION BY` or `ORDER BY` produces invalid SQL [calcite]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #4894:
URL: https://github.com/apache/calcite/pull/4894#discussion_r3109227344
##########
core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java:
##########
@@ -2600,6 +2600,59 @@ void testLikeAndSimilarFails() {
sql(expected6)
.withParserConfig(c -> c.withQuoting(Quoting.BACK_TICK)).ok();
+
+ // Test cases for [CALCITE-7480] https://issues.apache.org/jira/browse/CALCITE-7480
Review Comment:
sure, added
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org