Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@ public void validate(Set<String> keysSet, boolean isEnableMergeOnWrite, KeysType
} else if (type.isArrayType() && !defaultValue.isPresent()) {
defaultValue = Optional.of(DefaultValue.ARRAY_EMPTY_DEFAULT_VALUE);
}
if (defaultValue.isPresent() && type.toCatalogDataType().isScalarType()) {
if (defaultValue.isPresent()
&& defaultValue.get().getValue() != null
&& type.toCatalogDataType().isScalarType()) {
try {
ColumnDef.validateDefaultValue(type.toCatalogDataType(),
defaultValue.get().getValue(), defaultValue.get().getDefaultValueExprDef());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,8 @@
5 false 3 4 5 6 7
13 true 4 5 6 7 8

-- !sql --
1 true 2 2023-02-13T00:00
5 false 3 2023-02-13T00:00
13 true 4 2023-02-13T00:00

7 changes: 6 additions & 1 deletion regression-test/suites/nereids_p0/create_table/ddl/data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,9 @@ insert into test_list_partition values
insert into test_rollup values
(1, true, 2, 3, 4, 5, 6),
(5, false, 3, 4, 5, 6, 7),
(13, true, 4, 5, 6, 7, 8);
(13, true, 4, 5, 6, 7, 8);

insert into test_default_value values
(1, true, 2, '2023-02-13'),
(5, false, 3, '2023-02-13'),
(13, true, 4, '2023-02-13');
12 changes: 12 additions & 0 deletions regression-test/suites/nereids_p0/create_table/ddl/table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,18 @@ distributed by random buckets auto
rollup (
r1 (id, ktint, kbool, ktint, kbint) duplicate key(id)
)
properties (
"replication_num"="1"
);

drop table if exists test_default_value;
create table test_default_value (
`id` int not null,
`kbool` boolean not null,
`ktint` tinyint(4) default null,
`kdtmv2` datetimev2(0) default current_timestamp
)
distributed by hash(id)
properties (
"replication_num"="1"
);
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ suite("nereids_create_table") {
}
sql 'sync'
def tables = ['test_all_types', 'test_agg_key', 'test_uni_key', 'test_uni_key_mow', 'test_not_null',
'test_random', 'test_random_auto', 'test_less_than_partition', 'test_range_partition',
'test_step_partition', 'test_date_step_partition', 'test_list_partition', 'test_rollup']
'test_random', 'test_random_auto', 'test_less_than_partition', 'test_range_partition',
'test_step_partition', 'test_date_step_partition', 'test_list_partition', 'test_rollup',
'test_default_value']
for (String t in tables) {
qt_sql "select * from ${t} order by id"
}
Expand Down