Github user twalthr commented on a diff in the pull request:
https://github.com/apache/flink/pull/4127#discussion_r127995503
--- Diff:
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/runtime/functions/ScalarFunctions.scala
---
@@ -82,4 +82,102 @@ object ScalarFunctions {
}
sb.toString
}
+
+ /**
+ * Returns the string str, left-padded with the string pad to a length
of len characters.
+ * If str is longer than len, the return value is shortened to len
characters.
+ */
+ def lpad(base: String, len: Integer, pad: String): String = {
+ if (base == null || len == null || pad == null) {
+ return null
+ }
+ var data = "".getBytes
+ if (data.length < len) {
+ data = new Array[Byte](len)
+ }
+ val baseBytes = base.getBytes
+ val padBytes = pad.getBytes
+
+ // The length of the padding needed
+ val pos = Math.max(len - base.length, 0)
+
+ // Copy the padding
+ var i = 0
+
+ while (i < pos) {
+ {
+ var j = 0
+ while (j < pad.length && j < pos - i) {
+ {
+ data(i + j) = padBytes(j)
+ }
+ {
+ j += 1;
+ j - 1
--- End diff --
Isn't this expression useless?
---
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.
---