MaxGekk commented on code in PR #48087:
URL: https://github.com/apache/spark/pull/48087#discussion_r1758580992
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/generators.scala:
##########
@@ -618,3 +619,45 @@ case class SQLKeywords() extends LeafExpression with
Generator with CodegenFallb
override def prettyName: String = "sql_keywords"
}
+
+@ExpressionDescription(
+ usage = """_FUNC_() - Get all of the Spark SQL string collations""",
+ examples = """
+ Examples:
+ > SELECT * FROM _FUNC_() LIMIT 2;
+ SYSTEM BUILTIN UTF8_BINARY NULL NULL ACCENT_SENSITIVE
CASE_SENSITIVE NO_PAD NULL
+ SYSTEM BUILTIN UTF8_LCASE NULL NULL ACCENT_SENSITIVE
CASE_INSENSITIVE NO_PAD NULL
+ """,
+ since = "4.0.0",
+ group = "generator_funcs")
+case class AllCollations() extends LeafExpression with Generator with
CodegenFallback {
+ override def elementSchema: StructType = new StructType()
+ .add("COLLATION_CATALOG", StringType, nullable = false)
+ .add("COLLATION_SCHEMA", StringType, nullable = false)
+ .add("COLLATION_NAME", StringType, nullable = false)
+ .add("LANGUAGE", StringType)
+ .add("COUNTRY", StringType)
+ .add("ACCENT_SENSITIVITY", StringType, nullable = false)
+ .add("CASE_SENSITIVITY", StringType, nullable = false)
+ .add("PAD_ATTRIBUTE", StringType, nullable = false)
+ .add("ICU_VERSION", StringType)
+
+ override def eval(input: InternalRow): IterableOnce[InternalRow] = {
+
CollationFactory.listCollations().asScala.map(CollationFactory.loadCollationMeta).map
{ m =>
+ InternalRow(
+ UTF8String.fromString(m.catalog),
+ UTF8String.fromString(m.schema),
+ UTF8String.fromString(m.collationName),
+ if (m.language != null) UTF8String.fromString(m.language) else null,
Review Comment:
`fromString()` does null-checking, not need to check this additionally, see:
```java
public static UTF8String fromString(String str) {
return str == null ? null :
fromBytes(str.getBytes(StandardCharsets.UTF_8));
}
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]