Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-48906][SQL] Introduce SHOW COLLATIONS LIKE ... syntax to show all collations #47364

Closed
wants to merge 41 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
1fde4b4
[SPARK-48906][SQL] Introduce `SHOW COLLATIONS LIKE ...` syntax to sho…
panbingkun Jul 16, 2024
bc5ce3a
fix UT
panbingkun Jul 16, 2024
7c76601
Merge branch 'master' into show_collation_syntax
panbingkun Jul 16, 2024
395e40a
fix ut
panbingkun Jul 16, 2024
4dfb5e0
[MINOR][SQL] Fix CollationFactorySuite
panbingkun Jul 17, 2024
a8ed3e3
Merge branch 'master' into show_collation_syntax
panbingkun Jul 22, 2024
e30b5a6
Merge branch 'master' into show_collation_syntax
panbingkun Jul 23, 2024
0411f6d
update
panbingkun Jul 23, 2024
5928f59
Merge branch 'show_collation_syntax' of https://github.com/panbingkun…
panbingkun Jul 23, 2024
15cf451
update
panbingkun Jul 23, 2024
d7a7d81
Merge branch 'master' into show_collation_syntax
panbingkun Aug 1, 2024
c0a9808
update
panbingkun Aug 2, 2024
e48361e
Merge branch 'master' into show_collation_syntax
panbingkun Aug 2, 2024
f3ac8ad
add listCollations in catalog
panbingkun Aug 2, 2024
270ce4f
fix mima check
panbingkun Aug 2, 2024
f731ce1
fix mima
panbingkun Aug 2, 2024
37272d9
Merge branch 'master' into show_collation_syntax
panbingkun Aug 2, 2024
fd8803f
Merge branch 'master' into show_collation_syntax
panbingkun Aug 5, 2024
f96a597
update
panbingkun Aug 28, 2024
10c22dc
Merge branch 'master' into show_collation_syntax
panbingkun Aug 30, 2024
887c468
update
panbingkun Aug 30, 2024
e51542b
Merge branch 'master' into show_collation_syntax
panbingkun Aug 30, 2024
6855b6a
update
panbingkun Sep 6, 2024
a6870bb
Merge branch 'master' into show_collation_syntax
panbingkun Sep 6, 2024
4c567d6
fix
panbingkun Sep 6, 2024
008b9dc
update
panbingkun Sep 6, 2024
e2c17fc
update
panbingkun Sep 6, 2024
ee805c9
fix
panbingkun Sep 9, 2024
1a85852
update
panbingkun Sep 9, 2024
220c5a0
Merge branch 'master' into show_collation_syntax
panbingkun Sep 10, 2024
e61f3df
sort
panbingkun Sep 10, 2024
46be9ca
fix
panbingkun Sep 10, 2024
cd31c31
Merge branch 'master' into show_collation_syntax
panbingkun Sep 10, 2024
83f4e81
update
panbingkun Sep 10, 2024
a01b786
update version value
panbingkun Sep 10, 2024
bb8760e
add UT
panbingkun Sep 10, 2024
261f3c3
update
panbingkun Sep 10, 2024
949e16a
fix conflict
panbingkun Sep 11, 2024
dbeeb62
fix conflict
panbingkun Sep 11, 2024
811196e
Merge branch 'master' into show_collation_syntax
panbingkun Sep 11, 2024
dd966fa
update
panbingkun Sep 11, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public Optional<String> getVersion() {
/**
* Entry encapsulating all information about a collation.
*/
public static class Collation {
public static class Collation implements Comparable<Collation> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really needed? When do we want to order them? I would say list/table building should be deterministic and should always output collations in the same way. Also I would expect UTF8_* family collations to come in first as they represent OSS internal implementations.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay.

public final String collationName;
public final String provider;
public final Collator collator;
Expand Down Expand Up @@ -174,6 +174,11 @@ public Collation(
}
}

@Override
public int compareTo(Collation other) {
return this.collationName.compareTo(other.collationName);
}

/**
* Collation ID is defined as 32-bit integer. We specify binary layouts for different classes of
* collations. Classes of collations are differentiated by most significant 3 bits (bit 31, 30
Expand Down Expand Up @@ -342,6 +347,13 @@ private static int collationNameToId(String collationName) throws SparkException
}

Copy link
Contributor Author

@panbingkun panbingkun Aug 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think third-party implementation of CollationSpec requires the implementation of methods catalog() and schema() to provide catalog and schema. Am I right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is true actually. I will do a bit more of testing on how we can handle these two, as to me it seems a bit weird to only have it in meta, but not in the Collation itself. Also I feel like if we end up having calls for catalog and schema we need to think of the case where we add user defined collations. Will provide update by the end of the day.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, thanks!

protected abstract Collation buildCollation();

public static List<Collation> fetchAllCollations() {
List<Collation> collations = new ArrayList<>();
collations.addAll(CollationSpecUTF8.fetchAllCollations());
collations.addAll(CollationSpecICU.fetchAllCollations());
return collations;
}
}

private static class CollationSpecUTF8 extends CollationSpec {
Expand Down Expand Up @@ -428,6 +440,13 @@ protected Collation buildCollation() {
/* supportsLowercaseEquality = */ true);
}
}

public static List<Collation> fetchAllCollations() {
List<Collation> collations = new ArrayList<>();
collations.add(UTF8_BINARY_COLLATION);
collations.add(UTF8_LCASE_COLLATION);
return collations;
}
}

private static class CollationSpecICU extends CollationSpec {
Expand Down Expand Up @@ -704,6 +723,36 @@ private String collationName() {
}
return builder.toString();
}

private static void fetchCollation(List<Collation> collations, String collationName) {
try {
int collationId = CollationSpecICU.collationNameToId(
collationName, collationName.toUpperCase());
Collation collation = CollationSpecICU.fromCollationId(collationId).buildCollation();
collations.add(collation);
} catch (SparkException ignored) {
// ignore
}
}

public static List<Collation> fetchAllCollations() {
List<Collation> collations = new ArrayList<>();
for (Map.Entry<String, Integer> entry: ICULocaleToId.entrySet()) {
String locale = entry.getKey();
// CaseSensitivity.CS + AccentSensitivity.AS
fetchCollation(collations, locale);

// CaseSensitivity.CI + AccentSensitivity.AS
fetchCollation(collations, locale + "_CI");

// CaseSensitivity.CS + AccentSensitivity.AI
fetchCollation(collations, locale + "_AI");

// CaseSensitivity.CI + AccentSensitivity.AI
fetchCollation(collations, locale + "_CI_AI");
}
return collations;
}
}

/**
Expand Down Expand Up @@ -918,4 +967,8 @@ public static String getClosestSuggestionsOnInvalidName(

return String.join(", ", suggestions);
}

public static List<Collation> fetchAllCollations() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This operation seems a bit too expensive. We always build the whole table and then do a like on it. We need to do something similar to show tables where we have the pattern, as we do not want to ask for collation information if like operator is not concerned with it. Also it feels pretty weird to have fetchAllCollations in many places like this. This is not as expensive as building the whole table, but we are also allocating ArrayList multiple times

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me try to think of a better way.

return Collation.CollationSpec.fetchAllCollations();
}
}
1 change: 1 addition & 0 deletions docs/sql-ref-ansi-compliance.md
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ Below is a list of all the keywords in Spark SQL.
|CODEGEN|non-reserved|non-reserved|non-reserved|
|COLLATE|reserved|non-reserved|reserved|
|COLLATION|reserved|non-reserved|reserved|
|COLLATIONS|reserved|non-reserved|reserved|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we look at MySQL, they use SHOW COLLATION, PostgreSQL uses pg_collation catalog, so I would argue use of COLLATION keyword is sufficient, so let's keep this keyword free.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay,

The reason for using COLLATIONS is that I want to follow some of Spark's unwritten rules, eg:

| SHOW TABLES ((FROM | IN) identifierReference)?

| SHOW TBLPROPERTIES table=identifierReference

| SHOW COLUMNS (FROM | IN) table=identifierReference

Of course, if we decide to use COLLATION, I am fine too.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will follow-up on this a bit later, let's leave it as COLLATIONS for now, and then we can just revert keyword addition if we decide to switch to COLLATION.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay

|COLLECTION|non-reserved|non-reserved|non-reserved|
|COLUMN|reserved|non-reserved|reserved|
|COLUMNS|non-reserved|non-reserved|non-reserved|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ CLUSTERED: 'CLUSTERED';
CODEGEN: 'CODEGEN';
COLLATE: 'COLLATE';
COLLATION: 'COLLATION';
COLLATIONS: 'COLLATIONS';
COLLECTION: 'COLLECTION';
COLUMN: 'COLUMN';
COLUMNS: 'COLUMNS';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ statement
| SHOW PARTITIONS identifierReference partitionSpec? #showPartitions
| SHOW identifier? FUNCTIONS ((FROM | IN) ns=identifierReference)?
(LIKE? (legacy=multipartIdentifier | pattern=stringLit))? #showFunctions
| SHOW COLLATIONS (LIKE? pattern=stringLit)? #showCollations
| SHOW CREATE TABLE identifierReference (AS SERDE)? #showCreateTable
| SHOW CURRENT namespace #showCurrentNamespace
| SHOW CATALOGS (LIKE? pattern=stringLit)? #showCatalogs
Expand Down Expand Up @@ -1789,6 +1790,7 @@ nonReserved
| CODEGEN
| COLLATE
| COLLATION
| COLLATIONS
| COLLECTION
| COLUMN
| COLUMNS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ CLOSE
COALESCE
COLLATE
COLLATION
COLLATIONS
COLLECT
COLUMN
COMMIT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1116,4 +1116,18 @@ class SparkSqlAstBuilder extends AstBuilder {
withIdentClause(ctx.identifierReference(), UnresolvedNamespace(_)),
cleanedProperties)
}

/**
* Create a [[ShowCollationsCommand]] command.
* Expected format:
* {{{
* SHOW COLLATIONS (LIKE? pattern)?;
* }}}
*/
override def visitShowCollations(ctx: ShowCollationsContext): LogicalPlan = withOrigin(ctx) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you take a look at what visitShowFunctions does? I believe that approach might be the best for us, as in that case we have a clear distinction of what collation is being listed and we can easily remove addition of catalog and schema fields from CollationFactory.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, could we move than this function to AstBuilder, where visitShowFunctions is as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to define the syntax of SHOW COLLATIONS as follows?

| SHOW identifier? COLLATIONS ((FROM | IN) ns=identifierReference)?
        (LIKE? pattern=stringLit)?                                     #showCollations

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do two things here. Follow completely functions implementation, but just throw a new error that user defined collations are not supported, or just keep SHOW COLLATIONS (LIKE? pattern=stringLit)? and make sure we implement the listing of collation in a similar way as functions. Second approach might be more clear for now, as we would just throw parse exception if they tried to use some user defined collation specific implementation. ((FROM | IN) ns=identifierReference)? part of the parsing is a good add-on, but for now we are not going to use it. In showFunctions we only use identifier? and ((FROM | IN) ns=identifierReference)? when we are listing udfs and temporary functions from specific catalogs/schemas.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you ask me I would keep SHOW COLLATIONS (LIKE? pattern=stringLit)? but try to implement the underlying stuff as for functions. The addition of other features will not be that hard if we follow the functions implementation now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me implement a version first (Follow completely functions implementation).
From my perspective, it seems a bit reasonable.
Let's take a look at its final appearance.
If you think it's okay, we'll do it. If you don't think it's good, I'll update it later.

Copy link
Contributor Author

@panbingkun panbingkun Sep 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, could we move than this function to AstBuilder, where visitShowFunctions is as well

Because ShowCollationsCommand inherits UnaryRunnableCommand, and UnaryRunnableCommand is in module sql/core, So we need to put visitShowCollations in SparkSqlParser (in moudle sql/core) instead of AstBuilder (in module sql/catalyst),
#47038 (comment)
#47038 (comment)

why use UnaryRunnableCommand?
#47038 (comment)

Copy link
Contributor

@mihailom-db mihailom-db Sep 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with that. What do you think about using ShowCollations as a new LogicalPlan node and then resolve that to either ShowCollationsCommand or ShowCollationsExec, as ShowCollationsExec represents a v2 path of execution. (Something similar was done for Functions)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is reasonable, but based on the logic that has already been implemented, is it sufficient? I would like to ask @MaxGekk , what do you think? I would like to hear your advice.
Thanks!

if (!SQLConf.get.collationEnabled) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This config was removed as collations are now on by default in OSS. Please remove it from here as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, thanks!

throw QueryCompilationErrors.collationNotEnabledError()
}
ShowCollationsCommand(Option(ctx.pattern).map(x => string(visitStringLit(x))))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.spark.sql.execution.command

import java.util.regex.PatternSyntaxException

import scala.collection.mutable
import scala.jdk.CollectionConverters.CollectionHasAsScala

import org.apache.spark.sql.{Row, SparkSession}
import org.apache.spark.sql.catalyst.expressions.{Attribute, AttributeReference}
import org.apache.spark.sql.catalyst.util.CollationFactory
import org.apache.spark.sql.catalyst.util.CollationFactory.Collation
import org.apache.spark.sql.types.{BooleanType, StringType}

/**
* A command for `SHOW COLLATIONS`.
*
* The syntax of this command is:
* {{{
* SHOW COLLATIONS (LIKE? pattern)?;
* }}}
*/
case class ShowCollationsCommand(pattern: Option[String]) extends LeafRunnableCommand {
override val output: Seq[Attribute] = Seq(
AttributeReference("name", StringType, nullable = false)(),
AttributeReference("provider", StringType, nullable = false)(),
AttributeReference("version", StringType, nullable = false)(),
AttributeReference("binaryEquality", BooleanType, nullable = false)(),
AttributeReference("binaryOrdering", BooleanType, nullable = false)(),
AttributeReference("lowercaseEquality", BooleanType, nullable = false)())

override def run(sparkSession: SparkSession): Seq[Row] = {
val allCollations = CollationFactory.fetchAllCollations().asScala.toSeq
val filteredCollations = pattern.map(filterPattern(allCollations, _)).getOrElse(allCollations)
filteredCollations.map(c => Row(
c.collationName,
c.provider,
c.version,
c.supportsBinaryEquality,
c.supportsBinaryOrdering,
c.supportsLowercaseEquality))
}

private def filterPattern(collations: Seq[Collation], pattern: String): Seq[Collation] = {
val filteredCollations = mutable.SortedSet.empty[Collation]
pattern.trim().split("\\|").foreach { subPattern =>
try {
val regex = ("(?i)" + subPattern.replaceAll("\\*", ".*")).r
filteredCollations ++= collations.filter {
collation => regex.pattern.matcher(collation.collationName).matches()
}
} catch {
case _: PatternSyntaxException =>
}
}
filteredCollations.toSeq
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ CLUSTERED false
CODEGEN false
COLLATE true
COLLATION true
COLLATIONS true
COLLECTION false
COLUMN true
COLUMNS false
Expand Down Expand Up @@ -375,6 +376,7 @@ CAST
CHECK
COLLATE
COLLATION
COLLATIONS
COLUMN
CONSTRAINT
CREATE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ CLUSTERED false
CODEGEN false
COLLATE false
COLLATION false
COLLATIONS false
COLLECTION false
COLUMN false
COLUMNS false
Expand Down
20 changes: 20 additions & 0 deletions sql/core/src/test/scala/org/apache/spark/sql/CollationSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1465,4 +1465,24 @@ class CollationSuite extends DatasourceV2SQLBase with AdaptiveSparkPlanHelper {
}
}
}

test("show collations") {
Copy link
Contributor

@uros-db uros-db Sep 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add another test for just SHOW COLLATIONS, just so we verify that the output ordering is as expected (UTF8_BINARY, UTF8_LCASE, etc.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

val df = sql("SHOW COLLATIONS").limit(10)
    checkAnswer(df,
      Seq(Row("SYSTEM", "BUILTIN", "UTF8_BINARY", null, null,
        "ACCENT_SENSITIVE", "CASE_SENSITIVE", "NO_PAD", null),
      Row("SYSTEM", "BUILTIN", "UTF8_LCASE", null, null,
        "ACCENT_SENSITIVE", "CASE_INSENSITIVE", "NO_PAD", null),
      Row("SYSTEM", "BUILTIN", "UNICODE", "", "",
        "ACCENT_SENSITIVE", "CASE_SENSITIVE", "NO_PAD", "75.1.0.0"),
      Row("SYSTEM", "BUILTIN", "UNICODE_AI", "", "",
        "ACCENT_SENSITIVE", "CASE_INSENSITIVE", "NO_PAD", "75.1.0.0"),
      Row("SYSTEM", "BUILTIN", "UNICODE_CI", "", "",
        "ACCENT_INSENSITIVE", "CASE_SENSITIVE", "NO_PAD", "75.1.0.0"),
     Row("SYSTEM", "BUILTIN", "UNICODE_CI_AI", "", "",
       "ACCENT_INSENSITIVE", "CASE_INSENSITIVE", "NO_PAD", "75.1.0.0"),
     Row("SYSTEM", "BUILTIN", "af", "Afrikaans", "",
       "ACCENT_SENSITIVE", "CASE_SENSITIVE", "NO_PAD", "75.1.0.0"),
     Row("SYSTEM", "BUILTIN", "af_AI", "Afrikaans", "",
       "ACCENT_SENSITIVE", "CASE_INSENSITIVE", "NO_PAD", "75.1.0.0"),
     Row("SYSTEM", "BUILTIN", "af_CI", "Afrikaans", "",
       "ACCENT_INSENSITIVE", "CASE_SENSITIVE", "NO_PAD", "75.1.0.0"),
     Row("SYSTEM", "BUILTIN", "af_CI_AI", "Afrikaans", "",
        "ACCENT_INSENSITIVE", "CASE_INSENSITIVE", "NO_PAD", "75.1.0.0")))

assert(sql("SHOW COLLATIONS").collect().length == 562)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need the strict requirement? Could you either replace it by:

Suggested change
assert(sql("SHOW COLLATIONS").collect().length == 562)
assume(sql("SHOW COLLATIONS").collect().length == 562)

or at least set to:

Suggested change
assert(sql("SHOW COLLATIONS").collect().length == 562)
assert(sql("SHOW COLLATIONS").collect().length >= 562)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.


checkAnswer(sql("SHOW COLLATIONS LIKE '*UTF8_BINARY*'"),
Row("UTF8_BINARY", "spark", "1.0", true, true, false))
checkAnswer(sql("SHOW COLLATIONS '*zh_Hant_HKG*'"),
Seq(Row("zh_Hant_HKG", "icu", "153.120.0.0", false, false, false),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This version seems weird, I would say it should contain 75.1 as the version of ICU library. @nikolamand-db do you have any more info on is this expected?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

Row("zh_Hant_HKG_CI", "icu", "153.120.0.0", false, false, false),
Row("zh_Hant_HKG_AI", "icu", "153.120.0.0", false, false, false),
Row("zh_Hant_HKG_CI_AI", "icu", "153.120.0.0", false, false, false)))
withSQLConf(SQLConf.COLLATION_ENABLED.key -> "false") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto: on removing config calls

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

checkError(
exception = intercept[AnalysisException] {
sql("SHOW COLLATIONS")
},
errorClass = "UNSUPPORTED_FEATURE.COLLATION"
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ trait ThriftServerWithSparkContextSuite extends SharedThriftServer {
val sessionHandle = client.openSession(user, "")
val infoValue = client.getInfo(sessionHandle, GetInfoType.CLI_ODBC_KEYWORDS)
// scalastyle:off line.size.limit
assert(infoValue.getStringValue == "ADD,AFTER,ALL,ALTER,ALWAYS,ANALYZE,AND,ANTI,ANY,ANY_VALUE,ARCHIVE,ARRAY,AS,ASC,AT,AUTHORIZATION,BEGIN,BETWEEN,BIGINT,BINARY,BINDING,BOOLEAN,BOTH,BUCKET,BUCKETS,BY,BYTE,CACHE,CALLED,CASCADE,CASE,CAST,CATALOG,CATALOGS,CHANGE,CHAR,CHARACTER,CHECK,CLEAR,CLUSTER,CLUSTERED,CODEGEN,COLLATE,COLLATION,COLLECTION,COLUMN,COLUMNS,COMMENT,COMMIT,COMPACT,COMPACTIONS,COMPENSATION,COMPUTE,CONCATENATE,CONSTRAINT,CONTAINS,COST,CREATE,CROSS,CUBE,CURRENT,CURRENT_DATE,CURRENT_TIME,CURRENT_TIMESTAMP,CURRENT_USER,DATA,DATABASE,DATABASES,DATE,DATEADD,DATEDIFF,DATE_ADD,DATE_DIFF,DAY,DAYOFYEAR,DAYS,DBPROPERTIES,DEC,DECIMAL,DECLARE,DEFAULT,DEFINED,DEFINER,DELETE,DELIMITED,DESC,DESCRIBE,DETERMINISTIC,DFS,DIRECTORIES,DIRECTORY,DISTINCT,DISTRIBUTE,DIV,DOUBLE,DROP,ELSE,END,ESCAPE,ESCAPED,EVOLUTION,EXCEPT,EXCHANGE,EXCLUDE,EXECUTE,EXISTS,EXPLAIN,EXPORT,EXTENDED,EXTERNAL,EXTRACT,FALSE,FETCH,FIELDS,FILEFORMAT,FILTER,FIRST,FLOAT,FOLLOWING,FOR,FOREIGN,FORMAT,FORMATTED,FROM,FULL,FUNCTION,FUNCTIONS,GENERATED,GLOBAL,GRANT,GROUP,GROUPING,HAVING,HOUR,HOURS,IDENTIFIER,IF,IGNORE,ILIKE,IMMEDIATE,IMPORT,IN,INCLUDE,INDEX,INDEXES,INNER,INPATH,INPUT,INPUTFORMAT,INSERT,INT,INTEGER,INTERSECT,INTERVAL,INTO,INVOKER,IS,ITEMS,JOIN,KEYS,LANGUAGE,LAST,LATERAL,LAZY,LEADING,LEFT,LIKE,LIMIT,LINES,LIST,LOAD,LOCAL,LOCATION,LOCK,LOCKS,LOGICAL,LONG,MACRO,MAP,MATCHED,MERGE,MICROSECOND,MICROSECONDS,MILLISECOND,MILLISECONDS,MINUS,MINUTE,MINUTES,MODIFIES,MONTH,MONTHS,MSCK,NAME,NAMESPACE,NAMESPACES,NANOSECOND,NANOSECONDS,NATURAL,NO,NONE,NOT,NULL,NULLS,NUMERIC,OF,OFFSET,ON,ONLY,OPTION,OPTIONS,OR,ORDER,OUT,OUTER,OUTPUTFORMAT,OVER,OVERLAPS,OVERLAY,OVERWRITE,PARTITION,PARTITIONED,PARTITIONS,PERCENT,PIVOT,PLACING,POSITION,PRECEDING,PRIMARY,PRINCIPALS,PROPERTIES,PURGE,QUARTER,QUERY,RANGE,READS,REAL,RECORDREADER,RECORDWRITER,RECOVER,REDUCE,REFERENCES,REFRESH,RENAME,REPAIR,REPEATABLE,REPLACE,RESET,RESPECT,RESTRICT,RETURN,RETURNS,REVOKE,RIGHT,ROLE,ROLES,ROLLBACK,ROLLUP,ROW,ROWS,SCHEMA,SCHEMAS,SECOND,SECONDS,SECURITY,SELECT,SEMI,SEPARATED,SERDE,SERDEPROPERTIES,SESSION_USER,SET,SETS,SHORT,SHOW,SINGLE,SKEWED,SMALLINT,SOME,SORT,SORTED,SOURCE,SPECIFIC,SQL,START,STATISTICS,STORED,STRATIFY,STRING,STRUCT,SUBSTR,SUBSTRING,SYNC,SYSTEM_TIME,SYSTEM_VERSION,TABLE,TABLES,TABLESAMPLE,TARGET,TBLPROPERTIES,TERMINATED,THEN,TIME,TIMEDIFF,TIMESTAMP,TIMESTAMPADD,TIMESTAMPDIFF,TIMESTAMP_LTZ,TIMESTAMP_NTZ,TINYINT,TO,TOUCH,TRAILING,TRANSACTION,TRANSACTIONS,TRANSFORM,TRIM,TRUE,TRUNCATE,TRY_CAST,TYPE,UNARCHIVE,UNBOUNDED,UNCACHE,UNION,UNIQUE,UNKNOWN,UNLOCK,UNPIVOT,UNSET,UPDATE,USE,USER,USING,VALUES,VAR,VARCHAR,VARIABLE,VARIANT,VERSION,VIEW,VIEWS,VOID,WEEK,WEEKS,WHEN,WHERE,WINDOW,WITH,WITHIN,X,YEAR,YEARS,ZONE")
assert(infoValue.getStringValue == "ADD,AFTER,ALL,ALTER,ALWAYS,ANALYZE,AND,ANTI,ANY,ANY_VALUE,ARCHIVE,ARRAY,AS,ASC,AT,AUTHORIZATION,BEGIN,BETWEEN,BIGINT,BINARY,BINDING,BOOLEAN,BOTH,BUCKET,BUCKETS,BY,BYTE,CACHE,CALLED,CASCADE,CASE,CAST,CATALOG,CATALOGS,CHANGE,CHAR,CHARACTER,CHECK,CLEAR,CLUSTER,CLUSTERED,CODEGEN,COLLATE,COLLATION,COLLATIONS,COLLECTION,COLUMN,COLUMNS,COMMENT,COMMIT,COMPACT,COMPACTIONS,COMPENSATION,COMPUTE,CONCATENATE,CONSTRAINT,CONTAINS,COST,CREATE,CROSS,CUBE,CURRENT,CURRENT_DATE,CURRENT_TIME,CURRENT_TIMESTAMP,CURRENT_USER,DATA,DATABASE,DATABASES,DATE,DATEADD,DATEDIFF,DATE_ADD,DATE_DIFF,DAY,DAYOFYEAR,DAYS,DBPROPERTIES,DEC,DECIMAL,DECLARE,DEFAULT,DEFINED,DEFINER,DELETE,DELIMITED,DESC,DESCRIBE,DETERMINISTIC,DFS,DIRECTORIES,DIRECTORY,DISTINCT,DISTRIBUTE,DIV,DOUBLE,DROP,ELSE,END,ESCAPE,ESCAPED,EVOLUTION,EXCEPT,EXCHANGE,EXCLUDE,EXECUTE,EXISTS,EXPLAIN,EXPORT,EXTENDED,EXTERNAL,EXTRACT,FALSE,FETCH,FIELDS,FILEFORMAT,FILTER,FIRST,FLOAT,FOLLOWING,FOR,FOREIGN,FORMAT,FORMATTED,FROM,FULL,FUNCTION,FUNCTIONS,GENERATED,GLOBAL,GRANT,GROUP,GROUPING,HAVING,HOUR,HOURS,IDENTIFIER,IF,IGNORE,ILIKE,IMMEDIATE,IMPORT,IN,INCLUDE,INDEX,INDEXES,INNER,INPATH,INPUT,INPUTFORMAT,INSERT,INT,INTEGER,INTERSECT,INTERVAL,INTO,INVOKER,IS,ITEMS,JOIN,KEYS,LANGUAGE,LAST,LATERAL,LAZY,LEADING,LEFT,LIKE,LIMIT,LINES,LIST,LOAD,LOCAL,LOCATION,LOCK,LOCKS,LOGICAL,LONG,MACRO,MAP,MATCHED,MERGE,MICROSECOND,MICROSECONDS,MILLISECOND,MILLISECONDS,MINUS,MINUTE,MINUTES,MODIFIES,MONTH,MONTHS,MSCK,NAME,NAMESPACE,NAMESPACES,NANOSECOND,NANOSECONDS,NATURAL,NO,NONE,NOT,NULL,NULLS,NUMERIC,OF,OFFSET,ON,ONLY,OPTION,OPTIONS,OR,ORDER,OUT,OUTER,OUTPUTFORMAT,OVER,OVERLAPS,OVERLAY,OVERWRITE,PARTITION,PARTITIONED,PARTITIONS,PERCENT,PIVOT,PLACING,POSITION,PRECEDING,PRIMARY,PRINCIPALS,PROPERTIES,PURGE,QUARTER,QUERY,RANGE,READS,REAL,RECORDREADER,RECORDWRITER,RECOVER,REDUCE,REFERENCES,REFRESH,RENAME,REPAIR,REPEATABLE,REPLACE,RESET,RESPECT,RESTRICT,RETURN,RETURNS,REVOKE,RIGHT,ROLE,ROLES,ROLLBACK,ROLLUP,ROW,ROWS,SCHEMA,SCHEMAS,SECOND,SECONDS,SECURITY,SELECT,SEMI,SEPARATED,SERDE,SERDEPROPERTIES,SESSION_USER,SET,SETS,SHORT,SHOW,SINGLE,SKEWED,SMALLINT,SOME,SORT,SORTED,SOURCE,SPECIFIC,SQL,START,STATISTICS,STORED,STRATIFY,STRING,STRUCT,SUBSTR,SUBSTRING,SYNC,SYSTEM_TIME,SYSTEM_VERSION,TABLE,TABLES,TABLESAMPLE,TARGET,TBLPROPERTIES,TERMINATED,THEN,TIME,TIMEDIFF,TIMESTAMP,TIMESTAMPADD,TIMESTAMPDIFF,TIMESTAMP_LTZ,TIMESTAMP_NTZ,TINYINT,TO,TOUCH,TRAILING,TRANSACTION,TRANSACTIONS,TRANSFORM,TRIM,TRUE,TRUNCATE,TRY_CAST,TYPE,UNARCHIVE,UNBOUNDED,UNCACHE,UNION,UNIQUE,UNKNOWN,UNLOCK,UNPIVOT,UNSET,UPDATE,USE,USER,USING,VALUES,VAR,VARCHAR,VARIABLE,VARIANT,VERSION,VIEW,VIEWS,VOID,WEEK,WEEKS,WHEN,WHERE,WINDOW,WITH,WITHIN,X,YEAR,YEARS,ZONE")
// scalastyle:on line.size.limit
}
}
Expand Down