Github user chenghao-intel commented on a diff in the pull request:
https://github.com/apache/spark/pull/6762#discussion_r34214228
--- Diff: sql/core/src/main/scala/org/apache/spark/sql/functions.scala ---
@@ -1627,6 +1627,178 @@ object functions {
def ascii(columnName: String): Column = ascii(Column(columnName))
/**
+ * Trim the spaces from both ends for the specified string value.
+ *
+ * @group string_funcs
+ * @since 1.5.0
+ */
+ def trim(e: Column): Column = StringTrim(e.expr)
+
+ /**
+ * Trim the spaces from both ends for the specified column.
+ *
+ * @group string_funcs
+ * @since 1.5.0
+ */
+ def trim(columnName: String): Column = trim(Column(columnName))
+
+ /**
+ * Trim the spaces from left end for the specified string value.
+ *
+ * @group string_funcs
+ * @since 1.5.0
+ */
+ def ltrim(e: Column): Column = StringTrimLeft(e.expr)
+
+ /**
+ * Trim the spaces from left end for the specified column.
+ *
+ * @group string_funcs
+ * @since 1.5.0
+ */
+ def ltrim(columnName: String): Column = ltrim(Column(columnName))
+
+ /**
+ * Trim the spaces from right end for the specified string value.
+ *
+ * @group string_funcs
+ * @since 1.5.0
+ */
+ def rtrim(e: Column): Column = StringTrimRight(e.expr)
+
+ /**
+ * Trim the spaces from right end for the specified column.
+ *
+ * @group string_funcs
+ * @since 1.5.0
+ */
+ def rtrim(columnName: String): Column = rtrim(Column(columnName))
+
+ /**
+ * Format strings in printf-style.
+ *
+ * @group string_funcs
+ * @since 1.5.0
+ */
+ @scala.annotation.varargs
+ def formatString(format: Column, arguments: Column*): Column = {
+ StringFormat((format +: arguments).map(_.expr): _*)
+ }
+
+ /**
+ * Format strings in printf-style.
+ *
+ * @group string_funcs
+ * @since 1.5.0
+ */
+ @scala.annotation.varargs
+ def formatString(format: String, arguments: String*): Column = {
+ StringFormat((format +: arguments).map(Column(_).expr): _*)
--- End diff --
Yes, I know we can do it either way, but will that cause confusing for
pyspark/java user, as they are reply on the column names in string type? I mean
can they call `def formatString(format: Column, arguments: Column*): Column`
directly like the other API?
So my original suggestion is can we add another API with different method
name.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]