cloud-fan commented on code in PR #53407:
URL: https://github.com/apache/spark/pull/53407#discussion_r2627685324


##########
sql/core/src/test/resources/sql-tests/inputs/identifier-clause.sql:
##########
@@ -367,6 +367,62 @@ SELECT * FROM unpivot_test UNPIVOT (val FOR col IN (a AS 
IDENTIFIER('col_a'), b
 SELECT * FROM unpivot_test UNPIVOT ((v1, v2) FOR col IN ((a, b) AS 
IDENTIFIER('cols_ab'), (b, c) AS IDENTIFIER('cols_bc'))) ORDER BY ALL;
 DROP TABLE unpivot_test;
 
+-- UNPIVOT result table alias with IDENTIFIER()
+CREATE TABLE unpivot_alias_test(id INT, a INT, b INT) USING CSV;
+INSERT INTO unpivot_alias_test VALUES (1, 10, 20);
+SELECT * FROM unpivot_alias_test UNPIVOT (val FOR col IN (a, b)) AS 
IDENTIFIER('unpivoted_result') ORDER BY ALL;
+DROP TABLE unpivot_alias_test;
+
+-- PIVOT with IDENTIFIER() for pivot column and value aliases
+CREATE TABLE pivot_test(product STRING, quarter STRING, revenue INT) USING CSV;
+INSERT INTO pivot_test VALUES ('A', 'Q1', 100), ('A', 'Q2', 150), ('B', 'Q1', 
200), ('B', 'Q2', 250);
+-- PIVOT column with IDENTIFIER()
+SELECT * FROM pivot_test PIVOT (SUM(revenue) FOR IDENTIFIER('quarter') IN 
('Q1', 'Q2')) ORDER BY product;
+-- PIVOT value alias with IDENTIFIER()
+SELECT * FROM pivot_test PIVOT (SUM(revenue) AS IDENTIFIER('total') FOR 
quarter IN ('Q1' AS IDENTIFIER('first_quarter'), 'Q2' AS 
IDENTIFIER('second_quarter'))) ORDER BY product;
+DROP TABLE pivot_test;
+
+-- Lambda variable names with IDENTIFIER()
+-- Note: Lambda variable binding with IDENTIFIER() has limitations - the 
variable declaration
+-- and usage are resolved independently, so using IDENTIFIER() for both 
doesn't work as expected.
+-- This test verifies the parsing works, but the semantic resolution is a 
known limitation.
+SELECT transform(array(1, 2, 3), IDENTIFIER('x') -> x + 1);
+
+-- Note: INDEX tests are skipped because CreateIndex/DropIndex operations

Review Comment:
   This makes me think that we should move most of the tests here to a scala 
parser test suite. We need golden file test for basic end-to-end use cases, but 
most detailed tests should go to scala parser test suite for better efficiency 
and easy of review.
   
   Can we follow `ShowColumnsParserSuite` and add a new 
`IdentifierClauseParserSuite`?



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