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
14 changes: 13 additions & 1 deletion be/src/exec/schema_scanner/schema_columns_scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,19 @@ Status SchemaColumnsScanner::_fill_block_impl(vectorized::Block* block) {
RETURN_IF_ERROR(fill_dest_column_for_range(block, 4, datas));
}
// COLUMN_DEFAULT
{ RETURN_IF_ERROR(fill_dest_column_for_range(block, 5, null_datas)); }
{
std::vector<StringRef> strs(columns_num);
for (int i = 0; i < columns_num; ++i) {
if (_desc_result.columns[i].columnDesc.__isset.defaultValue) {
strs[i] = StringRef(_desc_result.columns[i].columnDesc.defaultValue.c_str(),
_desc_result.columns[i].columnDesc.defaultValue.length());
datas[i] = strs.data() + i;
} else {
datas[i] = nullptr;
}
}
RETURN_IF_ERROR(fill_dest_column_for_range(block, 5, datas));
}
// IS_NULLABLE
{
StringRef str_yes = StringRef("YES", 3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,10 @@ private TColumnDesc getColumnDesc(Column column) {
}
desc.setChildren(children);
}
String defaultValue = column.getDefaultValue();
if (defaultValue != null) {
desc.setDefaultValue(defaultValue);
}
return desc;
}

Expand Down
1 change: 1 addition & 0 deletions gensrc/thrift/FrontendService.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ struct TColumnDesc {
6: optional bool isAllowNull
7: optional string columnKey
8: optional list<TColumnDesc> children
9: optional string defaultValue
}

// A column definition; used by CREATE TABLE and DESCRIBE <table> statements. A column
Expand Down
7 changes: 7 additions & 0 deletions regression-test/data/account_p0/test_information_schema.out
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,10 @@
-- !sql --
DUP

-- !default --
id largeint YES \N
name varchar(20) YES 无
age smallint(6) YES 0
address varchar(100) YES beijing
date datetime YES 20240101

22 changes: 22 additions & 0 deletions regression-test/suites/account_p0/test_information_schema.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,26 @@ suite("test_information_schema") {
def dbName = dbPrefix + i.toString()
sql "DROP DATABASE `${dbName}`"
}

def dbName = dbPrefix + "default"
def tableName = tablePrefix + "default"
sql "CREATE DATABASE IF NOT EXISTS `${dbName}`"
sql "USE `${dbName}`"
sql """drop table if exists `${tableName}`"""
sql """
CREATE TABLE `${tableName}` (
`id` largeint NULL COMMENT '用户ID',
`name` varchar(20) NULL DEFAULT "无" COMMENT '用户姓名',
`age` smallint NULL DEFAULT "0" COMMENT '用户年龄',
`address` varchar(100) NULL DEFAULT "beijing" COMMENT '用户所在地区',
`date` datetime NULL DEFAULT "20240101" COMMENT '数据导入时间'
) ENGINE=OLAP
DUPLICATE KEY(`id`, `name`)
DISTRIBUTED BY HASH(`id`) BUCKETS 1
PROPERTIES (
"replication_allocation" = "tag.location.default: 1")
"""
qt_default "SELECT COLUMN_NAME as field,COLUMN_TYPE as type,IS_NULLABLE as isNullable, COLUMN_DEFAULT as defaultValue FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '${tableName}' AND TABLE_SCHEMA = '${dbName}'"
sql "DROP DATABASE `${dbName}`"
}

Loading