panbingkun commented on code in PR #48087:
URL: https://github.com/apache/spark/pull/48087#discussion_r1759017567


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/generators.scala:
##########
@@ -618,3 +619,44 @@ 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_() WHERE COLLATION_NAME = 'UTF8_BINARY';
+       SYSTEM  BUILTIN  UTF8_BINARY NULL  NULL  ACCENT_SENSITIVE  
CASE_SENSITIVE  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)

Review Comment:
   Also, I have found an issue. Do we need to register it as a `SQL built-in 
function`? I noticed that some functions in `FunctionRegistry` are both `TVF` 
and `SQL built-in function`, eg:
   
https://github.com/apache/spark/blob/9fc58aa4c0753ef42e0172d73e13b45a00a730f9/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/FunctionRegistry.scala#L370-L371
   
https://github.com/apache/spark/blob/9fc58aa4c0753ef42e0172d73e13b45a00a730f9/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/FunctionRegistry.scala#L1155-L1156
   
   
   
   so we can use them as follows:
   ```sql
   SELECT all_collations();
   ```
   or
   ```sql
   SELECT * FROM all_collations();
   ```



-- 
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]

Reply via email to