AngersZhuuuu commented on code in PR #44767:
URL: https://github.com/apache/spark/pull/44767#discussion_r1464219993


##########
sql/core/src/test/resources/sql-tests/inputs/cache.sql:
##########
@@ -0,0 +1,33 @@
+CREATE TEMPORARY VIEW t1 AS SELECT * FROM VALUES (0, 0), (1, 1), (2, 2) AS 
t(c1, c2);
+CREATE TEMPORARY VIEW t2 AS
+WITH v as (
+  SELECT c1 + c1 c3 FROM t1
+)
+SELECT SUM(c3) s FROM v;
+
+CACHE TABLE cache_table
+WITH
+t2 AS (SELECT 1)
+SELECT * FROM t2;
+
+SELECT * FROM cache_table;
+
+EXPLAIN EXTENDED SELECT * FROM cache_table;
+
+-- Nested WithCTE

Review Comment:
   > hmm, why does it have nested CTE?
   
   If there is CTE in view, and query with CTE, will have two WithCTE
   
   <img width="1003" alt="截屏2024-01-24 10 21 50" 
src="https://github.com/apache/spark/assets/46485123/0b5c60ea-0f7c-408c-bd42-d6107afb9f32";>
   
   
   Current code with handle each WithCTE by starting cteId from 0.
   Since the origin cteId is non-repeating,  I think the current code is safe.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to