Inject default column

This commit is contained in:
alesapin 2018-11-28 20:21:27 +03:00
parent 23aa6595cd
commit d4059ba507

View File

@ -1,4 +1,5 @@
#include <Storages/MergeTree/MergeTreeSequentialBlockInputStream.h>
#include <Storages/MergeTree/MergeTreeBlockReadUtils.h>
namespace DB
{
@ -28,14 +29,15 @@ MergeTreeSequentialBlockInputStream::MergeTreeSequentialBlockInputStream(
addTotalRowsApprox(data_part->rows_count);
header = storage.getSampleBlockForColumns(columns_to_read);
LOG_INFO(log, "Reading columns:" << header.dumpNames());
fixHeader(header);
LOG_INFO(log, "Reading columns(after fix):" << header.dumpNames());
const NamesAndTypesList & physical_columns = storage.getColumns().getAllPhysical();
auto column_names_with_helper_columns = columns_to_read;
injectRequiredColumns(storage, data_part, column_names_with_helper_columns);
reader = std::make_unique<MergeTreeReader>(
data_part->getFullPath(), data_part, header.getNamesAndTypesList(), /* uncompressed_cache = */ nullptr,
data_part->getFullPath(), data_part, physical_columns.addTypes(column_names_with_helper_columns), /* uncompressed_cache = */ nullptr,
mark_cache.get(), /* save_marks_in_cache = */ false, storage,
MarkRanges{MarkRange(0, data_part->marks_count)},
/* bytes to use AIO */ read_with_direct_io ? 1UL : std::numeric_limits<size_t>::max(),
@ -46,7 +48,6 @@ MergeTreeSequentialBlockInputStream::MergeTreeSequentialBlockInputStream(
void MergeTreeSequentialBlockInputStream::fixHeader(Block & header_block) const
{
/// Types may be different during ALTER (when this stream is used to perform an ALTER).
/// NOTE: We may use similar code to implement non blocking ALTERs.
for (const auto & name_type : data_part->columns)
{
if (header_block.has(name_type.name))
@ -80,7 +81,6 @@ try
current_row += rows_readed;
current_mark += (rows_readed / storage.index_granularity);
bool should_reorder = false, should_evaluate_missing_defaults = false;
LOG_INFO(log, "Block before filling: " << res.dumpStructure());
reader->fillMissingColumns(res, should_reorder, should_evaluate_missing_defaults, res.rows());
if (res && should_evaluate_missing_defaults)