Skip to content

Commit

Permalink
Merge pull request #19430 from ClickHouse/fix-14100
Browse files Browse the repository at this point in the history
Fix error Extremes transform was already added to pipeline
  • Loading branch information
alexey-milovidov committed Jan 25, 2021
2 parents 405e9c8 + 70b4199 commit 7197552
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Processors/QueryPipeline.cpp
Expand Up @@ -182,8 +182,11 @@ void QueryPipeline::addExtremesTransform()
{
checkInitializedAndNotCompleted();

/// It is possible that pipeline already have extremes.
/// For example, it may be added from VIEW subquery.
/// In this case, recalculate extremes again - they should be calculated for different rows.
if (pipe.getExtremesPort())
throw Exception("Extremes transform was already added to pipeline.", ErrorCodes::LOGICAL_ERROR);
pipe.dropExtremes();

resize(1);
auto transform = std::make_shared<ExtremesTransform>(getHeader());
Expand Down
16 changes: 16 additions & 0 deletions tests/queries/0_stateless/01660_second_extremes_bug.reference
@@ -0,0 +1,16 @@
{
"meta":
[
{
"name": "a",
"type": "String"
}
],

"data":
[

],

"rows": 0
}
10 changes: 10 additions & 0 deletions tests/queries/0_stateless/01660_second_extremes_bug.sql
@@ -0,0 +1,10 @@
DROP TABLE IF EXISTS t;
DROP TABLE IF EXISTS t_v;

CREATE TABLE t ( a String ) ENGINE = Memory();
CREATE VIEW t_v AS SELECT * FROM t;
SET output_format_write_statistics = 0;
SELECT * FROM t_v FORMAT JSON SETTINGS extremes = 1;

DROP TABLE IF EXISTS t;
DROP TABLE IF EXISTS t_v;

0 comments on commit 7197552

Please sign in to comment.