Skip to content

Commit

Permalink
[GLUTEN-1632][CH]Daily Update Clickhouse Version (20240801) (#6665)
Browse files Browse the repository at this point in the history
* [GLUTEN-1632][CH]Daily Update Clickhouse Version (20240801)

* Fix build due to ClickHouse/ClickHouse#66528

> It's being misused and leading to unnecessary copies.

We misused using getSettings() in all place except CHUtils.cpp

---------

Co-authored-by: kyligence-git <[email protected]>
Co-authored-by: Chang Chen <[email protected]>
  • Loading branch information
3 people authored Aug 1, 2024
1 parent 21618c9 commit b8a7d80
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 19 deletions.
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/20240730
CH_COMMIT=f69def8b6a8
CH_BRANCH=rebase_ch/20240801
CH_COMMIT=768e193bd4d

2 changes: 1 addition & 1 deletion cpp-ch/local-engine/Common/CHUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@ void BackendInitializerUtil::updateConfig(const DB::ContextMutablePtr & context,
// configs cannot be updated per query
// settings can be updated per query

auto settings = context->getSettings(); // make a copy
auto settings = context->getSettingsCopy(); // make a copy
initSettings(backend_conf_map, settings);
updateNewSettings(context, settings);
}
Expand Down
2 changes: 1 addition & 1 deletion cpp-ch/local-engine/Parser/CrossRelParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ std::shared_ptr<DB::TableJoin> createCrossTableJoin(substrait::CrossRel_JoinType
{
auto & global_context = SerializedPlanParser::global_context;
auto table_join = std::make_shared<TableJoin>(
global_context->getSettings(), global_context->getGlobalTemporaryVolume(), global_context->getTempDataOnDisk());
global_context->getSettingsRef(), global_context->getGlobalTemporaryVolume(), global_context->getTempDataOnDisk());

std::pair<DB::JoinKind, DB::JoinStrictness> kind_and_strictness = JoinUtil::getCrossJoinKindAndStrictness(join_type);
table_join->setKind(kind_and_strictness.first);
Expand Down
2 changes: 1 addition & 1 deletion cpp-ch/local-engine/Parser/JoinRelParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ std::shared_ptr<DB::TableJoin> createDefaultTableJoin(substrait::JoinRel_JoinTyp
{
auto & global_context = SerializedPlanParser::global_context;
auto table_join = std::make_shared<TableJoin>(
global_context->getSettings(), global_context->getGlobalTemporaryVolume(), global_context->getTempDataOnDisk());
global_context->getSettingsRef(), global_context->getGlobalTemporaryVolume(), global_context->getTempDataOnDisk());

std::pair<DB::JoinKind, DB::JoinStrictness> kind_and_strictness = JoinUtil::getJoinKindAndStrictness(join_type, is_existence_join);
table_join->setKind(kind_and_strictness.first);
Expand Down
2 changes: 1 addition & 1 deletion cpp-ch/local-engine/Parser/MergeTreeRelParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ DB::QueryPlanPtr MergeTreeRelParser::parseReadRel(

auto ranges = merge_tree_table.extractRange(selected_parts);
std::string ret;
if (context->getSettings().tryGetString("enabled_driver_filter_mergetree_index", ret) && ret == "'true'")
if (context->getSettingsRef().tryGetString("enabled_driver_filter_mergetree_index", ret) && ret == "'true'")
storage->analysisPartsByRanges(*reinterpret_cast<ReadFromMergeTree *>(read_step.get()), ranges);
else
storage->wrapRangesInDataParts(*reinterpret_cast<ReadFromMergeTree *>(read_step.get()), ranges);
Expand Down
2 changes: 1 addition & 1 deletion cpp-ch/local-engine/Shuffle/PartitionWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class SortBasedPartitionWriter : public PartitionWriter
{
max_merge_block_size = options->split_size;
max_sort_buffer_size = options->max_sort_buffer_size;
max_merge_block_bytes = SerializedPlanParser::global_context->getSettings().prefer_external_sort_block_bytes;
max_merge_block_bytes = SerializedPlanParser::global_context->getSettingsRef().prefer_external_sort_block_bytes;
}
public:
String getName() const override { return "SortBasedPartitionWriter"; }
Expand Down
2 changes: 1 addition & 1 deletion cpp-ch/local-engine/Storages/Mergetree/MetaDataHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void restoreMetaData(CustomStorageMergeTreePtr & storage, const MergeTreeTable &
return;

// Increase the speed of metadata recovery
auto max_concurrency = std::max(10UL, SerializedPlanParser::global_context->getSettings().max_threads.value);
auto max_concurrency = std::max(10UL, SerializedPlanParser::global_context->getSettingsRef().max_threads.value);
auto max_threads = std::min(max_concurrency, not_exists_part.size());
FreeThreadPool thread_pool(
CurrentMetrics::LocalThread,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ DB::FormatSettings ExcelTextFormatFile::createFormatSettings()
format_settings.csv.null_representation = file_info.text().null_value();

bool empty_as_null = true;
if (context->getSettings().has(BackendInitializerUtil::EXCEL_EMPTY_AS_NULL))
empty_as_null = context->getSettings().getString(BackendInitializerUtil::EXCEL_EMPTY_AS_NULL) == "'true'";
if (context->getSettingsRef().has(BackendInitializerUtil::EXCEL_EMPTY_AS_NULL))
empty_as_null = context->getSettingsRef().getString(BackendInitializerUtil::EXCEL_EMPTY_AS_NULL) == "'true'";

format_settings.try_infer_integers = 0;
if (!context->getSettings().has(BackendInitializerUtil::EXCEL_NUMBER_FORCE))
if (!context->getSettingsRef().has(BackendInitializerUtil::EXCEL_NUMBER_FORCE))
format_settings.try_infer_integers = 1;
if (context->getSettings().has(BackendInitializerUtil::EXCEL_NUMBER_FORCE)
&& context->getSettings().getString(BackendInitializerUtil::EXCEL_NUMBER_FORCE) == "'true'")
if (context->getSettingsRef().has(BackendInitializerUtil::EXCEL_NUMBER_FORCE)
&& context->getSettingsRef().getString(BackendInitializerUtil::EXCEL_NUMBER_FORCE) == "'true'")
format_settings.try_infer_integers = 1;

if (format_settings.csv.null_representation.empty() || empty_as_null)
Expand All @@ -131,8 +131,8 @@ DB::FormatSettings ExcelTextFormatFile::createFormatSettings()
{
format_settings.csv.allow_single_quotes = false;

if (context->getSettings().has(BackendInitializerUtil::EXCEL_QUOTE_STRICT)
&& context->getSettings().getString(BackendInitializerUtil::EXCEL_QUOTE_STRICT) == "'true'")
if (context->getSettingsRef().has(BackendInitializerUtil::EXCEL_QUOTE_STRICT)
&& context->getSettingsRef().getString(BackendInitializerUtil::EXCEL_QUOTE_STRICT) == "'true'")
format_settings.csv.allow_double_quotes = false;
else
format_settings.csv.allow_double_quotes = true;
Expand Down
4 changes: 2 additions & 2 deletions cpp-ch/local-engine/Storages/SubstraitSource/FormatFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ FormatFilePtr FormatFileUtil::createFile(
#if USE_HIVE
if (file.has_text())
{
if (context->getSettings().has(BackendInitializerUtil::USE_EXCEL_PARSER)
&& context->getSettings().getString(BackendInitializerUtil::USE_EXCEL_PARSER) == "'true'")
if (context->getSettingsRef().has(BackendInitializerUtil::USE_EXCEL_PARSER)
&& context->getSettingsRef().getString(BackendInitializerUtil::USE_EXCEL_PARSER) == "'true'")
return std::make_shared<ExcelTextFormatFile>(context, file, read_buffer_builder);
else
return std::make_shared<TextFormatFile>(context, file, read_buffer_builder);
Expand Down
2 changes: 1 addition & 1 deletion cpp-ch/local-engine/tests/benchmark_local_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ QueryPlanPtr readFromMergeTree(MergeTreeWithSnapshot storage)
QueryPlanPtr joinPlan(QueryPlanPtr left, QueryPlanPtr right, String left_key, String right_key, size_t block_size = 8192)
{
auto join = std::make_shared<TableJoin>(
global_context->getSettings(), global_context->getGlobalTemporaryVolume(), global_context->getTempDataOnDisk());
global_context->getSettingsRef(), global_context->getGlobalTemporaryVolume(), global_context->getTempDataOnDisk());
auto left_columns = left->getCurrentDataStream().header.getColumnsWithTypeAndName();
auto right_columns = right->getCurrentDataStream().header.getColumnsWithTypeAndName();
join->setKind(JoinKind::Left);
Expand Down
2 changes: 1 addition & 1 deletion cpp-ch/local-engine/tests/gtest_ch_join.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ TEST(TestJoin, simple)
right_plan.addStep(std::make_unique<ReadFromPreparedSource>(Pipe(right_table)));

auto join = std::make_shared<TableJoin>(
global_context->getSettings(), global_context->getGlobalTemporaryVolume(), global_context->getTempDataOnDisk());
global_context->getSettingsRef(), global_context->getGlobalTemporaryVolume(), global_context->getTempDataOnDisk());
join->setKind(JoinKind::Left);
join->setStrictness(JoinStrictness::All);
join->setColumnsFromJoinedTable(right.getNamesAndTypesList());
Expand Down

0 comments on commit b8a7d80

Please sign in to comment.