[Fix](vcompound pred) Corrected evaluation for compound predicates with constant columns (#28421)
This commit is contained in:
@ -61,7 +61,8 @@ public:
|
||||
int lhs_id = -1;
|
||||
int rhs_id = -1;
|
||||
RETURN_IF_ERROR(_children[0]->execute(context, block, &lhs_id));
|
||||
ColumnPtr lhs_column = block->get_by_position(lhs_id).column;
|
||||
ColumnPtr lhs_column =
|
||||
block->get_by_position(lhs_id).column->convert_to_full_column_if_const();
|
||||
size_t size = lhs_column->size();
|
||||
bool lhs_is_nullable = lhs_column->is_nullable();
|
||||
auto [lhs_data_column, lhs_null_map] =
|
||||
@ -88,7 +89,8 @@ public:
|
||||
auto get_rhs_colum = [&]() {
|
||||
if (rhs_id == -1) {
|
||||
RETURN_IF_ERROR(_children[1]->execute(context, block, &rhs_id));
|
||||
rhs_column = block->get_by_position(rhs_id).column;
|
||||
rhs_column =
|
||||
block->get_by_position(rhs_id).column->convert_to_full_column_if_const();
|
||||
rhs_is_nullable = rhs_column->is_nullable();
|
||||
auto rhs_nullable_column = _get_raw_data_and_null_map(rhs_column, rhs_is_nullable);
|
||||
rhs_data_column = rhs_nullable_column.first;
|
||||
|
||||
7
regression-test/data/query_p0/test_constant_fold.out
Normal file
7
regression-test/data/query_p0/test_constant_fold.out
Normal file
@ -0,0 +1,7 @@
|
||||
-- This file is automatically generated. You should know what you did if you want to edit this
|
||||
-- !select --
|
||||
0
|
||||
|
||||
-- !select --
|
||||
0
|
||||
|
||||
52
regression-test/suites/query_p0/test_constant_fold.groovy
Normal file
52
regression-test/suites/query_p0/test_constant_fold.groovy
Normal file
@ -0,0 +1,52 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
suite("test_constant_fold", "query") {
|
||||
// define a sql table
|
||||
def testTable = "test_constant_fold_fuzzy"
|
||||
|
||||
sql """
|
||||
CREATE TABLE IF NOT EXISTS ${testTable} (
|
||||
c0 BOOLEAN
|
||||
)
|
||||
AGGREGATE KEY(c0)
|
||||
DISTRIBUTED BY HASH (c0)
|
||||
BUCKETS 28
|
||||
PROPERTIES (
|
||||
"replication_num" = "1"
|
||||
);
|
||||
"""
|
||||
// prepare data
|
||||
sql """ INSERT INTO ${testTable} VALUES (false) """
|
||||
sql """ INSERT INTO ${testTable} VALUES (true) """
|
||||
|
||||
sql """ set enable_fold_constant_by_be=true """
|
||||
|
||||
qt_select """ SELECT SUM(count) FROM
|
||||
(SELECT CAST((NOT ((1378719999)||(CASE ${testTable}.c0 WHEN ${testTable}.c0 THEN -388844163 WHEN ${testTable}.c0 THEN 1455674610 ELSE 671348352 END ))) IS NOT NULL AND
|
||||
(NOT ((1378719999)||(CASE ${testTable}.c0 WHEN ${testTable}.c0 THEN -388844163 WHEN ${testTable}.c0 THEN 1455674610 ELSE 671348352 END ))) AS INT) as count
|
||||
FROM ${testTable}) as res;
|
||||
"""
|
||||
|
||||
sql """ set enable_fold_constant_by_be=false """
|
||||
|
||||
qt_select """ SELECT SUM(count) FROM
|
||||
(SELECT CAST((NOT ((1378719999)||(CASE ${testTable}.c0 WHEN ${testTable}.c0 THEN -388844163 WHEN ${testTable}.c0 THEN 1455674610 ELSE 671348352 END ))) IS NOT NULL AND
|
||||
(NOT ((1378719999)||(CASE ${testTable}.c0 WHEN ${testTable}.c0 THEN -388844163 WHEN ${testTable}.c0 THEN 1455674610 ELSE 671348352 END ))) AS INT) as count
|
||||
FROM ${testTable}) as res;
|
||||
"""
|
||||
}
|
||||
Reference in New Issue
Block a user