change as request

This commit is contained in:
taiyang-li 2024-10-29 09:45:09 +08:00
parent 04099b1f9d
commit 9616167325
4 changed files with 16 additions and 17 deletions

View File

@ -5456,13 +5456,12 @@ Only available in ClickHouse Cloud. Number of background threads for speculative
DECLARE(Int64, ignore_cold_parts_seconds, 0, R"(
Only available in ClickHouse Cloud. Exclude new data parts from SELECT queries until they're either pre-warmed (see cache_populated_by_fetch) or this many seconds old. Only for Replicated-/SharedMergeTree.
)", 0) \
DECLARE(Bool, short_circuit_default_implementation_for_nulls, true, R"(
Setting for short-circuit default implementations for nulls in function with useDefaultImplementationForNulls() = true.
If true, function will not actually evaluate for rows in which there are at least one argument with null value.
DECLARE(Bool, short_circuit_function_evaluation_for_nulls, true, R"(
Whether to enable short-circuit evaluation for rows with at least one null in arguments in functions where useDefaultImplementationForNulls() is true.
)", 0) \
DECLARE(Double, short_circuit_default_implementation_for_nulls_threshold, 1.0, R"(
Ratio threshold for short-circuit default implementations for nulls in function with useDefaultImplementationForNulls() = true. It is only valid when short_circuit_default_implementation_for_nulls is true.
When the ratio of rows containing nulls to the total number of rows exceeds this threshold, these rows containing nulls would not be evaluated.
DECLARE(Double, short_circuit_function_evaluation_for_nulls_threshold, 1.0, R"(
Ratio threshold for short-circuit evaluation for rows with at least one null in arguments in functions where useDefaultImplementationForNulls() is true. This is only valid when short_circuit_function_evaluation_for_nulls is true.
When the ratio of rows containing nulls to the total number of rows exceeds this threshold, these rows containing nulls will not be evaluated.
)", 0) \
DECLARE(Int64, prefer_warmed_unmerged_parts_seconds, 0, R"(
Only available in ClickHouse Cloud. If a merged part is less than this many seconds old and is not pre-warmed (see cache_populated_by_fetch), but all its source parts are available and pre-warmed, SELECT queries will read from those parts instead. Only for ReplicatedMergeTree. Note that this only checks whether CacheWarmer processed the part; if the part was fetched into cache by something else, it'll still be considered cold until CacheWarmer gets to it; if it was warmed, then evicted from cache, it'll still be considered warm.

View File

@ -64,6 +64,8 @@ static std::initializer_list<std::pair<ClickHouseVersion, SettingsChangesHistory
},
{"24.11",
{
{"short_circuit_function_evaluation_for_nulls", false, true, "Whether to enable short-circuit evaluation for rows with at least one null in arguments in functions where useDefaultImplementationForNulls() is true."},
{"short_circuit_function_evaluation_for_nulls_threshold", 1.0, 1.0, "Ratio threshold for short-circuit evaluation for rows with at least one null in arguments in functions where useDefaultImplementationForNulls() is true. This is only valid when short_circuit_function_evaluation_for_nulls is true."},
}
},
{"24.10",
@ -103,8 +105,6 @@ static std::initializer_list<std::pair<ClickHouseVersion, SettingsChangesHistory
{"distributed_cache_read_alignment", 0, 0, "A setting for ClickHouse Cloud"},
{"distributed_cache_max_unacked_inflight_packets", 10, 10, "A setting for ClickHouse Cloud"},
{"distributed_cache_data_packet_ack_window", 5, 5, "A setting for ClickHouse Cloud"},
{"short_circuit_default_implementation_for_nulls", false, true, "Setting for short-circuit default implementations for null in function with useDefaultImplementationForNulls() = true. If true, function will not actually evaluate for rows in which there are at least one argument with null value."},
{"short_circuit_default_implementation_for_nulls_threshold", 0.0, 0.0, "Ratio threshold for short-circuit default implementations for nulls in function with useDefaultImplementationForNulls() = true. It is only valid when short_circuit_default_implementation_for_nulls is true."},
{"input_format_parquet_enable_row_group_prefetch", false, true, "Enable row group prefetching during parquet parsing. Currently, only single-threaded parsing can prefetch."},
{"input_format_orc_dictionary_as_low_cardinality", false, true, "Treat ORC dictionary encoded columns as LowCardinality columns while reading ORC files"},
{"allow_experimental_refreshable_materialized_view", false, true, "Not experimental anymore"},

View File

@ -42,8 +42,8 @@ namespace DB
namespace Setting
{
extern const SettingsBool short_circuit_default_implementation_for_nulls;
extern const SettingsDouble short_circuit_default_implementation_for_nulls_threshold;
extern const SettingsBool short_circuit_function_evaluation_for_nulls;
extern const SettingsDouble short_circuit_function_evaluation_for_nulls_threshold;
}
namespace ErrorCodes
@ -254,8 +254,8 @@ ColumnPtr IExecutableFunction::defaultImplementationForNulls(
size_t rows_without_nulls = countBytesInFilter(mask.data(), 0, mask.size());
size_t rows_with_nulls = mask.size() - rows_without_nulls;
double null_ratio = rows_with_nulls / static_cast<double>(mask.size());
bool should_short_circuit = short_circuit_default_implementation_for_nulls && !all_columns_constant
&& null_ratio >= short_circuit_default_implementation_for_nulls_threshold;
bool should_short_circuit = short_circuit_function_evaluation_for_nulls && !all_columns_constant
&& null_ratio >= short_circuit_function_evaluation_for_nulls_threshold;
ProfileEvents::increment(ProfileEvents::DefaultImplementationForNullsRows, mask.size());
ProfileEvents::increment(ProfileEvents::DefaultImplementationForNullsRowsWithNulls, rows_with_nulls);
@ -361,10 +361,10 @@ IExecutableFunction::IExecutableFunction()
if (CurrentThread::isInitialized())
{
auto query_context = CurrentThread::get().getQueryContext();
if (query_context && query_context->getSettingsRef()[Setting::short_circuit_default_implementation_for_nulls])
if (query_context && query_context->getSettingsRef()[Setting::short_circuit_function_evaluation_for_nulls])
{
short_circuit_default_implementation_for_nulls = true;
short_circuit_default_implementation_for_nulls_threshold = query_context->getSettingsRef()[Setting::short_circuit_default_implementation_for_nulls_threshold];
short_circuit_function_evaluation_for_nulls = true;
short_circuit_function_evaluation_for_nulls_threshold = query_context->getSettingsRef()[Setting::short_circuit_function_evaluation_for_nulls_threshold];
}
}
}

View File

@ -122,8 +122,8 @@ private:
ColumnPtr executeWithoutSparseColumns(
const ColumnsWithTypeAndName & arguments, const DataTypePtr & result_type, size_t input_rows_count, bool dry_run) const;
bool short_circuit_default_implementation_for_nulls = false;
double short_circuit_default_implementation_for_nulls_threshold = 0.0;
bool short_circuit_function_evaluation_for_nulls = false;
double short_circuit_function_evaluation_for_nulls_threshold = 0.0;
};
using ExecutableFunctionPtr = std::shared_ptr<IExecutableFunction>;