-
Notifications
You must be signed in to change notification settings - Fork 3.7k
branch-4.0: [Feature](function) Support function DEFAULT #57531 #60198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
github-actions
wants to merge
1
commit into
branch-4.0
Choose a base branch
from
auto-pick-57531-branch-4.0
base: branch-4.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+971
−0
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
+------------+----------------+-------------------+--------------------+---------------+---------------------+-----------------------------------------+-----------------+------------------+---------------------+---------------------------+----------------+-------------------+------------------+---------------------+-------------+----------------+----------------+----------------+---------------------+------------------------+-----------------------+------------------+-------------------+
```
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
Contributor
|
run buildall |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Cherry-picked from #57531