mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 09:32:06 +00:00
Column default dictGet identifier fix
This commit is contained in:
parent
43102e8427
commit
a87ffdff92
@ -63,8 +63,11 @@ void addDefaultRequiredExpressionsRecursively(
|
||||
for (const auto & next_required_column_name : required_columns_names)
|
||||
addDefaultRequiredExpressionsRecursively(block, next_required_column_name, required_column_type, columns, default_expr_list_accum, added_columns, null_as_default);
|
||||
}
|
||||
else
|
||||
else if (columns.has(required_column_name))
|
||||
{
|
||||
/// In case of dictGet function we allow to use it with identifier dictGet(identifier, 'column_name', key_expression)
|
||||
/// and this identifier will be in required columns. If such column is not in ColumnsDescription we ignore it.
|
||||
|
||||
/// This column is required, but doesn't have default expression, so lets use "default default"
|
||||
auto column = columns.get(required_column_name);
|
||||
auto default_value = column.type->getDefault();
|
||||
|
@ -0,0 +1 @@
|
||||
5 0
|
@ -0,0 +1,37 @@
|
||||
DROP TABLE IF EXISTS test_table;
|
||||
CREATE TABLE test_table
|
||||
(
|
||||
key_column UInt64,
|
||||
data_column_1 UInt64,
|
||||
data_column_2 UInt8
|
||||
)
|
||||
ENGINE = MergeTree
|
||||
ORDER BY key_column;
|
||||
|
||||
INSERT INTO test_table VALUES (0, 0, 0);
|
||||
|
||||
DROP DICTIONARY IF EXISTS test_dictionary;
|
||||
CREATE DICTIONARY test_dictionary
|
||||
(
|
||||
key_column UInt64 DEFAULT 0,
|
||||
data_column_1 UInt64 DEFAULT 1,
|
||||
data_column_2 UInt8 DEFAULT 1
|
||||
)
|
||||
PRIMARY KEY key_column
|
||||
LAYOUT(DIRECT())
|
||||
SOURCE(CLICKHOUSE(TABLE 'test_table'));
|
||||
|
||||
DROP TABLE IF EXISTS test_table_default;
|
||||
CREATE TABLE test_table_default
|
||||
(
|
||||
data_1 DEFAULT dictGetUInt64('test_dictionary', 'data_column_1', toUInt64(0)),
|
||||
data_2 DEFAULT dictGet(test_dictionary, 'data_column_2', toUInt64(0))
|
||||
)
|
||||
ENGINE=TinyLog;
|
||||
|
||||
INSERT INTO test_table_default(data_1) VALUES (5);
|
||||
SELECT * FROM test_table_default;
|
||||
|
||||
DROP DICTIONARY test_dictionary;
|
||||
DROP TABLE test_table;
|
||||
DROP TABLE test_table_default;
|
Loading…
Reference in New Issue
Block a user