Fix insert for native format

This commit is contained in:
alesapin 2018-09-20 15:59:33 +03:00
parent dfa3e7e1cd
commit 0f12e028a5
2 changed files with 19 additions and 14 deletions

View File

@ -81,16 +81,14 @@ Block IProfilingBlockInputStream::read()
progress(Progress(res.rows(), res.bytes()));
/// This code commented, because some streams (for example Native) break this
/// protocol. This must be fixed.
//#ifndef NDEBUG
// if (res)
// {
// Block header = getHeader();
// if (header)
// assertBlocksHaveEqualStructure(res, header, getName());
// }
//#endif
#ifndef NDEBUG
if (res)
{
Block header = getHeader();
if (header)
assertBlocksHaveEqualStructure(res, header, getName());
}
#endif
return res;
}

View File

@ -54,13 +54,20 @@ StoragePtr InterpreterInsertQuery::getTable(const ASTInsertQuery & query)
Block InterpreterInsertQuery::getSampleBlock(const ASTInsertQuery & query, const StoragePtr & table)
{
Block table_sample = table->getSampleBlock();
/// If the query does not include information about columns
if (!query.columns)
return table_sample;
Block table_sample_non_materialized = table->getSampleBlockNonMaterialized();
/// If the query does not include information about columns
if (!query.columns)
{
/// Fromat Native ignores header and write blocks as is.
if (query.format == "Native")
return {};
else
return table_sample_non_materialized;
}
Block table_sample = table->getSampleBlock();
/// Form the block based on the column names from the query
Block res;
for (const auto & identifier : query.columns->children)