Skip to content

Conversation

@github-actions
Copy link
Contributor

Cherry-picked from #57531

Return the default value of column

```sql
CREATE TABLE test_default_scalar (
    c_id INT,
    c_bool                   BOOLEAN                               NULL     DEFAULT 1,
    c_tinyint                TINYINT                               NULL     DEFAULT 7,
    c_smallint               SMALLINT                              NULL     DEFAULT 32000,
    c_int                    INT                                   NULL     DEFAULT 2147483647,
    c_bigint                 BIGINT                                NULL     DEFAULT 9223372036854775807,
    c_largeint               LARGEINT                              NULL     DEFAULT '170141183460469231731687303715884105727',
    c_float                  FLOAT                                 NULL     DEFAULT 3.125,
    c_double                 DOUBLE                                NULL     DEFAULT 2.718281828,
    c_decimal                DECIMAL(27, 9)                        NULL     DEFAULT '123456789.123456789',
    c_decimal_compact        DECIMAL(18, 4)                        NULL     DEFAULT '99999.1234',
    c_pi                     DOUBLE                                NULL     DEFAULT PI,
    c_e                      DOUBLE                                NULL     DEFAULT E,
    c_char                   CHAR(8)                               NULL     DEFAULT 'charDemo',
    c_varchar                VARCHAR(32)                           NULL     DEFAULT '',
    c_string                 STRING                                NULL     DEFAULT 'plain string',
    c_datetime               DATETIME                              NULL     DEFAULT '2025-10-25 11:22:33',
    c_date                   DATE                                  NULL     DEFAULT '2025-10-31',
    c_json                   JSON                                  NULL,
    c_ipv4                   IPV4                                  NULL     DEFAULT '192.168.1.1',
    c_ipv6                   IPV6                                  NULL     DEFAULT '2001:db8::1',
    c_array_int              ARRAY<INT>                            NULL     DEFAULT '[]',
    c_array_string           ARRAY<STRING>                         NULL,
    c_map_str_int            MAP<STRING, INT>                      NULL,
    c_struct                 STRUCT<f1:INT,f2:STRING,f3:BOOLEAN>   NULL,
    c_variant                VARIANT                               NULL
) PROPERTIES ( 'replication_num' = '1');

SELECT
    default(c_id)                   AS default_id,
    default(c_bool)                 AS default_c_bool,
    default(c_tinyint)              AS default_c_tinyint,
    default(c_smallint)             AS default_c_smallint,
    default(c_int)                  AS default_c_int,
    default(c_bigint)               AS default_c_bigint,
    default(c_largeint)             AS default_c_largeint,
    default(c_float)                AS default_c_float,
    default(c_double)               AS default_c_double,
    default(c_decimal)              AS default_c_decimal,
    default(c_decimal_compact)      AS default_c_decimal_compact,
    default(c_char)                 AS default_c_char,
    default(c_varchar)              AS default_c_varchar,
    default(c_string)               AS default_c_string,
    default(c_datetime)             AS default_datetime,
    default(c_date)                 AS defaut_time,
    default(c_json)                 AS default_c_json,
    default(c_ipv4)                 AS default_c_ipv4,
    default(c_ipv6)                 AS default_c_ipv6,
    default(c_array_int)            AS default_c_array_int,
    default(c_array_string)         AS default_c_array_string,
    default(c_map_str_int)          AS default_c_map_str_int,
    default(c_struct)               AS default_c_struct,
    default(c_variant)              AS default_c_variant
FROM test_default_scalar
LIMIT 1;
```
```text
+------------+----------------+-------------------+--------------------+---------------+---------------------+-----------------------------------------+-----------------+------------------+---------------------+---------------------------+----------------+-------------------+------------------+---------------------+-------------+----------------+----------------+----------------+---------------------+------------------------+-----------------------+------------------+-------------------+
| default_id | default_c_bool | default_c_tinyint | default_c_smallint | default_c_int | default_c_bigint    | default_c_largeint                      | default_c_float | default_c_double | default_c_decimal   | default_c_decimal_compact | default_c_char | default_c_varchar | default_c_string | default_datetime    | defaut_time | default_c_json | default_c_ipv4 | default_c_ipv6 | default_c_array_int | default_c_array_string | default_c_map_str_int | default_c_struct | default_c_variant |
+------------+----------------+-------------------+--------------------+---------------+---------------------+-----------------------------------------+-----------------+------------------+---------------------+---------------------------+----------------+-------------------+------------------+---------------------+-------------+----------------+----------------+----------------+---------------------+------------------------+-----------------------+------------------+-------------------+
|       NULL |              1 |                 7 |              32000 |    2147483647 | 9223372036854775807 | 170141183460469231731687303715884105727 |           3.125 |      2.718281828 | 123456789.123456789 |                99999.1234 | charDemo       |                   | plain string     | 2025-10-25 11:22:33 | 2025-10-31  | NULL           | 192.168.1.1    | 2001:db8::1    | []                  | NULL                   | NULL                  | NULL             | NULL              |
+------------+----------------+-------------------+--------------------+---------------+---------------------+-----------------------------------------+-----------------+------------------+---------------------+---------------------------+----------------+-------------------+------------------+---------------------+-------------+----------------+----------------+----------------+---------------------+------------------------+-----------------------+------------------+-------------------+
```
@github-actions github-actions bot requested a review from yiguolei as a code owner January 23, 2026 17:14
@Thearas
Copy link
Contributor

Thearas commented Jan 23, 2026

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@dataroaring dataroaring reopened this Jan 23, 2026
@Thearas
Copy link
Contributor

Thearas commented Jan 23, 2026

run buildall

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants