stefankandic commented on code in PR #50435: URL: https://github.com/apache/spark/pull/50435#discussion_r2018649463
########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveDDLCommandStringTypes.scala: ########## @@ -46,9 +46,14 @@ object ResolveDDLCommandStringTypes extends Rule[LogicalPlan] { case createTable: CreateTable if createTable.tableSpec.collation.isDefined => StringType(createTable.tableSpec.collation.get) + // CreateView also handles CREATE OR REPLACE VIEW + // Unlike tables, it is not treated separately Review Comment: ```suggestion // Unlike for tables, CreateView also handles CREATE OR REPLACE VIEW. ``` ########## sql/core/src/test/scala/org/apache/spark/sql/collation/DefaultCollationTestSuite.scala: ########## @@ -388,6 +388,25 @@ class DefaultCollationTestSuiteV1 extends DefaultCollationTestSuite { assertTableColumnCollation(testTable, "c4", "UTF8_BINARY") } } + + test("CREATE OR REPLACE VIEW with DEFAULT COLLATION") { + withTable(testTable) { + sql(s"CREATE TABLE $testTable (c1 STRING, c2 STRING COLLATE UTF8_LCASE)") + sql(s"INSERT INTO $testTable VALUES ('a', 'a'), ('A', 'A'), ('b', 'b')") + withView(testView) { + // scalastyle:off + sql( + s"""CREATE OR REPLACE VIEW $testView + | DEFAULT COLLATION sr_ci_ai + | AS SELECT *, 'ć' AS c3 FROM $testTable + |""".stripMargin) + checkAnswer(sql(s"SELECT COUNT(*) FROM $testView WHERE c1 = 'A'"), Row(1)) + checkAnswer(sql(s"SELECT COUNT(*) FROM $testView WHERE c2 = 'a'"), Row(2)) + checkAnswer(sql(s"SELECT COUNT(*) FROM $testView WHERE c3 = 'Č'"), Row(3)) Review Comment: Can we also verify the collation of the column? `SELECT DISTINCT COLLATION(col) FROM view` -- 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