From ff084e662ca9670710c2d071b135aed7da332433 Mon Sep 17 00:00:00 2001 From: Alexander Kuzmenkov Date: Wed, 21 Jul 2021 14:50:22 +0300 Subject: [PATCH] add more debug to window transform The idea of working with input chunks with different structures doesn't seem sane. Assert that they are totally equal. --- src/Processors/Transforms/WindowTransform.cpp | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/Processors/Transforms/WindowTransform.cpp b/src/Processors/Transforms/WindowTransform.cpp index 43a7e745842..5d50dae1f1b 100644 --- a/src/Processors/Transforms/WindowTransform.cpp +++ b/src/Processors/Transforms/WindowTransform.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -965,10 +966,39 @@ void WindowTransform::writeOutCurrentRow() } } +static void assertSameColumns(const Columns & left_all, + const Columns & right_all) +{ + assert(left_all.size() == right_all.size()); + + for (size_t i = 0; i < left_all.size(); ++i) + { + const auto * left_column = left_all[i].get(); + const auto * right_column = right_all[i].get(); + + assert(left_column); + assert(right_column); + + assert(typeid(*left_column).hash_code() + == typeid(*right_column).hash_code()); + + fmt::print(stderr, "{}\n", typeid(*left_column).name()); + + if (isColumnConst(*left_column)) + { + Field left_value = assert_cast(*left_column).getField(); + Field right_value = assert_cast(*right_column).getField(); + + assert(left_value == right_value); + } + } +} + void WindowTransform::appendChunk(Chunk & chunk) { // fmt::print(stderr, "new chunk, {} rows, finished={}\n", chunk.getNumRows(), // input_is_finished); +// fmt::print(stderr, "chunk structure '{}'\n", chunk.dumpStructure()); // First, prepare the new input block and add it to the queue. We might not // have it if it's end of data, though. @@ -1006,6 +1036,12 @@ void WindowTransform::appendChunk(Chunk & chunk) ->createColumn()); block.output_columns.back()->reserve(block.rows); } + + if (blocks.size() > 1) + { + assertSameColumns(blocks.front().input_columns, + blocks.back().input_columns); + } } // Start the calculations. First, advance the partition end.