Get marks from first non-alias column in Log storage

This commit is contained in:
Ivan Lezhankin 2020-02-19 21:06:18 +03:00
parent a47c52a909
commit 894c451cf0
3 changed files with 18 additions and 2 deletions

View File

@ -540,8 +540,16 @@ void StorageLog::truncate(const ASTPtr &, const Context &, TableStructureWriteLo
const StorageLog::Marks & StorageLog::getMarksWithRealRowCount() const
{
const String & column_name = getColumns().begin()->name;
const IDataType & column_type = *getColumns().begin()->type;
/// There should be at least one physical column
auto begin = getColumns().begin();
while (begin != getColumns().end() && begin->default_desc == ColumnDefaultKind::Alias)
++begin;
if (begin == getColumns().end())
throw Exception("No physical columns found!", ErrorCodes::LOGICAL_ERROR);
const String & column_name = begin->name;
const IDataType & column_type = *begin->type;
String filename;
/** We take marks from first column.

View File

@ -0,0 +1,7 @@
DROP TABLE IF EXISTS test_alias;
CREATE TABLE test_alias (a UInt8 ALIAS b, b UInt8) ENGINE Log;
SELECT count() FROM test_alias;
DROP TABLE test_alias;