mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-19 16:20:50 +00:00
Merge branch 'master' into refactor_statistics
This commit is contained in:
commit
bc60dd2f7c
2
contrib/libarchive
vendored
2
contrib/libarchive
vendored
@ -1 +1 @@
|
||||
Subproject commit 0c21691b177fac5f4cceca2a1ff2ddfa5d60f51c
|
||||
Subproject commit 313aa1fa10b657de791e3202c168a6c833bc3543
|
@ -1,6 +1,6 @@
|
||||
set (LIBRARY_DIR "${ClickHouse_SOURCE_DIR}/contrib/libarchive")
|
||||
|
||||
set(SRCS
|
||||
set(SRCS
|
||||
"${LIBRARY_DIR}/libarchive/archive_acl.c"
|
||||
"${LIBRARY_DIR}/libarchive/archive_blake2sp_ref.c"
|
||||
"${LIBRARY_DIR}/libarchive/archive_blake2s_ref.c"
|
||||
@ -135,7 +135,7 @@ set(SRCS
|
||||
)
|
||||
|
||||
add_library(_libarchive ${SRCS})
|
||||
target_include_directories(_libarchive PUBLIC
|
||||
target_include_directories(_libarchive PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
"${LIBRARY_DIR}/libarchive"
|
||||
)
|
||||
@ -157,7 +157,7 @@ if (TARGET ch_contrib::zlib)
|
||||
endif()
|
||||
|
||||
if (TARGET ch_contrib::zstd)
|
||||
target_compile_definitions(_libarchive PUBLIC HAVE_ZSTD_H=1 HAVE_LIBZSTD=1 HAVE_LIBZSTD_COMPRESSOR=1)
|
||||
target_compile_definitions(_libarchive PUBLIC HAVE_ZSTD_H=1 HAVE_LIBZSTD=1 HAVE_ZSTD_compressStream=1)
|
||||
target_link_libraries(_libarchive PRIVATE ch_contrib::zstd)
|
||||
endif()
|
||||
|
||||
@ -179,4 +179,4 @@ if (OS_LINUX)
|
||||
)
|
||||
endif()
|
||||
|
||||
add_library(ch_contrib::libarchive ALIAS _libarchive)
|
||||
add_library(ch_contrib::libarchive ALIAS _libarchive)
|
||||
|
@ -334,13 +334,16 @@ typedef uint64_t uintmax_t;
|
||||
/* #undef ARCHIVE_XATTR_LINUX */
|
||||
|
||||
/* Version number of bsdcpio */
|
||||
#define BSDCPIO_VERSION_STRING "3.7.0"
|
||||
#define BSDCPIO_VERSION_STRING "3.7.4"
|
||||
|
||||
/* Version number of bsdtar */
|
||||
#define BSDTAR_VERSION_STRING "3.7.0"
|
||||
#define BSDTAR_VERSION_STRING "3.7.4"
|
||||
|
||||
/* Version number of bsdcat */
|
||||
#define BSDCAT_VERSION_STRING "3.7.0"
|
||||
#define BSDCAT_VERSION_STRING "3.7.4"
|
||||
|
||||
/* Version number of bsdunzip */
|
||||
#define BSDUNZIP_VERSION_STRING "3.7.4"
|
||||
|
||||
/* Define to 1 if you have the `acl_create_entry' function. */
|
||||
/* #undef HAVE_ACL_CREATE_ENTRY */
|
||||
@ -642,8 +645,8 @@ typedef uint64_t uintmax_t;
|
||||
/* Define to 1 if you have the `getgrnam_r' function. */
|
||||
#define HAVE_GETGRNAM_R 1
|
||||
|
||||
/* Define to 1 if platform uses `optreset` to reset `getopt` */
|
||||
#define HAVE_GETOPT_OPTRESET 1
|
||||
/* Define to 1 if you have the `getline' function. */
|
||||
#define HAVE_GETLINE 1
|
||||
|
||||
/* Define to 1 if you have the `getpid' function. */
|
||||
#define HAVE_GETPID 1
|
||||
@ -750,6 +753,12 @@ typedef uint64_t uintmax_t;
|
||||
/* Define to 1 if you have the `pcreposix' library (-lpcreposix). */
|
||||
/* #undef HAVE_LIBPCREPOSIX */
|
||||
|
||||
/* Define to 1 if you have the `pcre2-8' library (-lpcre2-8). */
|
||||
/* #undef HAVE_LIBPCRE2 */
|
||||
|
||||
/* Define to 1 if you have the `pcreposix' library (-lpcre2posix). */
|
||||
/* #undef HAVE_LIBPCRE2POSIX */
|
||||
|
||||
/* Define to 1 if you have the `xml2' library (-lxml2). */
|
||||
#define HAVE_LIBXML2 1
|
||||
|
||||
@ -765,9 +774,8 @@ typedef uint64_t uintmax_t;
|
||||
/* Define to 1 if you have the `zstd' library (-lzstd). */
|
||||
/* #undef HAVE_LIBZSTD */
|
||||
|
||||
/* Define to 1 if you have the `zstd' library (-lzstd) with compression
|
||||
support. */
|
||||
/* #undef HAVE_LIBZSTD_COMPRESSOR */
|
||||
/* Define to 1 if you have the ZSTD_compressStream function. */
|
||||
/* #undef HAVE_ZSTD_compressStream */
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
#define HAVE_LIMITS_H 1
|
||||
@ -923,6 +931,9 @@ typedef uint64_t uintmax_t;
|
||||
/* Define to 1 if you have the <pcreposix.h> header file. */
|
||||
/* #undef HAVE_PCREPOSIX_H */
|
||||
|
||||
/* Define to 1 if you have the <pcre2posix.h> header file. */
|
||||
/* #undef HAVE_PCRE2POSIX_H */
|
||||
|
||||
/* Define to 1 if you have the `pipe' function. */
|
||||
#define HAVE_PIPE 1
|
||||
|
||||
@ -1029,6 +1040,12 @@ typedef uint64_t uintmax_t;
|
||||
/* Define to 1 if you have the `strrchr' function. */
|
||||
#define HAVE_STRRCHR 1
|
||||
|
||||
/* Define to 1 if the system has the type `struct statfs'. */
|
||||
/* #undef HAVE_STRUCT_STATFS */
|
||||
|
||||
/* Define to 1 if `f_iosize' is a member of `struct statfs'. */
|
||||
/* #undef HAVE_STRUCT_STATFS_F_IOSIZE */
|
||||
|
||||
/* Define to 1 if `f_namemax' is a member of `struct statfs'. */
|
||||
/* #undef HAVE_STRUCT_STATFS_F_NAMEMAX */
|
||||
|
||||
@ -1077,6 +1094,9 @@ typedef uint64_t uintmax_t;
|
||||
/* Define to 1 if you have the `symlink' function. */
|
||||
#define HAVE_SYMLINK 1
|
||||
|
||||
/* Define to 1 if you have the `sysconf' function. */
|
||||
#define HAVE_SYSCONF 1
|
||||
|
||||
/* Define to 1 if you have the <sys/acl.h> header file. */
|
||||
/* #undef HAVE_SYS_ACL_H */
|
||||
|
||||
@ -1273,13 +1293,13 @@ typedef uint64_t uintmax_t;
|
||||
/* #undef HAVE__MKGMTIME */
|
||||
|
||||
/* Define as const if the declaration of iconv() needs const. */
|
||||
#define ICONV_CONST
|
||||
#define ICONV_CONST
|
||||
|
||||
/* Version number of libarchive as a single integer */
|
||||
#define LIBARCHIVE_VERSION_NUMBER "3007000"
|
||||
#define LIBARCHIVE_VERSION_NUMBER "3007004"
|
||||
|
||||
/* Version number of libarchive */
|
||||
#define LIBARCHIVE_VERSION_STRING "3.7.0"
|
||||
#define LIBARCHIVE_VERSION_STRING "3.7.4"
|
||||
|
||||
/* Define to 1 if `lstat' dereferences a symlink specified with a trailing
|
||||
slash. */
|
||||
@ -1333,7 +1353,7 @@ typedef uint64_t uintmax_t;
|
||||
#endif /* SAFE_TO_DEFINE_EXTENSIONS */
|
||||
|
||||
/* Version number of package */
|
||||
#define VERSION "3.7.0"
|
||||
#define VERSION "3.7.4"
|
||||
|
||||
/* Number of bits in a file offset, on hosts where this is settable. */
|
||||
/* #undef _FILE_OFFSET_BITS */
|
||||
|
10
docs/en/interfaces/third-party/gui.md
vendored
10
docs/en/interfaces/third-party/gui.md
vendored
@ -233,6 +233,16 @@ Features:
|
||||
- Useful tools: Zookeeper data exploration, query EXPLAIN, kill queries, etc.
|
||||
- Visualization metric charts: queries and resource usage, number of merges/mutation, merge performance, query performance, etc.
|
||||
|
||||
### CKibana {#ckibana}
|
||||
|
||||
[CKibana](https://github.com/TongchengOpenSource/ckibana) is a lightweight service that allows you to effortlessly search, explore, and visualize ClickHouse data using the native Kibana UI.
|
||||
|
||||
Features:
|
||||
|
||||
- Translates chart requests from the native Kibana UI into ClickHouse query syntax.
|
||||
- Supports advanced features such as sampling and caching to enhance query performance.
|
||||
- Minimizes the learning cost for users after migrating from ElasticSearch to ClickHouse.
|
||||
|
||||
## Commercial {#commercial}
|
||||
|
||||
### DataGrip {#datagrip}
|
||||
|
@ -47,6 +47,8 @@ keeper foo bar
|
||||
|
||||
- `ls '[path]'` -- Lists the nodes for the given path (default: cwd)
|
||||
- `cd '[path]'` -- Changes the working path (default `.`)
|
||||
- `cp '<src>' '<dest>'` -- Copies 'src' node to 'dest' path
|
||||
- `mv '<src>' '<dest>'` -- Moves 'src' node to the 'dest' path
|
||||
- `exists '<path>'` -- Returns `1` if node exists, `0` otherwise
|
||||
- `set '<path>' <value> [version]` -- Updates the node's value. Only updates if version matches (default: -1)
|
||||
- `create '<path>' <value> [mode]` -- Creates new node with the set value
|
||||
|
@ -1636,37 +1636,329 @@ SELECT toStartOfInterval(toDateTime('2023-01-01 14:45:00'), INTERVAL 1 MINUTE, t
|
||||
|
||||
Converts a date with time to a certain fixed date, while preserving the time.
|
||||
|
||||
**Syntax**
|
||||
|
||||
```sql
|
||||
toTime(date[,timezone])
|
||||
```
|
||||
|
||||
**Arguments**
|
||||
|
||||
- `date` — Date to convert to a time. [Date](../data-types/date.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md).
|
||||
- `timezone` (optional) — Timezone for the returned value. [String](../data-types/string.md).
|
||||
|
||||
**Returned value**
|
||||
|
||||
- DateTime with date equated to `1970-01-02` while preserving the time. [DateTime](../data-types/datetime.md).
|
||||
|
||||
:::note
|
||||
If the `date` input argument contained sub-second components,
|
||||
they will be dropped in the returned `DateTime` value with second-accuracy.
|
||||
:::
|
||||
|
||||
**Example**
|
||||
|
||||
Query:
|
||||
|
||||
```sql
|
||||
SELECT toTime(toDateTime64('1970-12-10 01:20:30.3000',3)) AS result, toTypeName(result);
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```response
|
||||
┌──────────────result─┬─toTypeName(result)─┐
|
||||
│ 1970-01-02 01:20:30 │ DateTime │
|
||||
└─────────────────────┴────────────────────┘
|
||||
```
|
||||
|
||||
## toRelativeYearNum
|
||||
|
||||
Converts a date, or date with time, to the number of the year, starting from a certain fixed point in the past.
|
||||
Converts a date, or date with time, to the number of years elapsed since a certain fixed point in the past.
|
||||
|
||||
**Syntax**
|
||||
|
||||
```sql
|
||||
toRelativeYearNum(date)
|
||||
```
|
||||
|
||||
**Arguments**
|
||||
|
||||
- `date` — Date or date with time. [Date](../data-types/date.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md).
|
||||
|
||||
**Returned value**
|
||||
|
||||
- The number of years from a fixed reference point in the past. [UInt16](../data-types/int-uint.md).
|
||||
|
||||
**Example**
|
||||
|
||||
Query:
|
||||
|
||||
```sql
|
||||
SELECT
|
||||
toRelativeYearNum(toDate('2002-12-08')) AS y1,
|
||||
toRelativeYearNum(toDate('2010-10-26')) AS y2
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```response
|
||||
┌───y1─┬───y2─┐
|
||||
│ 2002 │ 2010 │
|
||||
└──────┴──────┘
|
||||
```
|
||||
|
||||
## toRelativeQuarterNum
|
||||
|
||||
Converts a date, or date with time, to the number of the quarter, starting from a certain fixed point in the past.
|
||||
Converts a date, or date with time, to the number of quarters elapsed since a certain fixed point in the past.
|
||||
|
||||
**Syntax**
|
||||
|
||||
```sql
|
||||
toRelativeQuarterNum(date)
|
||||
```
|
||||
|
||||
**Arguments**
|
||||
|
||||
- `date` — Date or date with time. [Date](../data-types/date.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md).
|
||||
|
||||
**Returned value**
|
||||
|
||||
- The number of quarters from a fixed reference point in the past. [UInt32](../data-types/int-uint.md).
|
||||
|
||||
**Example**
|
||||
|
||||
Query:
|
||||
|
||||
```sql
|
||||
SELECT
|
||||
toRelativeQuarterNum(toDate('1993-11-25')) AS q1,
|
||||
toRelativeQuarterNum(toDate('2005-01-05')) AS q2
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```response
|
||||
┌───q1─┬───q2─┐
|
||||
│ 7975 │ 8020 │
|
||||
└──────┴──────┘
|
||||
```
|
||||
|
||||
## toRelativeMonthNum
|
||||
|
||||
Converts a date, or date with time, to the number of the month, starting from a certain fixed point in the past.
|
||||
Converts a date, or date with time, to the number of months elapsed since a certain fixed point in the past.
|
||||
|
||||
**Syntax**
|
||||
|
||||
```sql
|
||||
toRelativeMonthNum(date)
|
||||
```
|
||||
|
||||
**Arguments**
|
||||
|
||||
- `date` — Date or date with time. [Date](../data-types/date.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md).
|
||||
|
||||
**Returned value**
|
||||
|
||||
- The number of months from a fixed reference point in the past. [UInt32](../data-types/int-uint.md).
|
||||
|
||||
**Example**
|
||||
|
||||
Query:
|
||||
|
||||
```sql
|
||||
SELECT
|
||||
toRelativeMonthNum(toDate('2001-04-25')) AS m1,
|
||||
toRelativeMonthNum(toDate('2009-07-08')) AS m2
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```response
|
||||
┌────m1─┬────m2─┐
|
||||
│ 24016 │ 24115 │
|
||||
└───────┴───────┘
|
||||
```
|
||||
|
||||
## toRelativeWeekNum
|
||||
|
||||
Converts a date, or date with time, to the number of the week, starting from a certain fixed point in the past.
|
||||
Converts a date, or date with time, to the number of weeks elapsed since a certain fixed point in the past.
|
||||
|
||||
**Syntax**
|
||||
|
||||
```sql
|
||||
toRelativeWeekNum(date)
|
||||
```
|
||||
|
||||
**Arguments**
|
||||
|
||||
- `date` — Date or date with time. [Date](../data-types/date.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md).
|
||||
|
||||
**Returned value**
|
||||
|
||||
- The number of weeks from a fixed reference point in the past. [UInt32](../data-types/int-uint.md).
|
||||
|
||||
**Example**
|
||||
|
||||
Query:
|
||||
|
||||
```sql
|
||||
SELECT
|
||||
toRelativeWeekNum(toDate('2000-02-29')) AS w1,
|
||||
toRelativeWeekNum(toDate('2001-01-12')) AS w2
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```response
|
||||
┌───w1─┬───w2─┐
|
||||
│ 1574 │ 1619 │
|
||||
└──────┴──────┘
|
||||
```
|
||||
|
||||
## toRelativeDayNum
|
||||
|
||||
Converts a date, or date with time, to the number of the day, starting from a certain fixed point in the past.
|
||||
Converts a date, or date with time, to the number of days elapsed since a certain fixed point in the past.
|
||||
|
||||
**Syntax**
|
||||
|
||||
```sql
|
||||
toRelativeDayNum(date)
|
||||
```
|
||||
|
||||
**Arguments**
|
||||
|
||||
- `date` — Date or date with time. [Date](../data-types/date.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md).
|
||||
|
||||
**Returned value**
|
||||
|
||||
- The number of days from a fixed reference point in the past. [UInt32](../data-types/int-uint.md).
|
||||
|
||||
**Example**
|
||||
|
||||
Query:
|
||||
|
||||
```sql
|
||||
SELECT
|
||||
toRelativeDayNum(toDate('1993-10-05')) AS d1,
|
||||
toRelativeDayNum(toDate('2000-09-20')) AS d2
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```response
|
||||
┌───d1─┬────d2─┐
|
||||
│ 8678 │ 11220 │
|
||||
└──────┴───────┘
|
||||
```
|
||||
|
||||
## toRelativeHourNum
|
||||
|
||||
Converts a date, or date with time, to the number of the hour, starting from a certain fixed point in the past.
|
||||
Converts a date, or date with time, to the number of hours elapsed since a certain fixed point in the past.
|
||||
|
||||
**Syntax**
|
||||
|
||||
```sql
|
||||
toRelativeHourNum(date)
|
||||
```
|
||||
|
||||
**Arguments**
|
||||
|
||||
- `date` — Date or date with time. [Date](../data-types/date.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md).
|
||||
|
||||
**Returned value**
|
||||
|
||||
- The number of hours from a fixed reference point in the past. [UInt32](../data-types/int-uint.md).
|
||||
|
||||
**Example**
|
||||
|
||||
Query:
|
||||
|
||||
```sql
|
||||
SELECT
|
||||
toRelativeHourNum(toDateTime('1993-10-05 05:20:36')) AS h1,
|
||||
toRelativeHourNum(toDateTime('2000-09-20 14:11:29')) AS h2
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```response
|
||||
┌─────h1─┬─────h2─┐
|
||||
│ 208276 │ 269292 │
|
||||
└────────┴────────┘
|
||||
```
|
||||
|
||||
## toRelativeMinuteNum
|
||||
|
||||
Converts a date, or date with time, to the number of the minute, starting from a certain fixed point in the past.
|
||||
Converts a date, or date with time, to the number of minutes elapsed since a certain fixed point in the past.
|
||||
|
||||
**Syntax**
|
||||
|
||||
```sql
|
||||
toRelativeMinuteNum(date)
|
||||
```
|
||||
|
||||
**Arguments**
|
||||
|
||||
- `date` — Date or date with time. [Date](../data-types/date.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md).
|
||||
|
||||
**Returned value**
|
||||
|
||||
- The number of minutes from a fixed reference point in the past. [UInt32](../data-types/int-uint.md).
|
||||
|
||||
**Example**
|
||||
|
||||
Query:
|
||||
|
||||
```sql
|
||||
SELECT
|
||||
toRelativeMinuteNum(toDateTime('1993-10-05 05:20:36')) AS m1,
|
||||
toRelativeMinuteNum(toDateTime('2000-09-20 14:11:29')) AS m2
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```response
|
||||
┌───────m1─┬───────m2─┐
|
||||
│ 12496580 │ 16157531 │
|
||||
└──────────┴──────────┘
|
||||
```
|
||||
|
||||
## toRelativeSecondNum
|
||||
|
||||
Converts a date, or date with time, to the number of the second, starting from a certain fixed point in the past.
|
||||
Converts a date, or date with time, to the number of the seconds elapsed since a certain fixed point in the past.
|
||||
|
||||
**Syntax**
|
||||
|
||||
```sql
|
||||
toRelativeSecondNum(date)
|
||||
```
|
||||
|
||||
**Arguments**
|
||||
|
||||
- `date` — Date or date with time. [Date](../data-types/date.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md).
|
||||
|
||||
**Returned value**
|
||||
|
||||
- The number of seconds from a fixed reference point in the past. [UInt32](../data-types/int-uint.md).
|
||||
|
||||
**Example**
|
||||
|
||||
Query:
|
||||
|
||||
```sql
|
||||
SELECT
|
||||
toRelativeSecondNum(toDateTime('1993-10-05 05:20:36')) AS s1,
|
||||
toRelativeSecondNum(toDateTime('2000-09-20 14:11:29')) AS s2
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```response
|
||||
┌────────s1─┬────────s2─┐
|
||||
│ 749794836 │ 969451889 │
|
||||
└───────────┴───────────┘
|
||||
```
|
||||
|
||||
## toISOYear
|
||||
|
||||
|
@ -3906,7 +3906,7 @@ Result:
|
||||
|
||||
## toDateTime64
|
||||
|
||||
Converts the argument to the [DateTime64](../data-types/datetime64.md) data type.
|
||||
Converts an input value to a value of type [DateTime64](../data-types/datetime64.md).
|
||||
|
||||
**Syntax**
|
||||
|
||||
@ -3918,7 +3918,7 @@ toDateTime64(expr, scale, [timezone])
|
||||
|
||||
- `expr` — The value. [String](../data-types/string.md), [UInt32](../data-types/int-uint.md), [Float](../data-types/float.md) or [DateTime](../data-types/datetime.md).
|
||||
- `scale` - Tick size (precision): 10<sup>-precision</sup> seconds. Valid range: [ 0 : 9 ].
|
||||
- `timezone` - Time zone of the specified datetime64 object.
|
||||
- `timezone` (optional) - Time zone of the specified datetime64 object.
|
||||
|
||||
**Returned value**
|
||||
|
||||
@ -3977,10 +3977,137 @@ SELECT toDateTime64('2019-01-01 00:00:00', 3, 'Asia/Istanbul') AS value, toTypeN
|
||||
|
||||
## toDateTime64OrZero
|
||||
|
||||
Like [toDateTime64](#todatetime64), this function converts an input value to a value of type [DateTime64](../data-types/datetime64.md) but returns the min value of [DateTime64](../data-types/datetime64.md) if an invalid argument is received.
|
||||
|
||||
**Syntax**
|
||||
|
||||
``` sql
|
||||
toDateTime64OrZero(expr, scale, [timezone])
|
||||
```
|
||||
|
||||
**Arguments**
|
||||
|
||||
- `expr` — The value. [String](../data-types/string.md), [UInt32](../data-types/int-uint.md), [Float](../data-types/float.md) or [DateTime](../data-types/datetime.md).
|
||||
- `scale` - Tick size (precision): 10<sup>-precision</sup> seconds. Valid range: [ 0 : 9 ].
|
||||
- `timezone` (optional) - Time zone of the specified DateTime64 object.
|
||||
|
||||
**Returned value**
|
||||
|
||||
- A calendar date and time of day, with sub-second precision, otherwise the minimum value of `DateTime64`: `1970-01-01 01:00:00.000`. [DateTime64](../data-types/datetime64.md).
|
||||
|
||||
**Example**
|
||||
|
||||
Query:
|
||||
|
||||
```sql
|
||||
SELECT toDateTime64OrZero('2008-10-12 00:00:00 00:30:30', 3) AS invalid_arg
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```response
|
||||
┌─────────────invalid_arg─┐
|
||||
│ 1970-01-01 01:00:00.000 │
|
||||
└─────────────────────────┘
|
||||
```
|
||||
|
||||
**See also**
|
||||
|
||||
- [toDateTime64](#todatetime64).
|
||||
- [toDateTime64OrNull](#todatetime64ornull).
|
||||
- [toDateTime64OrDefault](#todatetime64ordefault).
|
||||
|
||||
## toDateTime64OrNull
|
||||
|
||||
Like [toDateTime64](#todatetime64), this function converts an input value to a value of type [DateTime64](../data-types/datetime64.md) but returns `NULL` if an invalid argument is received.
|
||||
|
||||
**Syntax**
|
||||
|
||||
``` sql
|
||||
toDateTime64OrNull(expr, scale, [timezone])
|
||||
```
|
||||
|
||||
**Arguments**
|
||||
|
||||
- `expr` — The value. [String](../data-types/string.md), [UInt32](../data-types/int-uint.md), [Float](../data-types/float.md) or [DateTime](../data-types/datetime.md).
|
||||
- `scale` - Tick size (precision): 10<sup>-precision</sup> seconds. Valid range: [ 0 : 9 ].
|
||||
- `timezone` (optional) - Time zone of the specified DateTime64 object.
|
||||
|
||||
**Returned value**
|
||||
|
||||
- A calendar date and time of day, with sub-second precision, otherwise `NULL`. [DateTime64](../data-types/datetime64.md)/[NULL](../data-types/nullable.md).
|
||||
|
||||
**Example**
|
||||
|
||||
Query:
|
||||
|
||||
```sql
|
||||
SELECT
|
||||
toDateTime64OrNull('1976-10-18 00:00:00.30', 3) AS valid_arg,
|
||||
toDateTime64OrNull('1976-10-18 00:00:00 30', 3) AS invalid_arg
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```response
|
||||
┌───────────────valid_arg─┬─invalid_arg─┐
|
||||
│ 1976-10-18 00:00:00.300 │ ᴺᵁᴸᴸ │
|
||||
└─────────────────────────┴─────────────┘
|
||||
```
|
||||
|
||||
**See also**
|
||||
|
||||
- [toDateTime64](#todatetime64).
|
||||
- [toDateTime64OrZero](#todatetime64orzero).
|
||||
- [toDateTime64OrDefault](#todatetime64ordefault).
|
||||
|
||||
## toDateTime64OrDefault
|
||||
|
||||
Like [toDateTime64](#todatetime64), this function converts an input value to a value of type [DateTime64](../data-types/datetime64.md),
|
||||
but returns either the default value of [DateTime64](../data-types/datetime64.md)
|
||||
or the provided default if an invalid argument is received.
|
||||
|
||||
**Syntax**
|
||||
|
||||
``` sql
|
||||
toDateTime64OrNull(expr, scale, [timezone, default])
|
||||
```
|
||||
|
||||
**Arguments**
|
||||
|
||||
- `expr` — The value. [String](../data-types/string.md), [UInt32](../data-types/int-uint.md), [Float](../data-types/float.md) or [DateTime](../data-types/datetime.md).
|
||||
- `scale` - Tick size (precision): 10<sup>-precision</sup> seconds. Valid range: [ 0 : 9 ].
|
||||
- `timezone` (optional) - Time zone of the specified DateTime64 object.
|
||||
- `default` (optional) - Default value to return if an invalid argument is received. [DateTime64](../data-types/datetime64.md).
|
||||
|
||||
**Returned value**
|
||||
|
||||
- A calendar date and time of day, with sub-second precision, otherwise the minimum value of `DateTime64` or the `default` value if provided. [DateTime64](../data-types/datetime64.md).
|
||||
|
||||
**Example**
|
||||
|
||||
Query:
|
||||
|
||||
```sql
|
||||
SELECT
|
||||
toDateTime64OrDefault('1976-10-18 00:00:00 30', 3) AS invalid_arg,
|
||||
toDateTime64OrDefault('1976-10-18 00:00:00 30', 3, 'UTC', toDateTime64('2001-01-01 00:00:00.00',3)) AS invalid_arg_with_default
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```response
|
||||
┌─────────────invalid_arg─┬─invalid_arg_with_default─┐
|
||||
│ 1970-01-01 01:00:00.000 │ 2000-12-31 23:00:00.000 │
|
||||
└─────────────────────────┴──────────────────────────┘
|
||||
```
|
||||
|
||||
**See also**
|
||||
|
||||
- [toDateTime64](#todatetime64).
|
||||
- [toDateTime64OrZero](#todatetime64orzero).
|
||||
- [toDateTime64OrNull](#todatetime64ornull).
|
||||
|
||||
## toDecimal32
|
||||
|
||||
Converts an input value to a value of type [`Decimal(9, S)`](../data-types/decimal.md) with scale of `S`. Throws an exception in case of an error.
|
||||
|
@ -168,7 +168,7 @@ std::vector<ConnectionPoolWithFailover::TryResult> ConnectionPoolWithFailover::g
|
||||
{ return tryGetEntry(pool, timeouts, fail_message, settings, &table_to_check, /*async_callback=*/ {}); };
|
||||
|
||||
return getManyImpl(settings, pool_mode, try_get_entry,
|
||||
/*skip_unavailable_endpoints=*/ std::nullopt,
|
||||
/*skip_unavailable_endpoints=*/ false, /// skip_unavailable_endpoints is used to get the min number of entries, and we need at least one
|
||||
/*priority_func=*/ {},
|
||||
settings.distributed_insert_skip_read_only_replicas);
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public:
|
||||
size_t max_error_cap = DBMS_CONNECTION_POOL_WITH_FAILOVER_MAX_ERROR_COUNT);
|
||||
|
||||
using Entry = IConnectionPool::Entry;
|
||||
using PoolWithFailoverBase<IConnectionPool>::checkTryResultIsValid;
|
||||
using PoolWithFailoverBase<IConnectionPool>::getValidTryResult;
|
||||
|
||||
/** Allocates connection to work. */
|
||||
Entry get(const ConnectionTimeouts & timeouts) override;
|
||||
@ -98,7 +98,7 @@ public:
|
||||
|
||||
std::vector<Base::ShuffledPool> getShuffledPools(const Settings & settings, GetPriorityFunc priority_func = {}, bool use_slowdown_count = false);
|
||||
|
||||
size_t getMaxErrorCup() const { return Base::max_error_cap; }
|
||||
size_t getMaxErrorCap() const { return Base::max_error_cap; }
|
||||
|
||||
void updateSharedError(std::vector<ShuffledPool> & shuffled_pools)
|
||||
{
|
||||
|
@ -327,7 +327,7 @@ HedgedConnectionsFactory::State HedgedConnectionsFactory::processFinishedConnect
|
||||
ShuffledPool & shuffled_pool = shuffled_pools[index];
|
||||
LOG_INFO(log, "Connection failed at try №{}, reason: {}", (shuffled_pool.error_count + 1), fail_message);
|
||||
|
||||
shuffled_pool.error_count = std::min(pool->getMaxErrorCup(), shuffled_pool.error_count + 1);
|
||||
shuffled_pool.error_count = std::min(pool->getMaxErrorCap(), shuffled_pool.error_count + 1);
|
||||
shuffled_pool.slowdown_count = 0;
|
||||
|
||||
if (shuffled_pool.error_count >= max_tries)
|
||||
|
@ -122,12 +122,18 @@ public:
|
||||
return result.entry.isNull() || !result.is_usable || (skip_read_only_replicas && result.is_readonly);
|
||||
}
|
||||
|
||||
void checkTryResultIsValid(const TryResult & result, bool skip_read_only_replicas) const
|
||||
TryResult getValidTryResult(const std::vector<TryResult> & results, bool skip_read_only_replicas) const
|
||||
{
|
||||
if (results.empty())
|
||||
throw DB::Exception(DB::ErrorCodes::ALL_CONNECTION_TRIES_FAILED, "Cannot get any valid connection because all connection tries failed");
|
||||
|
||||
auto result = results.front();
|
||||
if (isTryResultInvalid(result, skip_read_only_replicas))
|
||||
throw DB::Exception(DB::ErrorCodes::LOGICAL_ERROR,
|
||||
"Got an invalid connection result: entry.isNull {}, is_usable {}, is_up_to_date {}, delay {}, is_readonly {}, skip_read_only_replicas {}",
|
||||
result.entry.isNull(), result.is_usable, result.is_up_to_date, result.delay, result.is_readonly, skip_read_only_replicas);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
size_t getPoolSize() const { return nested_pools.size(); }
|
||||
|
@ -40,7 +40,7 @@ static constexpr auto SHOW_CHARS_ON_SYNTAX_ERROR = ptrdiff_t(160);
|
||||
/// each period reduces the error counter by 2 times
|
||||
/// too short a period can cause errors to disappear immediately after creation.
|
||||
static constexpr auto DBMS_CONNECTION_POOL_WITH_FAILOVER_DEFAULT_DECREASE_ERROR_PERIOD = 60;
|
||||
/// replica error max cap, this is to prevent replica from accumulating too many errors and taking to long to recover.
|
||||
/// replica error max cap, this is to prevent replica from accumulating too many errors and taking too long to recover.
|
||||
static constexpr auto DBMS_CONNECTION_POOL_WITH_FAILOVER_MAX_ERROR_COUNT = 1000;
|
||||
|
||||
/// The boundary on which the blocks for asynchronous file operations should be aligned.
|
||||
|
@ -83,7 +83,7 @@ static std::initializer_list<std::pair<ClickHouseVersion, SettingsChangesHistory
|
||||
},
|
||||
{"24.8",
|
||||
{
|
||||
{"rows_before_aggregation", true, true, "Provide exact value for rows_before_aggregation statistic, represents the number of rows read before aggregation"},
|
||||
{"rows_before_aggregation", false, false, "Provide exact value for rows_before_aggregation statistic, represents the number of rows read before aggregation"},
|
||||
{"restore_replace_external_table_functions_to_null", false, false, "New setting."},
|
||||
{"restore_replace_external_engines_to_null", false, false, "New setting."},
|
||||
{"input_format_json_max_depth", 1000000, 1000, "It was unlimited in previous versions, but that was unsafe."},
|
||||
|
@ -242,8 +242,7 @@ void DistributedAsyncInsertBatch::sendBatch(const SettingsChanges & settings_cha
|
||||
|
||||
auto timeouts = ConnectionTimeouts::getTCPTimeoutsWithFailover(insert_settings);
|
||||
auto results = parent.pool->getManyCheckedForInsert(timeouts, insert_settings, PoolMode::GET_ONE, parent.storage.remote_storage.getQualifiedName());
|
||||
auto result = results.front();
|
||||
parent.pool->checkTryResultIsValid(result, insert_settings.distributed_insert_skip_read_only_replicas);
|
||||
auto result = parent.pool->getValidTryResult(results, insert_settings.distributed_insert_skip_read_only_replicas);
|
||||
connection = std::move(result.entry);
|
||||
compression_expected = connection->getCompression() == Protocol::Compression::Enable;
|
||||
|
||||
@ -302,8 +301,7 @@ void DistributedAsyncInsertBatch::sendSeparateFiles(const SettingsChanges & sett
|
||||
|
||||
auto timeouts = ConnectionTimeouts::getTCPTimeoutsWithFailover(insert_settings);
|
||||
auto results = parent.pool->getManyCheckedForInsert(timeouts, insert_settings, PoolMode::GET_ONE, parent.storage.remote_storage.getQualifiedName());
|
||||
auto result = results.front();
|
||||
parent.pool->checkTryResultIsValid(result, insert_settings.distributed_insert_skip_read_only_replicas);
|
||||
auto result = parent.pool->getValidTryResult(results, insert_settings.distributed_insert_skip_read_only_replicas);
|
||||
auto connection = std::move(result.entry);
|
||||
bool compression_expected = connection->getCompression() == Protocol::Compression::Enable;
|
||||
|
||||
|
@ -415,8 +415,7 @@ void DistributedAsyncInsertDirectoryQueue::processFile(std::string & file_path,
|
||||
|
||||
auto timeouts = ConnectionTimeouts::getTCPTimeoutsWithFailover(insert_settings);
|
||||
auto results = pool->getManyCheckedForInsert(timeouts, insert_settings, PoolMode::GET_ONE, storage.remote_storage.getQualifiedName());
|
||||
auto result = results.front();
|
||||
pool->checkTryResultIsValid(result, insert_settings.distributed_insert_skip_read_only_replicas);
|
||||
auto result = pool->getValidTryResult(results, insert_settings.distributed_insert_skip_read_only_replicas);
|
||||
auto connection = std::move(result.entry);
|
||||
|
||||
LOG_DEBUG(log, "Sending `{}` to {} ({} rows, {} bytes)",
|
||||
|
@ -377,8 +377,7 @@ DistributedSink::runWritingJob(JobReplica & job, const Block & current_block, si
|
||||
/// NOTE: INSERT will also take into account max_replica_delay_for_distributed_queries
|
||||
/// (anyway fallback_to_stale_replicas_for_distributed_queries=true by default)
|
||||
auto results = shard_info.pool->getManyCheckedForInsert(timeouts, settings, PoolMode::GET_ONE, storage.remote_storage.getQualifiedName());
|
||||
auto result = results.front();
|
||||
shard_info.pool->checkTryResultIsValid(result, settings.distributed_insert_skip_read_only_replicas);
|
||||
auto result = shard_info.pool->getValidTryResult(results, settings.distributed_insert_skip_read_only_replicas);
|
||||
job.connection_entry = std::move(result.entry);
|
||||
}
|
||||
else
|
||||
|
@ -11,7 +11,7 @@ create table t (x UInt64, s String) engine = MergeTree order by x SETTINGS index
|
||||
INSERT INTO t SELECT
|
||||
number,
|
||||
if(number < (8129 * 1024), arrayStringConcat(arrayMap(x -> toString(x), range(number % 128)), ' '), '')
|
||||
FROM numbers_mt((8129 * 1024) * 3) settings max_insert_threads=8, max_rows_to_read=0;
|
||||
FROM numbers_mt((8129 * 1024) * 3) settings max_insert_threads=8, max_rows_to_read=0, max_memory_usage='10Gi';
|
||||
|
||||
-- optimize table t final;
|
||||
|
||||
|
@ -152,6 +152,7 @@ ChannelID
|
||||
Cidr
|
||||
Ciphertext
|
||||
CityHash
|
||||
CKibana
|
||||
Clangd
|
||||
ClickBench
|
||||
ClickCat
|
||||
@ -248,6 +249,7 @@ DoubleDelta
|
||||
Doxygen
|
||||
Durre
|
||||
ECMA
|
||||
ElasticSearch
|
||||
ETag
|
||||
Ecto
|
||||
EdgeAngle
|
||||
@ -473,6 +475,7 @@ KeeperMap
|
||||
KeeperOutstandingRequests
|
||||
Kerberos
|
||||
Khanna
|
||||
Kibana
|
||||
KittenHouse
|
||||
Klickhouse
|
||||
Kolmogorov
|
||||
@ -1370,6 +1373,7 @@ cipherList
|
||||
ciphertext
|
||||
cityHash
|
||||
cityhash
|
||||
ckibana
|
||||
ckman
|
||||
clangd
|
||||
cli
|
||||
@ -2587,6 +2591,7 @@ sqlinsert
|
||||
sqlite
|
||||
sqrt
|
||||
src
|
||||
dest
|
||||
srcReplicas
|
||||
sshkey
|
||||
stackoverflow
|
||||
|
Loading…
Reference in New Issue
Block a user