SSC-EWI-0077

Cycle found between CTE calls. CTEs cannot be ordered.

Severity

Low

Description

This warning is added when a query that has several CTE (Common Table Expression) reference calls creates a cycle that cannot determine the calling order of the CTEs, and then the CTEs cannot be ordered and the query will remain as the source.

Example Code

Input Code (Teradata):

IN -> Teradata_01.sql
WITH t1(c1) as (SELECT c1 FROM t2),
     t2(c2) as (SELECT c2 FROM t3),
     RECURSIVE t3(c3) as (SELECT c3, someOtherColumn FROM t1, t3)
     SELECT * FROM t1;

Output Code:

OUT -> Teradata_01.sql
!!!RESOLVE EWI!!! /*** SSC-EWI-0077 - CYCLE FOUND BETWEEN CTE REFERENCE CALLS, CTES CANNOT BE ORDERED AND THE QUERY WILL REMAIN AS ORIGINAL ***/!!!
WITH RECURSIVE t1(c1) AS
(
     SELECT
          c1 FROM t2
),
t2(c2) AS
(
     SELECT
          c2 FROM t3
),
t3(c3) AS
(
     SELECT
          c3,
          someOtherColumn FROM t1, t3
)
SELECT
     * FROM t1;

Recommendations

Last updated