mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 16:12:01 +00:00
Some fixes
This commit is contained in:
parent
107dc07327
commit
486128bd0e
@ -1052,7 +1052,7 @@ toStartOfWeek(t[, mode[, timezone]])
|
||||
**Arguments**
|
||||
|
||||
- `t` - a [Date](../data-types/date.md), [Date32](../data-types/date32.md), [DateTime](../data-types/datetime.md) or [DateTime64](../data-types/datetime64.md)
|
||||
- `mode` - determines the first day of the week as described in the [toWeek()](date-time-functions#toweek) function
|
||||
- `mode` - determines the first day of the week as described in the [toWeek()](date-time-functions#toweek) function. Default: 0
|
||||
- `timezone` - Optional parameter, it behaves like any other conversion function
|
||||
|
||||
**Returned value**
|
||||
|
@ -1202,7 +1202,7 @@ class IColumn;
|
||||
M(Bool, precise_float_parsing, false, "Prefer more precise (but slower) float parsing algorithm", 0) \
|
||||
M(DateTimeOverflowBehavior, date_time_overflow_behavior, "ignore", "Overflow mode for Date, Date32, DateTime, DateTime64 types. Possible values: 'ignore', 'throw', 'saturate'.", 0) \
|
||||
M(Bool, validate_experimental_and_suspicious_types_inside_nested_types, true, "Validate usage of experimental and suspicious types inside nested types like Array/Map/Tuple", 0) \
|
||||
M(DefaultWeekMode, default_mode_week_functions, DefaultWeekMode::MONDAY, "Change default week mode for week conversion functions. Default is Monday.", 0) \
|
||||
M(FirstDayOfWeek, first_day_of_week, FirstDayOfWeek::Monday, "The first day of the week (Monday or Sunday) used by date/time functions (default: Monday).", 0) \
|
||||
|
||||
|
||||
// End of FORMAT_FACTORY_SETTINGS
|
||||
|
@ -97,7 +97,7 @@ static std::map<ClickHouseVersion, SettingsChangesHistory::SettingsChanges> sett
|
||||
{"use_page_cache_for_disks_without_file_cache", false, false, "Added userspace page cache"},
|
||||
{"read_from_page_cache_if_exists_otherwise_bypass_cache", false, false, "Added userspace page cache"},
|
||||
{"page_cache_inject_eviction", false, false, "Added userspace page cache"},
|
||||
{"default_mode_week_functions", "monday", "monday", "Change default week mode for week conversion functions"},
|
||||
{"first_day_of_week", "Monday", "Monday", "Added a setting for the first day of the week for date/time functions"},
|
||||
{"input_format_json_use_string_type_for_ambiguous_paths_in_named_tuples_inference_from_objects", false, false, "Allow to use String type for ambiguous paths during named tuple inference from JSON objects"},
|
||||
{"traverse_shadow_remote_data_paths", false, false, "Traverse shadow directory when query system.remote_data_paths."},
|
||||
{"throw_if_deduplication_in_dependent_materialized_views_enabled_with_async_insert", false, true, "Deduplication is dependent materialized view cannot work together with async inserts."},
|
||||
|
@ -230,7 +230,7 @@ IMPLEMENT_SETTING_ENUM(SQLSecurityType, ErrorCodes::BAD_ARGUMENTS,
|
||||
{"INVOKER", SQLSecurityType::INVOKER},
|
||||
{"NONE", SQLSecurityType::NONE}})
|
||||
|
||||
IMPLEMENT_SETTING_ENUM(DefaultWeekMode, ErrorCodes::BAD_ARGUMENTS,
|
||||
{{"monday", DefaultWeekMode::MONDAY},
|
||||
{"sunday", DefaultWeekMode::SUNDAY}})
|
||||
IMPLEMENT_SETTING_ENUM(FirstDayOfWeek, ErrorCodes::BAD_ARGUMENTS,
|
||||
{{"Monday", FirstDayOfWeek::Monday},
|
||||
{"Sunday", FirstDayOfWeek::Sunday}})
|
||||
}
|
||||
|
@ -371,11 +371,11 @@ DECLARE_SETTING_ENUM_WITH_RENAME(DateTimeOverflowBehavior, FormatSettings::DateT
|
||||
|
||||
DECLARE_SETTING_ENUM(SQLSecurityType)
|
||||
|
||||
enum class DefaultWeekMode
|
||||
enum class FirstDayOfWeek
|
||||
{
|
||||
MONDAY,
|
||||
SUNDAY
|
||||
Monday,
|
||||
Sunday
|
||||
};
|
||||
|
||||
DECLARE_SETTING_ENUM(DefaultWeekMode)
|
||||
DECLARE_SETTING_ENUM(FirstDayOfWeek)
|
||||
}
|
||||
|
@ -351,7 +351,7 @@ public:
|
||||
static FunctionPtr create(ContextPtr context) { return std::make_shared<FunctionDateDiff>(context); }
|
||||
|
||||
explicit FunctionDateDiff(ContextPtr context)
|
||||
: enable_default_monday_first(context->getSettingsRef().default_mode_week_functions != DefaultWeekMode::SUNDAY)
|
||||
: enable_default_monday_first(context->getSettingsRef().first_day_of_week != FirstDayOfWeek::Sunday)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ public:
|
||||
static FunctionPtr create(ContextPtr context) { return std::make_shared<FunctionToStartOfInterval>(context); }
|
||||
|
||||
explicit FunctionToStartOfInterval(ContextPtr context)
|
||||
: enable_default_monday_first(context->getSettingsRef().default_mode_week_functions != DefaultWeekMode::SUNDAY)
|
||||
: enable_default_monday_first(context->getSettingsRef().first_day_of_week != FirstDayOfWeek::Sunday)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
SELECT
|
||||
toDateTime('2024-01-02 00:00:00', 'UTC') dt,
|
||||
toStartOfWeek(dt) w, -- Sunday, Dec 31
|
||||
toStartOfInterval(dt, toIntervalWeek(1)) w_1, -- Monday, Jan 01
|
||||
toStartOfInterval(dt, toIntervalWeek(2)) w_2, -- Monday, Dec 25
|
||||
toStartOfInterval(dt, INTERVAL 1 WEEK) w_1, -- Monday, Jan 01
|
||||
toStartOfInterval(dt, INTERVAL 2 WEEK) w_2, -- Monday, Dec 25
|
||||
toBool(w - w_1 = 0) b_1,
|
||||
toBool(w - w_2 = 7) b_2,
|
||||
toDateTime('2023-01-22 00:00:00', 'UTC') sunday,
|
||||
@ -18,8 +18,8 @@ SELECT
|
||||
SELECT
|
||||
toDateTime('2024-01-02 00:00:00', 'UTC') dt,
|
||||
toStartOfWeek(dt) w, -- Sunday, Dec 31
|
||||
toStartOfInterval(dt, toIntervalWeek(1)) w_1, -- Monday, Jan 01
|
||||
toStartOfInterval(dt, toIntervalWeek(2)) w_2, -- Monday, Dec 25
|
||||
toStartOfInterval(dt, INTERVAL 1 WEEK) w_1, -- Monday, Jan 01
|
||||
toStartOfInterval(dt, INTERVAL 2 WEEK) w_2, -- Monday, Dec 25
|
||||
toBool(w - w_1 = 0) b_1,
|
||||
toBool(w - w_2 = 7) b_2,
|
||||
toDateTime('2023-01-22 00:00:00', 'UTC') sunday,
|
||||
@ -30,13 +30,13 @@ SELECT
|
||||
age('week', monday, tuesday),
|
||||
age('week', sunday, monday),
|
||||
age('week', sunday, monday + toIntervalDay(10))
|
||||
SETTINGS default_mode_week_functions = 'monday';
|
||||
SETTINGS first_day_of_week = 'Monday';
|
||||
|
||||
SELECT
|
||||
toDateTime('2024-01-02 00:00:00', 'UTC') dt,
|
||||
toStartOfWeek(dt) w, -- Sunday, Dec 31
|
||||
toStartOfInterval(dt, toIntervalWeek(1)) w_1, -- Sunday, Dec 31
|
||||
toStartOfInterval(dt, toIntervalWeek(2)) w_2, -- Sunday, Dec 24
|
||||
toStartOfInterval(dt, INTERVAL 1 WEEK) w_1, -- Sunday, Dec 31
|
||||
toStartOfInterval(dt, INTERVAL 2 WEEK) w_2, -- Sunday, Dec 24
|
||||
toBool(w - w_1 = 0) b_1,
|
||||
toBool(w - w_2 = 7) b_2,
|
||||
toDateTime('2023-01-22 00:00:00', 'UTC') sunday,
|
||||
@ -47,4 +47,4 @@ SELECT
|
||||
age('week', monday, tuesday),
|
||||
age('week', sunday, monday),
|
||||
age('week', sunday, monday + toIntervalDay(10))
|
||||
SETTINGS default_mode_week_functions = 'sunday';
|
||||
SETTINGS first_day_of_week = 'Sunday';
|
Loading…
Reference in New Issue
Block a user