Skip to content

Commit

Permalink
[native] Update docs for VARCHAR type length value
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
czentgr committed Nov 29, 2024
1 parent 8ea5aea commit ec7e444
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions presto-docs/src/main/sphinx/language/types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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``
Expand Down Expand Up @@ -103,7 +103,7 @@ 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.
are treated as values of the ``DOUBLE`` type by default up to version 0.198.
After 0.198 they are parsed as DECIMAL.

- System wide property: ``parse-decimal-literals-as-double``
Expand All @@ -115,10 +115,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 !'``
Expand All @@ -144,10 +148,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.'``


Expand Down

0 comments on commit ec7e444

Please sign in to comment.