Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
implement collation trim block without collate builder call.
  • Loading branch information
jovanpavl-db committed Sep 23, 2024
commit e65232e056ff8d67009f7d74bf7b0b271dd3b54e
Original file line number Diff line number Diff line change
Expand Up @@ -2557,6 +2557,13 @@ class AstBuilder extends DataTypeAstBuilder
}

override def visitCollateClause(ctx: CollateClauseContext): String = withOrigin(ctx) {
val collationName = ctx.collationName.getText
if (!SQLConf.get.trimCollationEnabled &&
(collationName.toUpperCase().contains("TRIM") ||
collationName.toUpperCase().contains("LTRIM") ||
collationName.toUpperCase().contains("RTRIM"))) {
throw QueryCompilationErrors.trimCollationNotEnabledError()
}
ctx.identifier.getText
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,20 @@ class QueryCompilationErrorsSuite
}

test("SPARK-49666: the trim collation feature is off without collate builder call") {
withSQLConf(SQLConf.TRIM_COLLATION_ENABLED.key -> "false") {
Seq(
"CREATE TABLE t(col STRING COLLATE EN_TRIM_CI) USING parquet",
"CREATE TABLE t(col STRING COLLATE UTF8_LCASE_TRIM) USING parquet",
"SELECT 'aaa' COLLATE UNICODE_LTRIM_CI",
).foreach { sqlText =>
checkError(
exception = intercept[AnalysisException](sql(sqlText)),
condition = "UNSUPPORTED_FEATURE.TRIM_COLLATION")
}
}
}

test("SPARK-49666: the trim collation feature is off with collate builder call") {
withSQLConf(SQLConf.TRIM_COLLATION_ENABLED.key -> "false") {
Seq(
"SELECT collate('aaa', 'UNICODE_TRIM')",
Expand Down