Github user wzhfy commented on a diff in the pull request:
https://github.com/apache/spark/pull/12646#discussion_r117601355
--- Diff:
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala
---
@@ -2015,4 +2015,121 @@ class SQLQuerySuite extends QueryTest with
SQLTestUtils with TestHiveSingleton {
checkAnswer(table.filter($"p" === "p1\" and q=\"q1").select($"a"),
Row(4))
}
}
+
+ test("TRIM function-BOTH") {
+ withTable("trimBoth", "trimStrut") {
+ sql("create table trimBoth (c1 string, c2 char(1), c3 string, c4
string, " +
+ "c5 string, c6 string)")
+ // scalastyle:off
+ sql("insert into trimBoth select 'cccccc', 'c', ' cccbacc',
'cccbaccæ°', 'æ°æ®ç 头', 'æ°'")
+ // scalastyle:on
+ sql("create table trimStrut (c1 struct<n1: int, n2:string>, c2
string)")
+ sql("insert into trimStrut values ((100, 'abc'), 'ABC')")
+
+ intercept[AnalysisException] {
+ sql("SELECT TRIM('c', C1, 'd') from trimBoth")
+ }
+ intercept[AnalysisException] {
+ sql("SELECT TRIM(C2, C1) from trimBoth").collect
+ }
+ intercept[AnalysisException] {
+ sql("SELECT TRIM(BOTH C2 FROM C1) from trimBoth").collect
+ }
+ intercept[AnalysisException] {
+ sql("select trim(c1,c2) from trimStrut")
+ }
+ intercept[AnalysisException] {
+ sql("select trim(c2,c1) from trimStrut")
+ }
+
+ checkAnswer (sql("SELECT TRIM(BOTH 'c' FROM C1) from trimBoth"),
Row(""))
--- End diff --
remove space after `checkAnswer`
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]