turboFei commented on a change in pull request #29982: URL: https://github.com/apache/spark/pull/29982#discussion_r551362824
########## File path: sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/CliSuite.scala ########## @@ -573,4 +573,28 @@ class CliSuite extends SparkFunSuite with BeforeAndAfterAll with Logging { // the date formatter for `java.sql.LocalDate` must output negative years with sign. runCliWithin(1.minute)("SELECT MAKE_DATE(-44, 3, 15);" -> "-0044-03-15") } + + test("SPARK-33100: Ignore a semicolon inside a bracketed comment in spark-sql") { + runCliWithin(1.minute)("/* SELECT 'test';*/ SELECT 'test';" -> "test") + runCliWithin(1.minute)(";;/* SELECT 'test';*/ SELECT 'test';" -> "test") + runCliWithin(1.minute)("/* SELECT 'test';*/;; SELECT 'test';" -> "test") + runCliWithin(1.minute)("SELECT 'test'; -- SELECT 'test';" -> "") + runCliWithin(1.minute)("SELECT 'test'; /* SELECT 'test';*/" -> "") + runCliWithin(1.minute)("/*$meta chars{^\\;}*/ SELECT 'test';" -> "test") + runCliWithin(1.minute)("/*\nmulti-line\n*/ SELECT 'test';" -> "test") + runCliWithin(1.minute)("/*/* multi-level bracketed*/ SELECT 'test';" -> "test") + } + + test("SPARK-33100: test sql statements with hint in bracketed comment") { + runCliWithin(2.minute)( + "CREATE TEMPORARY VIEW t1 AS SELECT * FROM VALUES(1, 2) AS t1(k, v);" + -> "", + "CREATE TEMPORARY VIEW t2 AS SELECT * FROM VALUES(2, 1) AS t2(k, v);" + -> "", + "EXPLAIN SELECT /*+ MERGEJOIN(t1) */ t1.* FROM t1 JOIN t2 ON t1.k = t2.v;" + -> "SortMergeJoin", + "EXPLAIN SELECT /* + MERGEJOIN(t1) */ t1.* FROM t1 JOIN t2 ON t1.k = t2.v;" + -> "BroadcastHashJoin" Review comment: no, the ; in /* + MERGEJOIN(t1); */ in will be ignored means that the `;` would be treated as a delimiter, which used to split sql statements. `EXPLAIN SELECT /*+ MERGEJOIN(t1); */ t1.* FROM t1 JOIN t2 ON t1.k = t2.v` would be transfered to SparkSQLCliDriver totally. ---------------------------------------------------------------- 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: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org