szehon-ho commented on code in PR #50571: URL: https://github.com/apache/spark/pull/50571#discussion_r2042624601
########## sql/core/src/test/scala/org/apache/spark/sql/execution/command/DDLSuite.scala: ########## @@ -1376,32 +1398,67 @@ abstract class DDLSuite extends QueryTest with DDLSuiteBase { } } - test("SPARK-51747: Data source cached plan should respect options") { - withTable("t") { - spark.sql("CREATE TABLE t(a string, b string) USING CSV".stripMargin) - spark.sql("INSERT INTO TABLE t VALUES ('a;b', 'c')") - spark.sql("INSERT INTO TABLE t VALUES ('hello; world', 'test')") + test("SPARK-51747: Data source cached plan respects options if ignore conf disabled") { + Seq("true", "false").foreach { ignoreOption => + withSQLConf(SQLConf.READ_FILE_SOURCE_TABLE_CACHE_IGNORE_OPTIONS.key -> ignoreOption) { + withNamespace("ns") { + withTable("t") { + spark.sql("CREATE TABLE t(a string, b string) USING CSV".stripMargin) + spark.sql("INSERT INTO TABLE t VALUES ('a;b', 'c')") + spark.sql("INSERT INTO TABLE t VALUES ('hello; world', 'test')") - // check initial contents of table - checkAnswer(spark.table("t"), Row("a;b", "c") :: Row("hello; world", "test") :: Nil) + // check initial contents of table + checkAnswer(spark.table("t"), Row("a;b", "c") :: Row("hello; world", "test") :: Nil) - // no option - checkAnswer( - spark.sql("SELECT * FROM t"), - Row("a;b", "c") :: Row("hello; world", "test") :: Nil - ) + val shouldIgnoreOption = ignoreOption == "true" + // If shouldIgnoreOption conf set to true, then the result is always with no options + val resultNoOptions = Row("a;b", "c") :: Row("hello; world", "test") :: Nil - // respect delimiter option - checkAnswer( - spark.sql("SELECT * FROM t WITH ('delimiter' = ';')"), - Row("a", "b,c") :: Row("hello", " world,test") :: Nil - ) + // delimiter ; option + checkAnswer( + spark.sql("SELECT * FROM t WITH ('delimiter' = ';')"), + if (shouldIgnoreOption) { Review Comment: Nit: how about defining before: ``` val expected = if (shouldIgnoreOption) ... else ... ``` this can be re-used for sql and DF API? -- 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: reviews-unsubscr...@spark.apache.org 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