mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
Fix big dates comparison with compile expressions (Date and DateTime are not signed types anymore).
This commit is contained in:
parent
787e457d27
commit
55fc095c98
@ -34,8 +34,7 @@ static inline bool typeIsSigned(const IDataType & type)
|
||||
{
|
||||
return typeIsEither<
|
||||
DataTypeInt8, DataTypeInt16, DataTypeInt32, DataTypeInt64,
|
||||
DataTypeFloat32, DataTypeFloat64,
|
||||
DataTypeDate, DataTypeDateTime, DataTypeInterval
|
||||
DataTypeFloat32, DataTypeFloat64, DataTypeInterval
|
||||
>(type);
|
||||
}
|
||||
|
||||
|
@ -812,7 +812,7 @@ void ExpressionActions::finalize(const Names & output_columns)
|
||||
/// This has to be done before removing redundant actions and inserting REMOVE_COLUMNs
|
||||
/// because inlining may change dependency sets.
|
||||
if (settings.compile_expressions)
|
||||
compileFunctions(actions, output_columns, sample_block, compilation_cache, settings.min_count_to_compile);
|
||||
compileFunctions(actions, output_columns, sample_block, compilation_cache, settings.min_count_to_compile_expression);
|
||||
#endif
|
||||
|
||||
/// Which columns are needed to perform actions from the current to the last.
|
||||
|
@ -654,7 +654,7 @@ std::vector<std::unordered_set<std::optional<size_t>>> getActionsDependents(cons
|
||||
return dependents;
|
||||
}
|
||||
|
||||
void compileFunctions(ExpressionActions::Actions & actions, const Names & output_columns, const Block & sample_block, std::shared_ptr<CompiledExpressionCache> compilation_cache, size_t min_count_to_compile)
|
||||
void compileFunctions(ExpressionActions::Actions & actions, const Names & output_columns, const Block & sample_block, std::shared_ptr<CompiledExpressionCache> compilation_cache, size_t min_count_to_compile_expression)
|
||||
{
|
||||
static std::unordered_map<UInt128, UInt32, UInt128Hash> counter;
|
||||
static std::mutex mutex;
|
||||
@ -688,7 +688,7 @@ void compileFunctions(ExpressionActions::Actions & actions, const Names & output
|
||||
auto hash_key = ExpressionActions::ActionsHash{}(fused[i]);
|
||||
{
|
||||
std::lock_guard lock(mutex);
|
||||
if (counter[hash_key]++ < min_count_to_compile)
|
||||
if (counter[hash_key]++ < min_count_to_compile_expression)
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ public:
|
||||
|
||||
/// For each APPLY_FUNCTION action, try to compile the function to native code; if the only uses of a compilable
|
||||
/// function's result are as arguments to other compilable functions, inline it and leave the now-redundant action as-is.
|
||||
void compileFunctions(ExpressionActions::Actions & actions, const Names & output_columns, const Block & sample_block, std::shared_ptr<CompiledExpressionCache> compilation_cache, size_t min_count_to_compile);
|
||||
void compileFunctions(ExpressionActions::Actions & actions, const Names & output_columns, const Block & sample_block, std::shared_ptr<CompiledExpressionCache> compilation_cache, size_t min_count_to_compile_expression);
|
||||
|
||||
}
|
||||
|
||||
|
@ -77,6 +77,7 @@ struct Settings
|
||||
M(SettingBool, compile, false, "Whether query compilation is enabled.") \
|
||||
M(SettingBool, compile_expressions, true, "Compile some scalar functions and operators to native code.") \
|
||||
M(SettingUInt64, min_count_to_compile, 3, "The number of structurally identical queries before they are compiled.") \
|
||||
M(SettingUInt64, min_count_to_compile_expression, 3, "The number of identical expressions before they are JIT-compiled") \
|
||||
M(SettingUInt64, group_by_two_level_threshold, 100000, "From what number of keys, a two-level aggregation starts. 0 - the threshold is not set.") \
|
||||
M(SettingUInt64, group_by_two_level_threshold_bytes, 100000000, "From what size of the aggregation state in bytes, a two-level aggregation begins to be used. 0 - the threshold is not set. Two-level aggregation is used when at least one of the thresholds is triggered.") \
|
||||
M(SettingBool, distributed_aggregation_memory_efficient, false, "Is the memory-saving mode of distributed aggregation enabled.") \
|
||||
|
@ -1,5 +1,5 @@
|
||||
SET compile_expressions = 1;
|
||||
SET min_count_to_compile = 1;
|
||||
SET min_count_to_compile_expression = 1;
|
||||
SET optimize_move_to_prewhere = 0;
|
||||
SET enable_optimize_predicate_expression=0;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
SET compile_expressions = 1;
|
||||
SET min_count_to_compile = 1;
|
||||
SET min_count_to_compile_expression = 1;
|
||||
|
||||
DROP TABLE IF EXISTS test.time_table;
|
||||
|
||||
|
@ -0,0 +1,4 @@
|
||||
2019-02-06
|
||||
2019-02-07
|
||||
2019-02-08
|
||||
2021-02-06
|
@ -0,0 +1,14 @@
|
||||
SET compile_expressions = 1;
|
||||
SET min_count_to_compile_expression = 1;
|
||||
|
||||
DROP TABLE IF EXISTS test.foo_c;
|
||||
|
||||
CREATE TABLE test.foo_c(d DateTime) ENGINE = Memory;
|
||||
|
||||
INSERT INTO test.foo_c VALUES ('2019-02-06 01:01:01'),('2019-02-07 01:01:01'),('2019-02-08 01:01:01'),('2021-02-06 01:01:01'),('2093-05-29 01:01:01'),('2100-06-06 01:01:01'),('2100-10-14 01:01:01'),('2100-11-01 01:01:01'),('2100-11-15 01:01:01'),('2100-11-30 01:01:01'),('2100-12-11 01:01:01'),('2100-12-21 01:01:01');
|
||||
|
||||
SELECT toDate(d) AS dd FROM test.foo_c WHERE (dd >= '2019-02-06') AND (toDate(d) <= toDate('2019-08-09')) GROUP BY dd ORDER BY dd;
|
||||
|
||||
SELECT toDate(d) FROM test.foo_c WHERE (d > toDate('2019-02-10')) AND (d <= toDate('2022-01-01')) ORDER BY d;
|
||||
|
||||
DROP TABLE IF EXISTS test.foo_c;
|
Loading…
Reference in New Issue
Block a user