From 0f12e028a58d573628e55881f4d7de57acfc8c01 Mon Sep 17 00:00:00 2001 From: alesapin Date: Thu, 20 Sep 2018 15:59:33 +0300 Subject: [PATCH] Fix insert for native format --- .../DataStreams/IProfilingBlockInputStream.cpp | 18 ++++++++---------- .../Interpreters/InterpreterInsertQuery.cpp | 15 +++++++++++---- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/dbms/src/DataStreams/IProfilingBlockInputStream.cpp b/dbms/src/DataStreams/IProfilingBlockInputStream.cpp index f4664ba7f16..998ea2b42db 100644 --- a/dbms/src/DataStreams/IProfilingBlockInputStream.cpp +++ b/dbms/src/DataStreams/IProfilingBlockInputStream.cpp @@ -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; } diff --git a/dbms/src/Interpreters/InterpreterInsertQuery.cpp b/dbms/src/Interpreters/InterpreterInsertQuery.cpp index 55b199f0bc3..89437cec927 100644 --- a/dbms/src/Interpreters/InterpreterInsertQuery.cpp +++ b/dbms/src/Interpreters/InterpreterInsertQuery.cpp @@ -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)