From 2f21cb7c11832d0041ec50bc63a48fdfa6cee028 Mon Sep 17 00:00:00 2001 From: Christian Zentgraf Date: Mon, 2 Dec 2024 12:15:18 -0500 Subject: [PATCH] [native] Update docs for VARCHAR type length value The documentation does not clearly indicate what the length value in the varchar type definition means. Clear up that it is the number of characters and not the number of bytes. Do some cleanup for DECIMAL type documentation. --- .../src/main/sphinx/language/types.rst | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/presto-docs/src/main/sphinx/language/types.rst b/presto-docs/src/main/sphinx/language/types.rst index 9a58f281c80e3..01a89d6cd4a75 100644 --- a/presto-docs/src/main/sphinx/language/types.rst +++ b/presto-docs/src/main/sphinx/language/types.rst @@ -28,7 +28,7 @@ Integer .. note:: - Cast conversion functions allow leading and trailing spaces when casting + Cast conversion functions allow leading and trailing spaces when casting a string to ``TINYINT``, ``SMALLINT``, ``INTEGER``, or ``BIGINT``. ``TINYINT`` @@ -102,9 +102,10 @@ Example literals: ``DECIMAL '10.3'``, ``DECIMAL '1234567890'``, ``1.1`` .. note:: - For compatibility reasons decimal literals without explicit type specifier (e.g. ``1.2``) - are treated as values of the ``DOUBLE`` type by default up to version 0.198. - After 0.198 they are parsed as DECIMAL. + Decimal literals without explicit type specifier such as ``1.2`` + are parsed as values of the ``DECIMAL`` type by default. + To change the behavior and parse such values as ``DOUBLE`` type set + the following property to ``true``: - System wide property: ``parse-decimal-literals-as-double`` - Session wide property: ``parse_decimal_literals_as_double`` @@ -115,10 +116,14 @@ String ``VARCHAR`` ^^^^^^^^^^^ -Variable length character data with an optional maximum length. +Variable length character data with an optional maximum length indicating +the maximum number of characters allowed. Example type definitions: ``varchar``, ``varchar(20)``. +For ``varchar(20)`` the length value indicates that the string data may +consist of up to 20 characters. + SQL supports simple and Unicode string literals: - Literal string : ``'Hello winter !'`` - Unicode string with default escape character: ``U&'Hello winter \2603 !'`` @@ -144,10 +149,10 @@ equal, but comparison of such values implicitly converts the types to the same length and pads with spaces so that the following query returns `true`: ``SELECT cast('example' AS char(20)) = cast('example ' AS char(25));`` - + As with `VARCHAR`, a single quote in a `CHAR` literal can be escaped with another single quote: - + ``SELECT CHAR 'All right, Mr. DeMille, I''m ready for my close-up.'``