fixed MergedColumnOnlyOutputStream

This commit is contained in:
Nikita Vasilev 2019-08-04 21:28:46 +03:00
parent 5804398eae
commit 4c53b90e66
2 changed files with 7 additions and 6 deletions

View File

@ -27,13 +27,13 @@ void MergedColumnOnlyOutputStream::write(const Block & block)
{ {
column_streams.clear(); column_streams.clear();
serialization_states.clear(); serialization_states.clear();
serialization_states.reserve(block.columns()); serialization_states.reserve(header.columns());
WrittenOffsetColumns tmp_offset_columns; WrittenOffsetColumns tmp_offset_columns;
IDataType::SerializeBinaryBulkSettings settings; IDataType::SerializeBinaryBulkSettings settings;
for (size_t i = 0; i < block.columns(); ++i) for (const auto & column_name : header.getNames())
{ {
const auto & col = block.safeGetByPosition(i); const auto & col = block.getByName(column_name);
const auto columns = storage.getColumns(); const auto columns = storage.getColumns();
addStreams(part_path, col.name, *col.type, columns.getCodecOrDefault(col.name, codec), 0, skip_offsets); addStreams(part_path, col.name, *col.type, columns.getCodecOrDefault(col.name, codec), 0, skip_offsets);
@ -71,9 +71,9 @@ void MergedColumnOnlyOutputStream::write(const Block & block)
size_t new_index_offset = 0; size_t new_index_offset = 0;
size_t new_current_mark = 0; size_t new_current_mark = 0;
WrittenOffsetColumns offset_columns = already_written_offset_columns; WrittenOffsetColumns offset_columns = already_written_offset_columns;
for (size_t i = 0; i < block.columns(); ++i) for (size_t i = 0; i < header.columns(); ++i)
{ {
const ColumnWithTypeAndName & column = block.safeGetByPosition(i); const ColumnWithTypeAndName & column = block.getByName(header.getByPosition(i).name);
std::tie(new_current_mark, new_index_offset) = writeColumn(column.name, *column.type, *column.column, offset_columns, skip_offsets, serialization_states[i], current_mark); std::tie(new_current_mark, new_index_offset) = writeColumn(column.name, *column.type, *column.column, offset_columns, skip_offsets, serialization_states[i], current_mark);
} }

View File

@ -47,7 +47,8 @@ $CLICKHOUSE_CLIENT --query="ALTER TABLE test.minmax_idx MATERIALIZE INDEX idx IN
$CLICKHOUSE_CLIENT --query="SELECT count() FROM test.minmax_idx WHERE i64 = 2;" $CLICKHOUSE_CLIENT --query="SELECT count() FROM test.minmax_idx WHERE i64 = 2;"
$CLICKHOUSE_CLIENT --query="SELECT count() FROM test.minmax_idx WHERE i64 = 2 FORMAT JSON" | grep "rows_read" $CLICKHOUSE_CLIENT --query="SELECT count() FROM test.minmax_idx WHERE i64 = 2 FORMAT JSON" | grep "rows_read"
$CLICKHOUSE_CLIENT --query="ALTER TABLE test.minmax_idx CLEAR INDEX idx;" $CLICKHOUSE_CLIENT --query="ALTER TABLE test.minmax_idx CLEAR INDEX idx IN PARTITION 1;"
$CLICKHOUSE_CLIENT --query="ALTER TABLE test.minmax_idx CLEAR INDEX idx IN PARTITION 2;"
$CLICKHOUSE_CLIENT --query="SELECT count() FROM test.minmax_idx WHERE i64 = 2;" $CLICKHOUSE_CLIENT --query="SELECT count() FROM test.minmax_idx WHERE i64 = 2;"
$CLICKHOUSE_CLIENT --query="SELECT count() FROM test.minmax_idx WHERE i64 = 2 FORMAT JSON" | grep "rows_read" $CLICKHOUSE_CLIENT --query="SELECT count() FROM test.minmax_idx WHERE i64 = 2 FORMAT JSON" | grep "rows_read"