You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "viirya (via GitHub)" <gi...@apache.org> on 2026/03/30 21:38:31 UTC
[PR] [SPARK-49543][SQL] Add SHOW COLLATIONS command [spark]
viirya opened a new pull request, #55099:
URL: https://github.com/apache/spark/pull/55099
<!--
Thanks for sending a pull request! Here are some tips for you:
1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
4. Be sure to keep the PR description updated to reflect all changes.
5. Please write your PR title to summarize what this PR proposes.
6. If possible, provide a concise example to reproduce the issue for a faster review.
7. If you want to add a new configuration, please read the guideline first for naming configurations in
'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
8. If you want to add or modify an error type or message, please read the guideline first in
'common/utils/src/main/resources/error/README.md'.
-->
### What changes were proposed in this pull request?
<!--
Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue.
If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
2. If you fix some SQL features, you can provide some references of other DBMSes.
3. If there is design documentation, please add the link.
4. If there is a discussion in the mailing list, please add the link.
-->
Add SHOW COLLATIONS SQL syntax to list all Spark built-in collations. Supports optional LIKE pattern filtering (e.g. SHOW COLLATIONS LIKE 'UNICODE%').
Output schema: NAME, LANGUAGE, COUNTRY, ACCENT_SENSITIVITY, CASE_SENSITIVITY, PAD_ATTRIBUTE, ICU_VERSION — matching the existing collations() TVF but without the constant CATALOG/SCHEMA columns.
Implementation follows the ShowCatalogsCommand pattern as collations are engine-global and not tied to any catalog or namespace.
### Why are the changes needed?
<!--
Please clarify why the changes are needed. For instance,
1. If you propose a new API, clarify the use case for a new API.
2. If you fix a bug, you can clarify why it is a bug.
-->
SHOW COLLATIONS is a SQL command supported by MySQL and its derivatives (MariaDB, TiDB) for listing available collations. Spark currently only exposes this information via a table-valued function (SELECT * FROM collations()), which is inconsistent with how other catalog objects are queried (SHOW CATALOGS, SHOW TABLES, etc.) and unfamiliar to users coming from MySQL-compatible databases. This change adds a more intuitive SQL syntax consistent with Spark's existing SHOW command family.
### Does this PR introduce _any_ user-facing change?
<!--
Note that it means *any* user-facing change including all aspects such as new features, bug fixes, or other behavior changes. Documentation-only updates are not considered user-facing changes.
If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
If no, write 'No'.
-->
Yes, this adds `SHOW COLLATIONS` command.
### How was this patch tested?
<!--
If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
If tests were not added, please describe why they were not added and/or why it was difficult to add.
If benchmark tests were added, please run the benchmarks in GitHub Actions for the consistent environment, and the instructions could accord to: https://spark.apache.org/developer-tools.html#github-workflow-benchmarks.
-->
Unit tests
### Was this patch authored or co-authored using generative AI tooling?
<!--
If generative AI tooling has been used in the process of authoring this patch, please include the
phrase: 'Generated-by: ' followed by the name of the tool and its version.
If no, write 'No'.
Please refer to the [ASF Generative Tooling Guidance](https://www.apache.org/legal/generative-tooling.html) for details.
-->
Generated-by: Claude Sonnet 4.6
--
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-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-49543][SQL] Add SHOW COLLATIONS command [spark]
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on code in PR #55099:
URL: https://github.com/apache/spark/pull/55099#discussion_r3017111487
##########
sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2SQLSuite.scala:
##########
@@ -3223,6 +3223,37 @@ class DataSourceV2SQLSuiteV1Filter
Row("testcat"), Row("testcat2")))
}
+ test("SPARK-49543: ShowCollations") {
+ val schema = new StructType()
+ .add("NAME", StringType, nullable = false)
+ .add("LANGUAGE", StringType, nullable = true)
+ .add("COUNTRY", StringType, nullable = true)
+ .add("ACCENT_SENSITIVITY", StringType, nullable = false)
+ .add("CASE_SENSITIVITY", StringType, nullable = false)
+ .add("PAD_ATTRIBUTE", StringType, nullable = false)
+ .add("ICU_VERSION", StringType, nullable = true)
+
+ val df = sql("SHOW COLLATIONS")
+ assert(df.schema === schema)
+
+ val allCollations = df.collect()
+ assert(allCollations.exists(_.getString(0) == "UTF8_BINARY"))
+ assert(allCollations.exists(_.getString(0) == "UNICODE"))
+ assert(allCollations.exists(_.getString(0) == "UNICODE_CI"))
+
+ val utf8Row = allCollations.find(_.getString(0) == "UTF8_BINARY").get
+ assert(utf8Row.getString(3) == "ACCENT_SENSITIVE")
+ assert(utf8Row.getString(4) == "CASE_SENSITIVE")
+
+ val likeResult = sql("SHOW COLLATIONS LIKE 'UNICODE*'").collect()
Review Comment:
Thank you, @viirya . After reading the doc once more, I realized my misunderstanding. Sorry for making you confused.
--
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-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-49543][SQL] Add SHOW COLLATIONS command [spark]
Posted by "viirya (via GitHub)" <gi...@apache.org>.
viirya commented on code in PR #55099:
URL: https://github.com/apache/spark/pull/55099#discussion_r3016984351
##########
sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2SQLSuite.scala:
##########
@@ -3223,6 +3223,37 @@ class DataSourceV2SQLSuiteV1Filter
Row("testcat"), Row("testcat2")))
}
+ test("SPARK-49543: ShowCollations") {
+ val schema = new StructType()
+ .add("NAME", StringType, nullable = false)
+ .add("LANGUAGE", StringType, nullable = true)
+ .add("COUNTRY", StringType, nullable = true)
+ .add("ACCENT_SENSITIVITY", StringType, nullable = false)
+ .add("CASE_SENSITIVITY", StringType, nullable = false)
+ .add("PAD_ATTRIBUTE", StringType, nullable = false)
+ .add("ICU_VERSION", StringType, nullable = true)
+
+ val df = sql("SHOW COLLATIONS")
+ assert(df.schema === schema)
+
+ val allCollations = df.collect()
+ assert(allCollations.exists(_.getString(0) == "UTF8_BINARY"))
+ assert(allCollations.exists(_.getString(0) == "UNICODE"))
+ assert(allCollations.exists(_.getString(0) == "UNICODE_CI"))
+
+ val utf8Row = allCollations.find(_.getString(0) == "UTF8_BINARY").get
+ assert(utf8Row.getString(3) == "ACCENT_SENSITIVE")
+ assert(utf8Row.getString(4) == "CASE_SENSITIVE")
+
+ val likeResult = sql("SHOW COLLATIONS LIKE 'UNICODE*'").collect()
Review Comment:
Thanks for catching this! You're right that LIKE should use % as the wildcard. Fixed in ShowCollationsCommand by converting % to * before calling filterPattern (which only understands glob-style *).
For context: other existing SHOW commands like SHOW NAMESPACES and SHOW FUNCTIONS also use filterPattern directly without % conversion, so their existing tests only use * (e.g., LIKE '*1*'). This SHOW COLLATIONS fix makes it consistent with SQL LIKE convention, unlike those commands.
ShowNamespacesSuiteBase.scala:88 — SHOW NAMESPACES LIKE '*1*'
ShowFunctionsParserSuite.scala:50 — SHOW FUNCTIONS LIKE 'funct*'
ShowTablesParserSuite.scala:36 — SHOW TABLES LIKE '*test*'
ShowTablesParserSuite.scala:54 — SHOW TABLE EXTENDED LIKE '*test*'
ShowTablesSuiteBase.scala:338 — SHOW TABLE EXTENDED LIKE '$viewName*'
--
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-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-49543][SQL] Add SHOW COLLATIONS command [spark]
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on code in PR #55099:
URL: https://github.com/apache/spark/pull/55099#discussion_r3017099662
##########
sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2SQLSuite.scala:
##########
@@ -3223,6 +3223,37 @@ class DataSourceV2SQLSuiteV1Filter
Row("testcat"), Row("testcat2")))
}
+ test("SPARK-49543: ShowCollations") {
+ val schema = new StructType()
+ .add("NAME", StringType, nullable = false)
+ .add("LANGUAGE", StringType, nullable = true)
+ .add("COUNTRY", StringType, nullable = true)
+ .add("ACCENT_SENSITIVITY", StringType, nullable = false)
+ .add("CASE_SENSITIVITY", StringType, nullable = false)
+ .add("PAD_ATTRIBUTE", StringType, nullable = false)
+ .add("ICU_VERSION", StringType, nullable = true)
+
+ val df = sql("SHOW COLLATIONS")
+ assert(df.schema === schema)
+
+ val allCollations = df.collect()
+ assert(allCollations.exists(_.getString(0) == "UTF8_BINARY"))
+ assert(allCollations.exists(_.getString(0) == "UNICODE"))
+ assert(allCollations.exists(_.getString(0) == "UNICODE_CI"))
+
+ val utf8Row = allCollations.find(_.getString(0) == "UTF8_BINARY").get
+ assert(utf8Row.getString(3) == "ACCENT_SENSITIVE")
+ assert(utf8Row.getString(4) == "CASE_SENSITIVE")
+
+ val likeResult = sql("SHOW COLLATIONS LIKE 'UNICODE*'").collect()
Review Comment:
Oh. So, we support both `%` and `*`?
--
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-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-49543][SQL] Add SHOW COLLATIONS command [spark]
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun closed pull request #55099: [SPARK-49543][SQL] Add SHOW COLLATIONS command
URL: https://github.com/apache/spark/pull/55099
--
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-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-49543][SQL] Add SHOW COLLATIONS command [spark]
Posted by "viirya (via GitHub)" <gi...@apache.org>.
viirya commented on code in PR #55099:
URL: https://github.com/apache/spark/pull/55099#discussion_r3016984351
##########
sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2SQLSuite.scala:
##########
@@ -3223,6 +3223,37 @@ class DataSourceV2SQLSuiteV1Filter
Row("testcat"), Row("testcat2")))
}
+ test("SPARK-49543: ShowCollations") {
+ val schema = new StructType()
+ .add("NAME", StringType, nullable = false)
+ .add("LANGUAGE", StringType, nullable = true)
+ .add("COUNTRY", StringType, nullable = true)
+ .add("ACCENT_SENSITIVITY", StringType, nullable = false)
+ .add("CASE_SENSITIVITY", StringType, nullable = false)
+ .add("PAD_ATTRIBUTE", StringType, nullable = false)
+ .add("ICU_VERSION", StringType, nullable = true)
+
+ val df = sql("SHOW COLLATIONS")
+ assert(df.schema === schema)
+
+ val allCollations = df.collect()
+ assert(allCollations.exists(_.getString(0) == "UTF8_BINARY"))
+ assert(allCollations.exists(_.getString(0) == "UNICODE"))
+ assert(allCollations.exists(_.getString(0) == "UNICODE_CI"))
+
+ val utf8Row = allCollations.find(_.getString(0) == "UTF8_BINARY").get
+ assert(utf8Row.getString(3) == "ACCENT_SENSITIVE")
+ assert(utf8Row.getString(4) == "CASE_SENSITIVE")
+
+ val likeResult = sql("SHOW COLLATIONS LIKE 'UNICODE*'").collect()
Review Comment:
Thanks for catching this!
For context: other existing SHOW commands like SHOW NAMESPACES and SHOW FUNCTIONS also use *. This SHOW COLLATIONS fix makes it consistent with SQL LIKE convention, unlike those commands.
ShowNamespacesSuiteBase.scala:88 — SHOW NAMESPACES LIKE '*1*'
ShowFunctionsParserSuite.scala:50 — SHOW FUNCTIONS LIKE 'funct*'
ShowTablesParserSuite.scala:36 — SHOW TABLES LIKE '*test*'
ShowTablesParserSuite.scala:54 — SHOW TABLE EXTENDED LIKE '*test*'
ShowTablesSuiteBase.scala:338 — SHOW TABLE EXTENDED LIKE '$viewName*'
I also take a look at our document for SHOW TABLES LIKE https://spark.apache.org/docs/latest/sql-ref-syntax-aux-show-tables.html. It said the command uses `regex_pattern` after `LIKE`:
```
Syntax
SHOW TABLES [ { FROM | IN } database_name ] [ LIKE regex_pattern ]
```
--
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-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-49543][SQL] Add SHOW COLLATIONS command [spark]
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on code in PR #55099:
URL: https://github.com/apache/spark/pull/55099#discussion_r3017117334
##########
sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2SQLSuite.scala:
##########
@@ -3223,6 +3223,37 @@ class DataSourceV2SQLSuiteV1Filter
Row("testcat"), Row("testcat2")))
}
+ test("SPARK-49543: ShowCollations") {
+ val schema = new StructType()
+ .add("NAME", StringType, nullable = false)
+ .add("LANGUAGE", StringType, nullable = true)
+ .add("COUNTRY", StringType, nullable = true)
+ .add("ACCENT_SENSITIVITY", StringType, nullable = false)
+ .add("CASE_SENSITIVITY", StringType, nullable = false)
+ .add("PAD_ATTRIBUTE", StringType, nullable = false)
+ .add("ICU_VERSION", StringType, nullable = true)
+
+ val df = sql("SHOW COLLATIONS")
+ assert(df.schema === schema)
+
+ val allCollations = df.collect()
+ assert(allCollations.exists(_.getString(0) == "UTF8_BINARY"))
+ assert(allCollations.exists(_.getString(0) == "UNICODE"))
+ assert(allCollations.exists(_.getString(0) == "UNICODE_CI"))
+
+ val utf8Row = allCollations.find(_.getString(0) == "UTF8_BINARY").get
+ assert(utf8Row.getString(3) == "ACCENT_SENSITIVE")
+ assert(utf8Row.getString(4) == "CASE_SENSITIVE")
+
+ val likeResult = sql("SHOW COLLATIONS LIKE 'UNICODE*'").collect()
Review Comment:
BTW, can we have a new document for `SHOW COLLATIONS` like `SHOW TABLES LIKE` https://spark.apache.org/docs/latest/sql-ref-syntax-aux-show-tables.html ?
--
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-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-49543][SQL] Add SHOW COLLATIONS command [spark]
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #55099:
URL: https://github.com/apache/spark/pull/55099#discussion_r3019477375
##########
sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2SQLSuite.scala:
##########
@@ -3223,6 +3223,37 @@ class DataSourceV2SQLSuiteV1Filter
Row("testcat"), Row("testcat2")))
}
+ test("SPARK-49543: ShowCollations") {
+ val schema = new StructType()
+ .add("NAME", StringType, nullable = false)
+ .add("LANGUAGE", StringType, nullable = true)
+ .add("COUNTRY", StringType, nullable = true)
+ .add("ACCENT_SENSITIVITY", StringType, nullable = false)
+ .add("CASE_SENSITIVITY", StringType, nullable = false)
+ .add("PAD_ATTRIBUTE", StringType, nullable = false)
+ .add("ICU_VERSION", StringType, nullable = true)
+
+ val df = sql("SHOW COLLATIONS")
+ assert(df.schema === schema)
+
+ val allCollations = df.collect()
+ assert(allCollations.exists(_.getString(0) == "UTF8_BINARY"))
+ assert(allCollations.exists(_.getString(0) == "UNICODE"))
+ assert(allCollations.exists(_.getString(0) == "UNICODE_CI"))
+
+ val utf8Row = allCollations.find(_.getString(0) == "UTF8_BINARY").get
+ assert(utf8Row.getString(3) == "ACCENT_SENSITIVE")
+ assert(utf8Row.getString(4) == "CASE_SENSITIVE")
+
+ val likeResult = sql("SHOW COLLATIONS LIKE 'UNICODE*'").collect()
Review Comment:
there was a ticket to make it follow the standard SQL LIKE pattern SPARK-45880 (https://github.com/apache/spark/pull/43751) but was not landed.
--
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-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-49543][SQL] Add SHOW COLLATIONS command [spark]
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on code in PR #55099:
URL: https://github.com/apache/spark/pull/55099#discussion_r3017099662
##########
sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2SQLSuite.scala:
##########
@@ -3223,6 +3223,37 @@ class DataSourceV2SQLSuiteV1Filter
Row("testcat"), Row("testcat2")))
}
+ test("SPARK-49543: ShowCollations") {
+ val schema = new StructType()
+ .add("NAME", StringType, nullable = false)
+ .add("LANGUAGE", StringType, nullable = true)
+ .add("COUNTRY", StringType, nullable = true)
+ .add("ACCENT_SENSITIVITY", StringType, nullable = false)
+ .add("CASE_SENSITIVITY", StringType, nullable = false)
+ .add("PAD_ATTRIBUTE", StringType, nullable = false)
+ .add("ICU_VERSION", StringType, nullable = true)
+
+ val df = sql("SHOW COLLATIONS")
+ assert(df.schema === schema)
+
+ val allCollations = df.collect()
+ assert(allCollations.exists(_.getString(0) == "UTF8_BINARY"))
+ assert(allCollations.exists(_.getString(0) == "UNICODE"))
+ assert(allCollations.exists(_.getString(0) == "UNICODE_CI"))
+
+ val utf8Row = allCollations.find(_.getString(0) == "UTF8_BINARY").get
+ assert(utf8Row.getString(3) == "ACCENT_SENSITIVE")
+ assert(utf8Row.getString(4) == "CASE_SENSITIVE")
+
+ val likeResult = sql("SHOW COLLATIONS LIKE 'UNICODE*'").collect()
Review Comment:
~Oh. So, we support both `%` and `*`?~
--
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-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-49543][SQL] Add SHOW COLLATIONS command [spark]
Posted by "viirya (via GitHub)" <gi...@apache.org>.
viirya commented on code in PR #55099:
URL: https://github.com/apache/spark/pull/55099#discussion_r3017135026
##########
sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2SQLSuite.scala:
##########
@@ -3223,6 +3223,37 @@ class DataSourceV2SQLSuiteV1Filter
Row("testcat"), Row("testcat2")))
}
+ test("SPARK-49543: ShowCollations") {
+ val schema = new StructType()
+ .add("NAME", StringType, nullable = false)
+ .add("LANGUAGE", StringType, nullable = true)
+ .add("COUNTRY", StringType, nullable = true)
+ .add("ACCENT_SENSITIVITY", StringType, nullable = false)
+ .add("CASE_SENSITIVITY", StringType, nullable = false)
+ .add("PAD_ATTRIBUTE", StringType, nullable = false)
+ .add("ICU_VERSION", StringType, nullable = true)
+
+ val df = sql("SHOW COLLATIONS")
+ assert(df.schema === schema)
+
+ val allCollations = df.collect()
+ assert(allCollations.exists(_.getString(0) == "UTF8_BINARY"))
+ assert(allCollations.exists(_.getString(0) == "UNICODE"))
+ assert(allCollations.exists(_.getString(0) == "UNICODE_CI"))
+
+ val utf8Row = allCollations.find(_.getString(0) == "UTF8_BINARY").get
+ assert(utf8Row.getString(3) == "ACCENT_SENSITIVE")
+ assert(utf8Row.getString(4) == "CASE_SENSITIVE")
+
+ val likeResult = sql("SHOW COLLATIONS LIKE 'UNICODE*'").collect()
Review Comment:
Yes, let me add a document for it. Thanks for the reminder.
--
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-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-49543][SQL] Add SHOW COLLATIONS command [spark]
Posted by "viirya (via GitHub)" <gi...@apache.org>.
viirya commented on PR #55099:
URL: https://github.com/apache/spark/pull/55099#issuecomment-4164568723
> I updated the PR description too.
>
> ```diff
> -Add SHOW COLLATIONS SQL syntax to list all Spark built-in collations. Supports optional LIKE pattern filtering (e.g. SHOW COLLATIONS LIKE 'UNICODE%').
> +Add SHOW COLLATIONS SQL syntax to list all Spark built-in collations. Supports optional LIKE pattern filtering (e.g. SHOW COLLATIONS LIKE 'UNICODE*').
> ```
Thank you @dongjoon-hyun
--
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-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-49543][SQL] Add SHOW COLLATIONS command [spark]
Posted by "viirya (via GitHub)" <gi...@apache.org>.
viirya commented on PR #55099:
URL: https://github.com/apache/spark/pull/55099#issuecomment-4167458809
Thank you @dongjoon-hyun
--
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-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-49543][SQL] Add SHOW COLLATIONS command [spark]
Posted by "viirya (via GitHub)" <gi...@apache.org>.
viirya commented on code in PR #55099:
URL: https://github.com/apache/spark/pull/55099#discussion_r3016984351
##########
sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2SQLSuite.scala:
##########
@@ -3223,6 +3223,37 @@ class DataSourceV2SQLSuiteV1Filter
Row("testcat"), Row("testcat2")))
}
+ test("SPARK-49543: ShowCollations") {
+ val schema = new StructType()
+ .add("NAME", StringType, nullable = false)
+ .add("LANGUAGE", StringType, nullable = true)
+ .add("COUNTRY", StringType, nullable = true)
+ .add("ACCENT_SENSITIVITY", StringType, nullable = false)
+ .add("CASE_SENSITIVITY", StringType, nullable = false)
+ .add("PAD_ATTRIBUTE", StringType, nullable = false)
+ .add("ICU_VERSION", StringType, nullable = true)
+
+ val df = sql("SHOW COLLATIONS")
+ assert(df.schema === schema)
+
+ val allCollations = df.collect()
+ assert(allCollations.exists(_.getString(0) == "UTF8_BINARY"))
+ assert(allCollations.exists(_.getString(0) == "UNICODE"))
+ assert(allCollations.exists(_.getString(0) == "UNICODE_CI"))
+
+ val utf8Row = allCollations.find(_.getString(0) == "UTF8_BINARY").get
+ assert(utf8Row.getString(3) == "ACCENT_SENSITIVE")
+ assert(utf8Row.getString(4) == "CASE_SENSITIVE")
+
+ val likeResult = sql("SHOW COLLATIONS LIKE 'UNICODE*'").collect()
Review Comment:
Thanks for catching this!
For context: other existing SHOW commands like SHOW NAMESPACES and SHOW FUNCTIONS also uuse * (e.g., LIKE '*1*'). This SHOW COLLATIONS fix makes it consistent with SQL LIKE convention, unlike those commands.
ShowNamespacesSuiteBase.scala:88 — SHOW NAMESPACES LIKE '*1*'
ShowFunctionsParserSuite.scala:50 — SHOW FUNCTIONS LIKE 'funct*'
ShowTablesParserSuite.scala:36 — SHOW TABLES LIKE '*test*'
ShowTablesParserSuite.scala:54 — SHOW TABLE EXTENDED LIKE '*test*'
ShowTablesSuiteBase.scala:338 — SHOW TABLE EXTENDED LIKE '$viewName*'
I also take a look at our document for SHOW TABLES LIKE https://spark.apache.org/docs/latest/sql-ref-syntax-aux-show-tables.html. It said the command uses `regex_pattern` after `LIKE`:
```
Syntax
SHOW TABLES [ { FROM | IN } database_name ] [ LIKE regex_pattern ]
```
##########
sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2SQLSuite.scala:
##########
@@ -3223,6 +3223,37 @@ class DataSourceV2SQLSuiteV1Filter
Row("testcat"), Row("testcat2")))
}
+ test("SPARK-49543: ShowCollations") {
+ val schema = new StructType()
+ .add("NAME", StringType, nullable = false)
+ .add("LANGUAGE", StringType, nullable = true)
+ .add("COUNTRY", StringType, nullable = true)
+ .add("ACCENT_SENSITIVITY", StringType, nullable = false)
+ .add("CASE_SENSITIVITY", StringType, nullable = false)
+ .add("PAD_ATTRIBUTE", StringType, nullable = false)
+ .add("ICU_VERSION", StringType, nullable = true)
+
+ val df = sql("SHOW COLLATIONS")
+ assert(df.schema === schema)
+
+ val allCollations = df.collect()
+ assert(allCollations.exists(_.getString(0) == "UTF8_BINARY"))
+ assert(allCollations.exists(_.getString(0) == "UNICODE"))
+ assert(allCollations.exists(_.getString(0) == "UNICODE_CI"))
+
+ val utf8Row = allCollations.find(_.getString(0) == "UTF8_BINARY").get
+ assert(utf8Row.getString(3) == "ACCENT_SENSITIVE")
+ assert(utf8Row.getString(4) == "CASE_SENSITIVE")
+
+ val likeResult = sql("SHOW COLLATIONS LIKE 'UNICODE*'").collect()
Review Comment:
Thanks for catching this!
For context: other existing SHOW commands like SHOW NAMESPACES and SHOW FUNCTIONS also use * (e.g., LIKE '*1*'). This SHOW COLLATIONS fix makes it consistent with SQL LIKE convention, unlike those commands.
ShowNamespacesSuiteBase.scala:88 — SHOW NAMESPACES LIKE '*1*'
ShowFunctionsParserSuite.scala:50 — SHOW FUNCTIONS LIKE 'funct*'
ShowTablesParserSuite.scala:36 — SHOW TABLES LIKE '*test*'
ShowTablesParserSuite.scala:54 — SHOW TABLE EXTENDED LIKE '*test*'
ShowTablesSuiteBase.scala:338 — SHOW TABLE EXTENDED LIKE '$viewName*'
I also take a look at our document for SHOW TABLES LIKE https://spark.apache.org/docs/latest/sql-ref-syntax-aux-show-tables.html. It said the command uses `regex_pattern` after `LIKE`:
```
Syntax
SHOW TABLES [ { FROM | IN } database_name ] [ LIKE regex_pattern ]
```
--
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-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-49543][SQL] Add SHOW COLLATIONS command [spark]
Posted by "viirya (via GitHub)" <gi...@apache.org>.
viirya commented on code in PR #55099:
URL: https://github.com/apache/spark/pull/55099#discussion_r3016984351
##########
sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2SQLSuite.scala:
##########
@@ -3223,6 +3223,37 @@ class DataSourceV2SQLSuiteV1Filter
Row("testcat"), Row("testcat2")))
}
+ test("SPARK-49543: ShowCollations") {
+ val schema = new StructType()
+ .add("NAME", StringType, nullable = false)
+ .add("LANGUAGE", StringType, nullable = true)
+ .add("COUNTRY", StringType, nullable = true)
+ .add("ACCENT_SENSITIVITY", StringType, nullable = false)
+ .add("CASE_SENSITIVITY", StringType, nullable = false)
+ .add("PAD_ATTRIBUTE", StringType, nullable = false)
+ .add("ICU_VERSION", StringType, nullable = true)
+
+ val df = sql("SHOW COLLATIONS")
+ assert(df.schema === schema)
+
+ val allCollations = df.collect()
+ assert(allCollations.exists(_.getString(0) == "UTF8_BINARY"))
+ assert(allCollations.exists(_.getString(0) == "UNICODE"))
+ assert(allCollations.exists(_.getString(0) == "UNICODE_CI"))
+
+ val utf8Row = allCollations.find(_.getString(0) == "UTF8_BINARY").get
+ assert(utf8Row.getString(3) == "ACCENT_SENSITIVE")
+ assert(utf8Row.getString(4) == "CASE_SENSITIVE")
+
+ val likeResult = sql("SHOW COLLATIONS LIKE 'UNICODE*'").collect()
Review Comment:
Thanks for catching this!
For context: other existing SHOW commands like SHOW NAMESPACES and SHOW FUNCTIONS also use filterPattern directly without % conversion, so their existing tests only use * (e.g., LIKE '*1*'). This SHOW COLLATIONS fix makes it consistent with SQL LIKE convention, unlike those commands.
ShowNamespacesSuiteBase.scala:88 — SHOW NAMESPACES LIKE '*1*'
ShowFunctionsParserSuite.scala:50 — SHOW FUNCTIONS LIKE 'funct*'
ShowTablesParserSuite.scala:36 — SHOW TABLES LIKE '*test*'
ShowTablesParserSuite.scala:54 — SHOW TABLE EXTENDED LIKE '*test*'
ShowTablesSuiteBase.scala:338 — SHOW TABLE EXTENDED LIKE '$viewName*'
I also take a look at our document for SHOW TABLES LIKE https://spark.apache.org/docs/latest/sql-ref-syntax-aux-show-tables.html. It said the command uses `regex_pattern` after `LIKE`:
```
Syntax
SHOW TABLES [ { FROM | IN } database_name ] [ LIKE regex_pattern ]
```
--
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-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-49543][SQL] Add SHOW COLLATIONS command [spark]
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on PR #55099:
URL: https://github.com/apache/spark/pull/55099#issuecomment-4164475772
I updated the PR description too.
```diff
-Add SHOW COLLATIONS SQL syntax to list all Spark built-in collations. Supports optional LIKE pattern filtering (e.g. SHOW COLLATIONS LIKE 'UNICODE%').
+Add SHOW COLLATIONS SQL syntax to list all Spark built-in collations. Supports optional LIKE pattern filtering (e.g. SHOW COLLATIONS LIKE 'UNICODE*').
```
--
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-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-49543][SQL] Add SHOW COLLATIONS command [spark]
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on code in PR #55099:
URL: https://github.com/apache/spark/pull/55099#discussion_r3015824882
##########
sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2SQLSuite.scala:
##########
@@ -3223,6 +3223,37 @@ class DataSourceV2SQLSuiteV1Filter
Row("testcat"), Row("testcat2")))
}
+ test("SPARK-49543: ShowCollations") {
+ val schema = new StructType()
+ .add("NAME", StringType, nullable = false)
+ .add("LANGUAGE", StringType, nullable = true)
+ .add("COUNTRY", StringType, nullable = true)
+ .add("ACCENT_SENSITIVITY", StringType, nullable = false)
+ .add("CASE_SENSITIVITY", StringType, nullable = false)
+ .add("PAD_ATTRIBUTE", StringType, nullable = false)
+ .add("ICU_VERSION", StringType, nullable = true)
+
+ val df = sql("SHOW COLLATIONS")
+ assert(df.schema === schema)
+
+ val allCollations = df.collect()
+ assert(allCollations.exists(_.getString(0) == "UTF8_BINARY"))
+ assert(allCollations.exists(_.getString(0) == "UNICODE"))
+ assert(allCollations.exists(_.getString(0) == "UNICODE_CI"))
+
+ val utf8Row = allCollations.find(_.getString(0) == "UTF8_BINARY").get
+ assert(utf8Row.getString(3) == "ACCENT_SENSITIVE")
+ assert(utf8Row.getString(4) == "CASE_SENSITIVE")
+
+ val likeResult = sql("SHOW COLLATIONS LIKE 'UNICODE*'").collect()
Review Comment:
Could you double-check this, @viirya ? `LIKE` should use `%` instead of `*`.
`*` is used for another syntax like `REGEXP`.
--
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-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-49543][SQL] Add SHOW COLLATIONS command [spark]
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on code in PR #55099:
URL: https://github.com/apache/spark/pull/55099#discussion_r3017226385
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/command/DDLParserSuite.scala:
##########
@@ -820,4 +820,16 @@ class DDLParserSuite extends AnalysisTest with SharedSparkSession {
parser.parsePlan("SHOW CATALOGS LIKE 'defau*'"),
ShowCatalogsCommand(Some("defau*")))
}
+
+ test("SHOW COLLATIONS") {
+ comparePlans(
+ parser.parsePlan("SHOW COLLATIONS"),
+ ShowCollationsCommand(None))
+ comparePlans(
+ parser.parsePlan("SHOW COLLATIONS LIKE 'UNICODE%'"),
Review Comment:
If we don't support `%`, shall we avoid `%` in the test case, @viirya ?
--
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-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-49543][SQL] Add SHOW COLLATIONS command [spark]
Posted by "viirya (via GitHub)" <gi...@apache.org>.
viirya commented on code in PR #55099:
URL: https://github.com/apache/spark/pull/55099#discussion_r3017235495
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/command/DDLParserSuite.scala:
##########
@@ -820,4 +820,16 @@ class DDLParserSuite extends AnalysisTest with SharedSparkSession {
parser.parsePlan("SHOW CATALOGS LIKE 'defau*'"),
ShowCatalogsCommand(Some("defau*")))
}
+
+ test("SHOW COLLATIONS") {
+ comparePlans(
+ parser.parsePlan("SHOW COLLATIONS"),
+ ShowCollationsCommand(None))
+ comparePlans(
+ parser.parsePlan("SHOW COLLATIONS LIKE 'UNICODE%'"),
Review Comment:
Good catch! Let me remove it.
--
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-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-49543][SQL] Add SHOW COLLATIONS command [spark]
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on PR #55099:
URL: https://github.com/apache/spark/pull/55099#issuecomment-4165301115
Merged to master for Apache Spark 4.2.0.
--
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-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org