Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GLUTEN-1632][CH]Daily Update Clickhouse Version (20240710) #6383

Merged
merged 3 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cpp-ch/clickhouse.version
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CH_ORG=Kyligence
CH_BRANCH=rebase_ch/20240706
CH_COMMIT=25bf31bfbdf
CH_BRANCH=rebase_ch/20240710
CH_COMMIT=feb85da32a5

2 changes: 2 additions & 0 deletions cpp-ch/local-engine/Common/CHUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,8 @@ void BackendInitializerUtil::initSettings(std::map<std::string, std::string> & b
settings.set("function_json_value_return_type_allow_complex", true);
settings.set("function_json_value_return_type_allow_nullable", true);
settings.set("precise_float_parsing", true);
settings.set("enable_named_columns_in_function_tuple", false);

if (backend_conf_map.contains(GLUTEN_TASK_OFFHEAP))
{
auto task_memory = std::stoull(backend_conf_map.at(GLUTEN_TASK_OFFHEAP));
Expand Down
32 changes: 13 additions & 19 deletions cpp-ch/local-engine/Common/DebugUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ namespace debug
{
void headBlock(const DB::Block & block, size_t count)
{
std::cerr << "============Block============" << std::endl;
std::cerr << block.dumpStructure() << std::endl;
std::cout << "============Block============" << std::endl;
std::cout << block.dumpStructure() << std::endl;
// print header
for (const auto & name : block.getNames())
std::cerr << name << "\t";
std::cerr << std::endl;
std::cout << name << "\t";
std::cout << std::endl;

// print rows
for (size_t row = 0; row < std::min(count, block.rows()); ++row)
Expand All @@ -45,36 +45,30 @@ void headBlock(const DB::Block & block, size_t count)
auto col = block.getByPosition(column).column;

if (column > 0)
std::cerr << "\t";
std::cout << "\t";
DB::WhichDataType which(type);
if (which.isAggregateFunction())
{
std::cerr << "Nan";
}
std::cout << "Nan";
else if (col->isNullAt(row))
{
std::cerr << "null";
}
std::cout << "null";
else
{
std::cerr << toString((*col)[row]);
}
std::cout << toString((*col)[row]);
}
std::cerr << std::endl;
std::cout << std::endl;
}
}

void headColumn(const DB::ColumnPtr & column, size_t count)
{
std::cerr << "============Column============" << std::endl;
std::cout << "============Column============" << std::endl;

// print header
std::cerr << column->getName() << "\t";
std::cerr << std::endl;
std::cout << column->getName() << "\t";
std::cout << std::endl;

// print rows
for (size_t row = 0; row < std::min(count, column->size()); ++row)
std::cerr << toString((*column)[row]) << std::endl;
std::cout << toString((*column)[row]) << std::endl;
}

}
Binary file not shown.
10 changes: 10 additions & 0 deletions cpp-ch/local-engine/tests/gluten_test_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <DataTypes/DataTypeString.h>
#include <DataTypes/DataTypesNumber.h>
#include <Interpreters/ActionsDAG.h>
#include <boost/algorithm/string/replace.hpp>
#include <google/protobuf/util/json_util.h>
#include <parquet/schema.h>

Expand All @@ -32,6 +33,9 @@ using BlockFieldType = DB::ColumnWithTypeAndName;
using AnotherRowType = DB::NamesAndTypesList;
using AnotherFieldType = DB::NameAndTypePair;


#define GLUTEN_DATA_DIR(file) "file://" SOURCE_DIR file

namespace parquet
{
class ColumnDescriptor;
Expand Down Expand Up @@ -80,6 +84,12 @@ std::string JsonStringToBinary(const std::string_view & json)
}
}

inline std::string replaceLocalFilesWildcards(const String & haystack, const String & replaced)
{
static constexpr auto _WILDCARD_ = "{replace_local_files}";
return boost::replace_all_copy(haystack, _WILDCARD_, replaced);
}

inline DB::DataTypePtr BIGINT()
{
return std::make_shared<DB::DataTypeInt64>();
Expand Down
83 changes: 83 additions & 0 deletions cpp-ch/local-engine/tests/gtest_clickhouse_54881.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* 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.
*/
#include <gluten_test_util.h>
#include <incbin.h>

#include <Parser/SerializedPlanParser.h>
#include <gtest/gtest.h>
#include <Common/DebugUtils.h>


using namespace local_engine;

using namespace DB;

// Plan for https://github.com/ClickHouse/ClickHouse/pull/54881
INCBIN(resource_embedded_pr_54881_json, SOURCE_DIR "/utils/extern-local-engine/tests/json/clickhouse_pr_54881.json");

TEST(Clickhouse, PR54881)
{
const auto context1 = DB::Context::createCopy(SerializedPlanParser::global_context);
// context1->setSetting("enable_named_columns_in_function_tuple", DB::Field(true));
auto settingxs = context1->getSettingsRef();
EXPECT_FALSE(settingxs.enable_named_columns_in_function_tuple) << "GLUTEN NEED set enable_named_columns_in_function_tuple to false";

const std::string split_template
= R"({"items":[{"uriFile":"{replace_local_files}","partitionIndex":"0","length":"1529","parquet":{},"schema":{},"metadataColumns":[{}]}]})";
const std::string split
= replaceLocalFilesWildcards(split_template, GLUTEN_DATA_DIR("/utils/extern-local-engine/tests/data/54881.snappy.parquet"));

SerializedPlanParser parser(context1);
parser.addSplitInfo(test::pb_util::JsonStringToBinary<substrait::ReadRel::LocalFiles>(split));

const auto local_executor = parser.createExecutor<true>(
{reinterpret_cast<const char *>(gresource_embedded_pr_54881_jsonData), gresource_embedded_pr_54881_jsonSize});

EXPECT_TRUE(local_executor->hasNext());
const Block & block = *local_executor->nextColumnar();

debug::headBlock(block);

EXPECT_EQ(2, block.columns());
const auto & col_0 = *(block.getColumns()[0]);
EXPECT_EQ(col_0.getInt(0), 9);
EXPECT_EQ(col_0.getInt(1), 10);

Field field;
const auto & col_1 = *(block.getColumns()[1]);
col_1.get(0, field);
const Tuple & row_0 = field.get<DB::Tuple>();
EXPECT_EQ(2, row_0.size());

Int64 actual{-1};
EXPECT_TRUE(row_0[0].tryGet<Int64>(actual));
EXPECT_EQ(9, actual);

EXPECT_TRUE(row_0[1].tryGet<Int64>(actual));
EXPECT_EQ(10, actual);

col_1.get(1, field);
const Tuple & row_1 = field.get<DB::Tuple>();
EXPECT_EQ(2, row_1.size());
EXPECT_TRUE(row_1[0].tryGet<Int64>(actual));
EXPECT_EQ(10, actual);

EXPECT_TRUE(row_1[1].tryGet<Int64>(actual));
EXPECT_EQ(11, actual);

EXPECT_FALSE(local_executor->hasNext());
}
Loading
Loading