maropu commented on a change in pull request #27495: [SPARK-28880][SQL] Support 
ANSI nested bracketed comments
URL: https://github.com/apache/spark/pull/27495#discussion_r376700666
 
 

 ##########
 File path: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/PlanParserSuite.scala
 ##########
 @@ -55,6 +55,54 @@ class PlanParserSuite extends AnalysisTest {
     With(plan, ctes)
   }
 
+  test("single comment") {
+    val plan = table("a").select(star())
+    assertEqual("-- single comment\nSELECT * FROM a", plan)
+  }
+
+  test("bracketed comment case one") {
+    val plan = table("a").select(star())
+    assertEqual("/* This is an example of SQL which should not execute:\n" +
+      " * select 'multi-line';\n" +
+      " */\n" +
+      "SELECT * FROM a", plan)
+  }
+
+  test("bracketed comment case two") {
+    val plan = table("a").select(star())
+    assertEqual("/*\n" +
+      "SELECT 'trailing' as x1; -- inside block comment\n" +
+      "*/\n" +
+      "SELECT * FROM a", plan)
+  }
+
+  test("nexted bracketed comment case one") {
+    val plan = table("a").select(star())
+    assertEqual("/* This block comment surrounds a query which itself has a 
block comment...\n" +
+      "SELECT /* embedded single line */ 'embedded' AS x2;\n" +
+      "*/\n" +
+      "SELECT * FROM a", plan)
+  }
+
+  test("nexted bracketed comment case two") {
+    val plan = table("a").select(star())
+    assertEqual("SELECT -- continued after the following block comments...\n" +
+      "/* Deeply nested comment.\n" +
+      "   This includes a single apostrophe to make sure we aren't decoding 
this part as a " +
+      "string.\n" +
+      "SELECT 'deep nest' AS n1;\n" +
+      "/* Second level of nesting...\n" +
+      "SELECT 'deeper nest' as n2;\n" +
+      "/* Third level of nesting...\n" +
+      "SELECT 'deepest nest' as n3;\n" +
+      "*/\n" +
+      "Hoo boy. Still two deep...\n" +
+      "*/\n" +
+      "Now just one deep...\n" +
+      "*/\n" +
+      "* FROM a", plan)
+  }
 
 Review comment:
   I probably miss something though, why does not this change affect 
`postgreSQL/comments.sql.out`? It seems they have nested bracketed comments.
   
   > Is it enough with 
sql/core/src/test/resources/sql-tests/inputs/postgreSQL/comments.sql ?
   
   They are regression tests just ported from the pgSQL codebase to check 
behaviour differences beteween Spark/PostgreSQL. So, to check new behaviours 
implemented by this pr, I think its ok to put some basic end-to-end tests in 
`sql-tests/inputs/comments.sql`.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

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

Reply via email to