raminqaf commented on code in PR #30200:
URL: https://github.com/apache/flink/pull/30200#discussion_r4783549825


##########
docs/data/functions/string-and-binary/rpad.yml:
##########
@@ -0,0 +1,104 @@
+# 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
+
+name: RPAD
+summary: Returns a string padded on the right to a given length.
+
+syntax:
+  sql: RPAD(str, len, pad_str)
+  java: $("str").rpad(len, padStr)
+  python: col("str").rpad(len, pad_str)
+
+arguments:
+  - name: str
+    type: A character string
+    required: true
+    description: The string to pad.
+  - name: len
+    type: TINYINT, SMALLINT, INT
+    required: true
+    description: The length of the result, in characters.
+  - name: pad_str
+    type: A character string
+    required: true
+    description: The string to pad with. It is repeated as often as needed, 
and its last copy is cut to fit.
+
+returns:
+  description: "`str` with `pad_str` added on the right until the result has 
`len` characters. If `str` is longer than `len`, its first `len` characters."
+  nulls: Returns NULL if any argument is NULL, if `len` is negative, or if 
`pad_str` is an empty string.
+  type: "`STRING`, NOT NULL if all arguments are NOT NULL."
+
+notes:
+  - With NOT NULL arguments, a negative `len` or an empty `pad_str` still 
returns NULL, although the type is NOT NULL. Selecting the result then fails 
the job, `COALESCE` doesn't replace the NULL, and `CHAR_LENGTH` of it returns 
`-1` instead of NULL. A check with `IS NULL` isn't reliable either. `CASE WHEN 
... IS NULL` takes its ELSE branch, and `WHERE ... IS NOT NULL` keeps the row. 
Check the arguments instead, as in `CASE WHEN len < 0 OR pad_str = '' THEN NULL 
ELSE RPAD(str, len, pad_str) END`.

Review Comment:
   Done, as for LPAD.



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

Reply via email to