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
16 changes: 16 additions & 0 deletions src/Storages/StatisticsDescription.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,20 @@ ASTPtr ColumnStatisticsDescription::getAST() const
return function_node;
}

String ColumnStatisticsDescription::getNameForLogs() const
{
String ret;
for (const auto & [tp, desc] : types_to_desc)
{
ret += desc.getTypeName();
if (desc.is_implicit)
ret += "(auto)";
ret += ",";
}
if (!ret.empty())
ret.pop_back();
return ret;
}


}
2 changes: 2 additions & 0 deletions src/Storages/StatisticsDescription.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ struct ColumnStatisticsDescription

ASTPtr getAST() const;

String getNameForLogs() const;

/// get a vector of <column name, statistics desc> pair
static std::vector<std::pair<String, ColumnStatisticsDescription>> fromAST(const ASTPtr & definition_ast, const ColumnsDescription & columns);
static ColumnStatisticsDescription fromStatisticsDescriptionAST(const ASTPtr & statistics_desc, const String & column_name, DataTypePtr data_type);
Expand Down
8 changes: 8 additions & 0 deletions src/Storages/System/StorageSystemColumns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ StorageSystemColumns::StorageSystemColumns(const StorageID & table_id_)
{ "datetime_precision", std::make_shared<DataTypeNullable>(std::make_shared<DataTypeUInt64>()),
"Decimal precision of DateTime64 data type. For other data types, the NULL value is returned."},
{ "serialization_hint", std::make_shared<DataTypeNullable>(std::make_shared<DataTypeString>()), "A hint for column to choose serialization on inserts according to statistics."},
{ "statistics", std::make_shared<DataTypeString>(), "The types of statistics created in this columns."}
});

description.setAliases({
Expand Down Expand Up @@ -331,6 +332,13 @@ class ColumnsSource : public ISource
res_columns[res_index++]->insertDefault();
}

/// statistics
if (columns_mask[src_index++])
{
const ColumnStatisticsDescription & stats = column.statistics;
res_columns[res_index++]->insert(stats.getNameForLogs());
}

++rows_count;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
test_01602a CREATE TEMPORARY TABLE test_01602a (`x` UInt32) ENGINE = Memory Memory Memory 1
test_01602b CREATE TEMPORARY TABLE test_01602b (`y` Float64, `z` String) ENGINE = Memory Memory Memory 1
test_01602a x UInt32 1 0 0 0 0 0 0 0 \N 32 2 0 \N \N
test_01602b y Float64 1 0 0 0 0 0 0 0 \N \N \N \N \N \N
test_01602b z String 2 0 0 0 0 0 0 0 \N \N \N \N \N \N
test_01602a x UInt32 1 0 0 0 0 0 0 0 \N 32 2 0 \N \N
test_01602b y Float64 1 0 0 0 0 0 0 0 \N \N \N \N \N \N
test_01602b z String 2 0 0 0 0 0 0 0 \N \N \N \N \N \N
CREATE TEMPORARY TABLE test_01602a\n(\n `x` UInt32\n)\nENGINE = Memory
CREATE TEMPORARY TABLE test_01602b\n(\n `y` Float64,\n `z` String\n)\nENGINE = Memory
0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ CREATE TABLE system.columns
`numeric_scale` Nullable(UInt64),
`datetime_precision` Nullable(UInt64),
`serialization_hint` Nullable(String),
`statistics` String,
`column` String ALIAS name
)
ENGINE = SystemColumns
Expand Down
Loading