This is an automated email from the ASF dual-hosted git repository.
cloud-fan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push:
new a7c0d213480d [SPARK-49671][SQL] Remove the RTRIM collation config
a7c0d213480d is described below
commit a7c0d213480d98a5d18fa0931d85cf286a8f31d0
Author: Uros Bojanic <[email protected]>
AuthorDate: Wed May 13 09:02:06 2026 +0800
[SPARK-49671][SQL] Remove the RTRIM collation config
### What changes were proposed in this pull request?
Cleanup SQL configs by removing `TRIM_COLLATION_ENABLED` and its
surrounding code changes, thus eliminating the
`spark.sql.collation.trim.enabled` feature flag from the codebase.
### Why are the changes needed?
Collations and RTRIM are already enabled by default, and these configs are
no longer needed.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
Existing tests suffice. Outdated tests have been removed.
### Was this patch authored or co-authored using generative AI tooling?
No.
Closes #53576 from uros-db/remove-rtrim-flag.
Authored-by: Uros Bojanic <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>
---
.../expressions/collationExpressions.scala | 5 ----
.../spark/sql/catalyst/parser/AstBuilder.scala | 6 +---
.../spark/sql/errors/QueryCompilationErrors.scala | 7 -----
.../org/apache/spark/sql/internal/SQLConf.scala | 12 --------
.../sql/errors/QueryCompilationErrorsSuite.scala | 33 ----------------------
5 files changed, 1 insertion(+), 62 deletions(-)
diff --git
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collationExpressions.scala
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collationExpressions.scala
index 9d7c2236678d..c3db6fca6a86 100644
---
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collationExpressions.scala
+++
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collationExpressions.scala
@@ -24,7 +24,6 @@ import org.apache.spark.sql.catalyst.expressions.codegen._
import org.apache.spark.sql.catalyst.trees.TreePattern.{TreePattern,
UNRESOLVED_COLLATION}
import org.apache.spark.sql.catalyst.util.{AttributeNameParser,
CollationFactory}
import org.apache.spark.sql.errors.QueryCompilationErrors
-import org.apache.spark.sql.internal.SQLConf
import org.apache.spark.sql.internal.types.StringTypeWithCollation
import org.apache.spark.sql.types._
@@ -54,10 +53,6 @@ object CollateExpressionBuilder extends ExpressionBuilder {
if (evalCollation == null) {
throw QueryCompilationErrors.unexpectedNullError("collation",
collationExpr)
} else {
- if (!SQLConf.get.trimCollationEnabled &&
- evalCollation.toString.toUpperCase().contains("TRIM")) {
- throw QueryCompilationErrors.trimCollationNotEnabledError()
- }
Collate(e, UnresolvedCollation(
AttributeNameParser.parseAttributeName(evalCollation.toString)))
}
diff --git
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
index a6906be6d794..a79f64cf53d9 100644
---
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
+++
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
@@ -3583,11 +3583,7 @@ class AstBuilder extends DataTypeAstBuilder
}
override def visitCollateClause(ctx: CollateClauseContext): Seq[String] =
withOrigin(ctx) {
- val collationName = visitMultipartIdentifier(ctx.collationName)
- if (!SQLConf.get.trimCollationEnabled &&
collationName.last.toUpperCase().contains("TRIM")) {
- throw QueryCompilationErrors.trimCollationNotEnabledError()
- }
- collationName
+ visitMultipartIdentifier(ctx.collationName)
}
/**
diff --git
a/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryCompilationErrors.scala
b/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryCompilationErrors.scala
index 33fc7769f10a..9cd94e984cae 100644
---
a/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryCompilationErrors.scala
+++
b/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryCompilationErrors.scala
@@ -396,13 +396,6 @@ private[sql] object QueryCompilationErrors extends
QueryErrorsBase with Compilat
)
}
- def trimCollationNotEnabledError(): Throwable = {
- new AnalysisException(
- errorClass = "UNSUPPORTED_FEATURE.TRIM_COLLATION",
- messageParameters = Map.empty
- )
- }
-
def trailingCommaInSelectError(origin: Origin): Throwable = {
new AnalysisException(
errorClass = "TRAILING_COMMA_IN_SELECT",
diff --git
a/sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala
b/sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala
index 9e1e0d5d5f95..fe59cf239b70 100644
--- a/sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala
+++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala
@@ -1150,16 +1150,6 @@ object SQLConf {
.booleanConf
.createWithDefault(false)
- val TRIM_COLLATION_ENABLED =
- buildConf("spark.sql.collation.trim.enabled")
- .internal()
- .doc("When enabled allows the use of trim collations which trim trailing
whitespaces from" +
- " strings."
- )
- .version("4.0.0")
- .booleanConf
- .createWithDefault(true)
-
val COLLATION_AWARE_HASHING_ENABLED =
buildConf("spark.sql.legacy.collationAwareHashFunctions")
.internal()
@@ -7736,8 +7726,6 @@ class SQLConf extends Serializable with Logging with
SqlApiConf {
def schemaLevelCollationsEnabled: Boolean =
getConf(SCHEMA_LEVEL_COLLATIONS_ENABLED)
- def trimCollationEnabled: Boolean = getConf(TRIM_COLLATION_ENABLED)
-
def adaptiveExecutionEnabled: Boolean = getConf(ADAPTIVE_EXECUTION_ENABLED)
def adaptiveExecutionEnabledInStatelessStreaming: Boolean =
diff --git
a/sql/core/src/test/scala/org/apache/spark/sql/errors/QueryCompilationErrorsSuite.scala
b/sql/core/src/test/scala/org/apache/spark/sql/errors/QueryCompilationErrorsSuite.scala
index 2c10497c190e..c626d7183513 100644
---
a/sql/core/src/test/scala/org/apache/spark/sql/errors/QueryCompilationErrorsSuite.scala
+++
b/sql/core/src/test/scala/org/apache/spark/sql/errors/QueryCompilationErrorsSuite.scala
@@ -876,39 +876,6 @@ class QueryCompilationErrorsSuite
"inputTypes" -> "[\"INT\", \"STRING\", \"STRING\"]"))
}
- 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_RTRIM_CI) USING parquet",
- "CREATE TABLE t(col STRING COLLATE UTF8_LCASE_RTRIM) 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_RTRIM')",
- "SELECT collate('aaa', 'UTF8_BINARY_RTRIM')",
- "SELECT collate('aaa', 'EN_AI_RTRIM')"
- ).foreach { sqlText =>
- checkError(
- exception = intercept[AnalysisException](sql(sqlText)),
- condition = "UNSUPPORTED_FEATURE.TRIM_COLLATION",
- parameters = Map.empty,
- context =
- ExpectedContext(fragment = sqlText.substring(7), start = 7, stop =
sqlText.length - 1)
- )
- }
- }
- }
-
test("SPARK-50779: the object level collations feature is unsupported when
flag is disabled") {
withSQLConf(SQLConf.OBJECT_LEVEL_COLLATIONS_ENABLED.key -> "false") {
Seq(
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]