cloud-fan commented on code in PR #36950:
URL: https://github.com/apache/spark/pull/36950#discussion_r906086065
##########
docs/sql-ref-number-pattern.md:
##########
@@ -19,4 +19,132 @@ license: |
limitations under the License.
---
-TODO: Add the content of Number Patterns for Formatting and Parsing
+### Description
+
+Functions such as `to_number` and `try_to_number` support converting between
values of string and
+Decimal type. Such functions accept format strings indicating how to map
between these types.
+
+### Syntax
+
+Number format strings support the following syntax:
+
+```
+ { ' [ S ] [ $ ]
+ [ 0 | 9 | G | , ] [...]
+ [ . | D ]
+ [ 0 | 9 ] [...]
+ [ $ ] [ PR | MI | S ] ' }
+```
+
+### Elements
+
+Each number format string can contain the following elements (case
insensitive):
+
+- **`0`** or **`9`**
+
+ Specifies an expected digit between `0` and `9`.
+
+ A sequence of 0 or 9 in the format string matches a sequence of digits in
the input string. If the
+ 0/9 sequence starts with 0 and is before the decimal point, it can only
match a digit sequence of
+ the same size. Otherwise, if the sequence starts with 9 or is after the
decimal point, it can
+ match a digit sequence that has the same or smaller size.
Review Comment:
Since this doc is for both parsing and formatting, let's rephrase it a
little bit:
```
A sequence of 0 or 9 in the format string matches a sequence of digits with
the same or smaller size.
If the 0/9 sequence starts with 0 and is before the decimal point, it
requires matching the number of digits:
when parsing only a digit sequence of the same size can be matched, when
formatting the
digit sequence will be left-padded with zeros in the result string to reach
the same size.
Otherwise, the 0/9 sequence can match any digit sequence with the same or
smaller size
when parsing, and pad the digit sequence with spaces in the result string
when formatting.
Note that, the digit sequence will become a '#' sequence if the size is
larger than the 0/9
sequence.
```
--
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]