Skip to content

Commit

Permalink
[GLUTEN-7220][CH]Fix expand bug in grouping sets query (apache#7221)
Browse files Browse the repository at this point in the history
* fix grouping set

* remove useless code
  • Loading branch information
KevinyhZou authored and shamirchen committed Oct 14, 2024
1 parent 6f9cf39 commit cb926ad
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1415,4 +1415,5 @@ class GlutenClickHouseHiveTableSuite
runQueryAndCompare(selectSql)(df => checkOperatorCount[ProjectExecTransformer](3)(df))
spark.sql("DROP TABLE test_tbl_7054")
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2991,5 +2991,17 @@ class GlutenClickHouseTPCHSaltNullParquetSuite extends GlutenClickHouseTPCHAbstr
checkGlutenOperatorMatch[ProjectExecTransformer]
}
}

test("GLUTEN-7220: Fix bug of grouping sets") {
val table_create_sql = "create table test_tbl_7220(id bigint, name string) using parquet"
val insert_data_sql = "insert into test_tbl_7220 values(1, 'a123'), (2, 'a124'), (3, 'a125')"
val query_sql = "select '2024-08-26' as day, id,name from" +
" (select id, name from test_tbl_7220 group by id, name grouping sets((id),(id,name))) " +
" where name = 'a124'"
spark.sql(table_create_sql)
spark.sql(insert_data_sql)
compareResultsAgainstVanillaSpark(query_sql, true, { _ => })
spark.sql("drop table test_tbl_7220")
}
}
// scalastyle:on line.size.limit
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <Core/ColumnsWithTypeAndName.h>
#include <DataTypes/DataTypeNullable.h>
#include <DataTypes/DataTypesNumber.h>
#include <Operator/ExpandTransorm.h>
#include <Operator/ExpandTransform.h>
#include <Processors/Chunk.h>
#include <Processors/IProcessor.h>
#include <Processors/Transforms/AggregatingTransform.h>
Expand Down
2 changes: 1 addition & 1 deletion cpp-ch/local-engine/Operator/ExpandStep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <Core/ColumnsWithTypeAndName.h>
#include <DataTypes/DataTypeNullable.h>
#include <DataTypes/DataTypesNumber.h>
#include <Operator/ExpandTransorm.h>
#include <Operator/ExpandTransform.h>
#include <Processors/IProcessor.h>
#include <QueryPipeline/Pipe.h>
#include <QueryPipeline/QueryPipelineBuilder.h>
Expand Down
6 changes: 3 additions & 3 deletions cpp-ch/local-engine/Operator/ExpandTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <Common/Exception.h>
#include <Common/logger_useful.h>

#include "ExpandTransorm.h"
#include "ExpandTransform.h"

namespace DB
{
Expand Down Expand Up @@ -122,8 +122,8 @@ void ExpandTransform::work()
else if (kind == EXPAND_FIELD_KIND_LITERAL)
{
/// Add const column with field value
auto column = type->createColumnConst(rows, field);
columns[col_i] = column;
auto column = type->createColumnConst(rows, field)->convertToFullColumnIfConst();
columns[col_i] = std::move(column);
}
else
throw DB::Exception(DB::ErrorCodes::LOGICAL_ERROR, "Unknown ExpandFieldKind {}", magic_enum::enum_name(kind));
Expand Down

0 comments on commit cb926ad

Please sign in to comment.