Fix tests

This commit is contained in:
Alexey Milovidov 2023-11-23 16:02:33 +01:00
parent 93b789169b
commit 89656723fb
9 changed files with 21 additions and 7 deletions

View File

@ -152,6 +152,7 @@ class IColumn;
M(Bool, allow_suspicious_low_cardinality_types, false, "In CREATE TABLE statement allows specifying LowCardinality modifier for types of small fixed size (8 or less). Enabling this may increase merge times and memory consumption.", 0) \
M(Bool, allow_suspicious_fixed_string_types, false, "In CREATE TABLE statement allows creating columns of type FixedString(n) with n > 256. FixedString with length >= 256 is suspicious and most likely indicates misusage", 0) \
M(Bool, allow_suspicious_indices, false, "Reject primary/secondary indexes and sorting keys with identical expressions", 0) \
M(Bool, allow_suspicious_ttl_expressions, false, "Reject TTL expressions that don't depend on any of table's columns. It indicates a user error most of the time.", 0) \
M(Bool, compile_expressions, false, "Compile some scalar functions and operators to native code.", 0) \
M(UInt64, min_count_to_compile_expression, 3, "The number of identical expressions before they are JIT-compiled", 0) \
M(Bool, compile_aggregate_expressions, true, "Compile aggregate functions to native code.", 0) \

View File

@ -7,6 +7,7 @@
#include <boost/algorithm/string.hpp>
#include <map>
namespace DB
{
@ -80,6 +81,7 @@ namespace SettingsChangesHistory
/// It's used to implement `compatibility` setting (see https://github.com/ClickHouse/ClickHouse/issues/35972)
static std::map<ClickHouseVersion, SettingsChangesHistory::SettingsChanges> settings_changes_history =
{
{"23.11", {{"allow_suspicious_ttl_expressions", true, false, "It is a new setting, and in previous versions the behavior was equivalent to allowing."}}},
{"23.9", {{"optimize_group_by_constant_keys", false, true, "Optimize group by constant keys by default"},
{"input_format_json_try_infer_named_tuples_from_objects", false, true, "Try to infer named Tuples from JSON objects by default"},
{"input_format_json_read_numbers_as_strings", false, true, "Allow to read numbers as strings in JSON formats by default"},

View File

@ -55,10 +55,10 @@ TTLAggregateDescription & TTLAggregateDescription::operator=(const TTLAggregateD
namespace
{
void checkTTLExpression(const ExpressionActionsPtr & ttl_expression, const String & result_column_name, bool is_attach)
void checkTTLExpression(const ExpressionActionsPtr & ttl_expression, const String & result_column_name, bool allow_suspicious)
{
/// Do not apply this check in ATTACH queries for compatibility reasons.
if (!is_attach)
/// Do not apply this check in ATTACH queries for compatibility reasons and if explicitly allowed.
if (!allow_suspicious)
{
if (ttl_expression->getRequiredColumns().empty())
throw Exception(ErrorCodes::BAD_ARGUMENTS,
@ -297,7 +297,7 @@ TTLDescription TTLDescription::getTTLFromAST(
}
}
checkTTLExpression(result.expression, result.result_column, is_attach);
checkTTLExpression(result.expression, result.result_column, is_attach || context->getSettingsRef().allow_suspicious_ttl_expressions);
return result;
}

View File

@ -1,4 +1,5 @@
#pragma once
#include <Parsers/IAST_fwd.h>
#include <Storages/DataDestinationType.h>
#include <Storages/ColumnsDescription.h>
@ -7,6 +8,7 @@
#include <Interpreters/AggregateDescription.h>
#include <Storages/TTLMode.h>
namespace DB
{
@ -83,7 +85,7 @@ struct TTLDescription
ASTPtr recompression_codec;
/// Parse TTL structure from definition. Able to parse both column and table TTLs.
static TTLDescription getTTLFromAST(const ASTPtr & definition_ast, const ColumnsDescription & columns, ContextPtr context, const KeyDescription & primary_key, bool is_attach = false);
static TTLDescription getTTLFromAST(const ASTPtr & definition_ast, const ColumnsDescription & columns, ContextPtr context, const KeyDescription & primary_key, bool is_attach);
TTLDescription() = default;
TTLDescription(const TTLDescription & other);
@ -120,7 +122,7 @@ struct TTLTableDescription
TTLTableDescription & operator=(const TTLTableDescription & other);
static TTLTableDescription getTTLForTableFromAST(
const ASTPtr & definition_ast, const ColumnsDescription & columns, ContextPtr context, const KeyDescription & primary_key, bool is_attach = false);
const ASTPtr & definition_ast, const ColumnsDescription & columns, ContextPtr context, const KeyDescription & primary_key, bool is_attach);
/// Parse description from string
static TTLTableDescription parse(const String & str, const ColumnsDescription & columns, ContextPtr context, const KeyDescription & primary_key);

View File

@ -8,7 +8,8 @@
-- ┌───────────────now()─┬─toDate(toTimeZone(now(), 'America/Mazatlan'))─┬────today()─┐
-- │ 2023-07-24 06:24:06 │ 2023-07-23 │ 2023-07-24 │
-- └─────────────────────┴───────────────────────────────────────────────┴────────────┘
set session_timezone = '';
SET session_timezone = '';
SET allow_suspicious_ttl_expressions = 1;
drop table if exists ttl_00933_1;

View File

@ -1,5 +1,7 @@
drop table if exists alter_ttl;
SET allow_suspicious_ttl_expressions = 1;
create table alter_ttl(i Int) engine = MergeTree order by i ttl toDate('2020-05-05');
alter table alter_ttl add column s String;
alter table alter_ttl modify column s String ttl toDate('2020-01-01');

View File

@ -1,5 +1,7 @@
-- Tags: no-parallel
SET allow_suspicious_ttl_expressions = 1;
drop table if exists ttl;
create table ttl (d Date, a Int) engine = MergeTree order by a partition by toDayOfMonth(d);

View File

@ -1,5 +1,7 @@
-- Tags: no-parallel
SET allow_suspicious_ttl_expressions = 1;
drop table if exists ttl;
create table ttl (d Date, a Int) engine = MergeTree order by a partition by toDayOfMonth(d);

View File

@ -5,6 +5,8 @@ set mutations_sync = 2;
-- system.parts has server default, timezone cannot be randomized
set session_timezone = '';
SET allow_suspicious_ttl_expressions = 1;
drop table if exists ttl;
create table ttl (d Date, a Int) engine = MergeTree order by a partition by toDayOfMonth(d)