MartijnVisser commented on code in PR #30200: URL: https://github.com/apache/flink/pull/30200#discussion_r4772844957
########## docs/data/functions/string-and-binary/printf.yml: ########## @@ -0,0 +1,132 @@ +# 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: PRINTF +summary: Returns a string built from a printf-style format string and its arguments. + +syntax: + sql: PRINTF(format [, expr1, expr2, ...]) + java: $("format").printf(expr1, expr2, ...) + python: col("format").printf(expr1, expr2, ...) + +arguments: + - name: format + type: A character string + required: true + description: The text to return, with a format specifier such as `%s` or `%.2f` for each argument. It uses the syntax of `java.util.Formatter`. + - name: expr1, expr2, ... + type: Any type + required: false + description: The values for the format specifiers, in order. Extra values are ignored. + +returns: + description: "`format` with each format specifier replaced by its formatted value, with the conventions of the US locale, such as `,` to group digits and `.` before decimals." + nulls: Returns NULL if `format` is NULL or invalid, if `format` has more specifiers than there are values, or if a specifier doesn't fit the type of its value, such as `%d` for a string. A NULL value doesn't make the result NULL. `%s` prints it as `null`. + type: "`STRING`, nullable." + +notes: + - A `DECIMAL` value with `%f`, `%e` or `%d` returns NULL instead of the number. A literal such as `1.5` is a `DECIMAL` too. Cast the value to `DOUBLE` first, or use `%s`, which prints it with its scale. + - "`%s` prints a `DATE` as its number of days since 1970-01-01 and a `TIME` as its number of milliseconds since midnight, instead of the date or the time. A `TIMESTAMP` prints with a `T` between the date and the time. The `%t` conversions return NULL for all three. Cast the value to `STRING` first." + - The width and the precision count UTF-16 code units, so a character above U+FFFF, such as the emoji `😀`, counts as two. + - "`%s` prints an `ARRAY`, `MAP`, `ROW` or binary string as a Java object reference that changes between runs, instead of its content. Cast the value to `STRING` first." Review Comment: A `CAST` to `STRING` fails at planning for an `ARRAY`, `MAP` or `ROW`, only the binary string works. Please drop that advice for the first three. -- 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]
