HanumathRao commented on code in PR #3480: URL: https://github.com/apache/calcite/pull/3480#discussion_r1375334002
########## core/src/test/resources/sql/recursive_queries.iq: ########## @@ -0,0 +1,507 @@ +# recursive_queries.iq - recursive queries using WITH CTE +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to you under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +!use scott +!set outputformat mysql + +WITH RECURSIVE FactorialCTE(n, a) AS ( + SELECT 1, 1 + UNION ALL + SELECT n + 1, a * (n + 1) + FROM FactorialCTE + WHERE n < 11 +) +SELECT a FROM FactorialCTE WHERE n = 10; ++---------+ +| A | ++---------+ +| 3628800 | ++---------+ +(1 row) + +!ok + +WITH RECURSIVE FibonacciCTE(n, a, b) AS ( Review Comment: Thanks for asking this question. Yes, mutually recursive queries are valid as per SQL standard. However, this implementation doesn't support mutually recursive queries. In the latest commit, I have added a test case which reports an error (in SqlValidatorTest). I think it is better to track support for mutually recursive queries as a new functionality rather than clubbing it with the general recursive query support. WDYT? Please find the sqlfiddle [link](http://sqlfiddle.com/#!17/9eecb/111736) for postgres which reports an error for mutually recursive queries. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
