mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 09:32:06 +00:00
Merge remote-tracking branch 'origin/master' into flaky-01603
This commit is contained in:
commit
efa85d9cd2
@ -10,6 +10,8 @@ sidebar_label: Nullable
|
|||||||
|
|
||||||
Returns whether the argument is [NULL](../../sql-reference/syntax.md#null).
|
Returns whether the argument is [NULL](../../sql-reference/syntax.md#null).
|
||||||
|
|
||||||
|
See also operator [`IS NULL`](../operators/index.md#is_null).
|
||||||
|
|
||||||
``` sql
|
``` sql
|
||||||
isNull(x)
|
isNull(x)
|
||||||
```
|
```
|
||||||
@ -54,6 +56,8 @@ Result:
|
|||||||
|
|
||||||
Returns whether the argument is not [NULL](../../sql-reference/syntax.md#null-literal).
|
Returns whether the argument is not [NULL](../../sql-reference/syntax.md#null-literal).
|
||||||
|
|
||||||
|
See also operator [`IS NOT NULL`](../operators/index.md#is_not_null).
|
||||||
|
|
||||||
``` sql
|
``` sql
|
||||||
isNotNull(x)
|
isNotNull(x)
|
||||||
```
|
```
|
||||||
|
@ -298,7 +298,7 @@ Full columns and constants are represented differently in memory. Functions usua
|
|||||||
Accepts any arguments, including `NULL` and does nothing. Always returns 0.
|
Accepts any arguments, including `NULL` and does nothing. Always returns 0.
|
||||||
The argument is internally still evaluated. Useful e.g. for benchmarks.
|
The argument is internally still evaluated. Useful e.g. for benchmarks.
|
||||||
|
|
||||||
## sleep(seconds)
|
## sleep
|
||||||
|
|
||||||
Used to introduce a delay or pause in the execution of a query. It is primarily used for testing and debugging purposes.
|
Used to introduce a delay or pause in the execution of a query. It is primarily used for testing and debugging purposes.
|
||||||
|
|
||||||
@ -310,7 +310,7 @@ sleep(seconds)
|
|||||||
|
|
||||||
**Arguments**
|
**Arguments**
|
||||||
|
|
||||||
- `seconds`: [Int](../../sql-reference/data-types/int-uint.md) The number of seconds to pause the query execution to a maximum of 3 seconds. It can be a floating-point value to specify fractional seconds.
|
- `seconds`: [UInt*](../../sql-reference/data-types/int-uint.md) or [Float](../../sql-reference/data-types/float.md) The number of seconds to pause the query execution to a maximum of 3 seconds. It can be a floating-point value to specify fractional seconds.
|
||||||
|
|
||||||
**Returned value**
|
**Returned value**
|
||||||
|
|
||||||
@ -360,7 +360,7 @@ sleepEachRow(seconds)
|
|||||||
|
|
||||||
**Arguments**
|
**Arguments**
|
||||||
|
|
||||||
- `seconds`: [Int](../../sql-reference/data-types/int-uint.md) The number of seconds to pause the query execution for each row in the result set to a maximum of 3 seconds. It can be a floating-point value to specify fractional seconds.
|
- `seconds`: [UInt*](../../sql-reference/data-types/int-uint.md) or [Float*](../../sql-reference/data-types/float.md) The number of seconds to pause the query execution for each row in the result set to a maximum of 3 seconds. It can be a floating-point value to specify fractional seconds.
|
||||||
|
|
||||||
**Returned value**
|
**Returned value**
|
||||||
|
|
||||||
|
@ -353,7 +353,7 @@ For efficiency, the `and` and `or` functions accept any number of arguments. The
|
|||||||
|
|
||||||
ClickHouse supports the `IS NULL` and `IS NOT NULL` operators.
|
ClickHouse supports the `IS NULL` and `IS NOT NULL` operators.
|
||||||
|
|
||||||
### IS NULL
|
### IS NULL {#is_null}
|
||||||
|
|
||||||
- For [Nullable](../../sql-reference/data-types/nullable.md) type values, the `IS NULL` operator returns:
|
- For [Nullable](../../sql-reference/data-types/nullable.md) type values, the `IS NULL` operator returns:
|
||||||
- `1`, if the value is `NULL`.
|
- `1`, if the value is `NULL`.
|
||||||
@ -374,7 +374,7 @@ SELECT x+100 FROM t_null WHERE y IS NULL
|
|||||||
└──────────────┘
|
└──────────────┘
|
||||||
```
|
```
|
||||||
|
|
||||||
### IS NOT NULL
|
### IS NOT NULL {#is_not_null}
|
||||||
|
|
||||||
- For [Nullable](../../sql-reference/data-types/nullable.md) type values, the `IS NOT NULL` operator returns:
|
- For [Nullable](../../sql-reference/data-types/nullable.md) type values, the `IS NOT NULL` operator returns:
|
||||||
- `0`, if the value is `NULL`.
|
- `0`, if the value is `NULL`.
|
||||||
|
@ -50,6 +50,7 @@
|
|||||||
#include <Functions/registerFunctions.h>
|
#include <Functions/registerFunctions.h>
|
||||||
#include <AggregateFunctions/registerAggregateFunctions.h>
|
#include <AggregateFunctions/registerAggregateFunctions.h>
|
||||||
#include <Formats/registerFormats.h>
|
#include <Formats/registerFormats.h>
|
||||||
|
#include <Formats/FormatFactory.h>
|
||||||
|
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
using namespace std::literals;
|
using namespace std::literals;
|
||||||
@ -1137,6 +1138,13 @@ void Client::processOptions(const OptionsDescription & options_description,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static bool checkIfStdoutIsRegularFile()
|
||||||
|
{
|
||||||
|
struct stat file_stat;
|
||||||
|
return fstat(STDOUT_FILENO, &file_stat) == 0 && S_ISREG(file_stat.st_mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Client::processConfig()
|
void Client::processConfig()
|
||||||
{
|
{
|
||||||
if (!queries.empty() && config().has("queries-file"))
|
if (!queries.empty() && config().has("queries-file"))
|
||||||
@ -1173,7 +1181,14 @@ void Client::processConfig()
|
|||||||
pager = config().getString("pager", "");
|
pager = config().getString("pager", "");
|
||||||
|
|
||||||
is_default_format = !config().has("vertical") && !config().has("format");
|
is_default_format = !config().has("vertical") && !config().has("format");
|
||||||
if (config().has("vertical"))
|
if (is_default_format && checkIfStdoutIsRegularFile())
|
||||||
|
{
|
||||||
|
is_default_format = false;
|
||||||
|
std::optional<String> format_from_file_name;
|
||||||
|
format_from_file_name = FormatFactory::instance().tryGetFormatFromFileDescriptor(STDOUT_FILENO);
|
||||||
|
format = format_from_file_name ? *format_from_file_name : "TabSeparated";
|
||||||
|
}
|
||||||
|
else if (config().has("vertical"))
|
||||||
format = config().getString("format", "Vertical");
|
format = config().getString("format", "Vertical");
|
||||||
else
|
else
|
||||||
format = config().getString("format", is_interactive ? "PrettyCompact" : "TabSeparated");
|
format = config().getString("format", is_interactive ? "PrettyCompact" : "TabSeparated");
|
||||||
|
@ -327,6 +327,14 @@ static bool checkIfStdinIsRegularFile()
|
|||||||
return fstat(STDIN_FILENO, &file_stat) == 0 && S_ISREG(file_stat.st_mode);
|
return fstat(STDIN_FILENO, &file_stat) == 0 && S_ISREG(file_stat.st_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static bool checkIfStdoutIsRegularFile()
|
||||||
|
{
|
||||||
|
struct stat file_stat;
|
||||||
|
return fstat(STDOUT_FILENO, &file_stat) == 0 && S_ISREG(file_stat.st_mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string LocalServer::getInitialCreateTableQuery()
|
std::string LocalServer::getInitialCreateTableQuery()
|
||||||
{
|
{
|
||||||
if (!config().has("table-structure") && !config().has("table-file") && !config().has("table-data-format") && (!checkIfStdinIsRegularFile() || queries.empty()))
|
if (!config().has("table-structure") && !config().has("table-file") && !config().has("table-data-format") && (!checkIfStdinIsRegularFile() || queries.empty()))
|
||||||
@ -638,6 +646,13 @@ void LocalServer::processConfig()
|
|||||||
if (config().has("macros"))
|
if (config().has("macros"))
|
||||||
global_context->setMacros(std::make_unique<Macros>(config(), "macros", log));
|
global_context->setMacros(std::make_unique<Macros>(config(), "macros", log));
|
||||||
|
|
||||||
|
if (!config().has("output-format") && !config().has("format") && checkIfStdoutIsRegularFile())
|
||||||
|
{
|
||||||
|
std::optional<String> format_from_file_name;
|
||||||
|
format_from_file_name = FormatFactory::instance().tryGetFormatFromFileDescriptor(STDOUT_FILENO);
|
||||||
|
format = format_from_file_name ? *format_from_file_name : "TSV";
|
||||||
|
}
|
||||||
|
else
|
||||||
format = config().getString("output-format", config().getString("format", is_interactive ? "PrettyCompact" : "TSV"));
|
format = config().getString("output-format", config().getString("format", is_interactive ? "PrettyCompact" : "TSV"));
|
||||||
insert_format = "Values";
|
insert_format = "Values";
|
||||||
|
|
||||||
|
@ -62,32 +62,17 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the name of the function.
|
String getName() const override { return name; }
|
||||||
String getName() const override
|
bool isSuitableForConstantFolding() const override { return false; } /// Do not sleep during query analysis.
|
||||||
{
|
size_t getNumberOfArguments() const override { return 1; }
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Do not sleep during query analysis.
|
|
||||||
bool isSuitableForConstantFolding() const override
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t getNumberOfArguments() const override
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isSuitableForShortCircuitArgumentsExecution(const DataTypesWithConstInfo & /*arguments*/) const override { return true; }
|
bool isSuitableForShortCircuitArgumentsExecution(const DataTypesWithConstInfo & /*arguments*/) const override { return true; }
|
||||||
|
|
||||||
DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override
|
DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override
|
||||||
{
|
{
|
||||||
WhichDataType which(arguments[0]);
|
WhichDataType which(arguments[0]);
|
||||||
|
|
||||||
if (!which.isFloat()
|
if (!which.isFloat() && !which.isNativeUInt())
|
||||||
&& !which.isNativeUInt())
|
throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Illegal type {} of argument of function {}, expected UInt* or Float*",
|
||||||
throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Illegal type {} of argument of function {}, expected Float64",
|
|
||||||
arguments[0]->getName(), getName());
|
arguments[0]->getName(), getName());
|
||||||
|
|
||||||
return std::make_shared<DataTypeUInt8>();
|
return std::make_shared<DataTypeUInt8>();
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
0
|
||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
4
|
||||||
|
5
|
||||||
|
6
|
||||||
|
7
|
||||||
|
8
|
||||||
|
9
|
||||||
|
0
|
||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
4
|
||||||
|
5
|
||||||
|
6
|
||||||
|
7
|
||||||
|
8
|
||||||
|
9
|
13
tests/queries/0_stateless/02181_detect_output_format_by_file_extension.sh
Executable file
13
tests/queries/0_stateless/02181_detect_output_format_by_file_extension.sh
Executable file
@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Tags: no-parallel, no-fasttest
|
||||||
|
|
||||||
|
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||||
|
# shellcheck source=../shell_config.sh
|
||||||
|
. "$CURDIR"/../shell_config.sh
|
||||||
|
|
||||||
|
|
||||||
|
$CLICKHOUSE_LOCAL -q "select * from numbers(10)" > $CLICKHOUSE_TMP/data.parquet
|
||||||
|
$CLICKHOUSE_LOCAL -q "select * from table" < $CLICKHOUSE_TMP/data.parquet
|
||||||
|
|
||||||
|
$CLICKHOUSE_CLIENT -q "select * from numbers(10)" > $CLICKHOUSE_TMP/data.parquet
|
||||||
|
$CLICKHOUSE_LOCAL -q "select * from table" < $CLICKHOUSE_TMP/data.parquet
|
15
tests/queries/0_stateless/02995_forget_partition.sql → tests/queries/0_stateless/02995_forget_partition.sh
Normal file → Executable file
15
tests/queries/0_stateless/02995_forget_partition.sql → tests/queries/0_stateless/02995_forget_partition.sh
Normal file → Executable file
@ -1,5 +1,12 @@
|
|||||||
-- Tags: zookeeper, no-replicated-database
|
#!/usr/bin/env bash
|
||||||
|
# Tags: zookeeper, no-replicated-database
|
||||||
|
|
||||||
|
CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||||
|
# shellcheck source=../shell_config.sh
|
||||||
|
. "$CUR_DIR"/../shell_config.sh
|
||||||
|
|
||||||
|
|
||||||
|
${CLICKHOUSE_CLIENT} --multiline --multiquery -q """
|
||||||
drop table if exists forget_partition;
|
drop table if exists forget_partition;
|
||||||
|
|
||||||
create table forget_partition
|
create table forget_partition
|
||||||
@ -16,7 +23,12 @@ insert into forget_partition select number, '2024-01-01' + interval number day,
|
|||||||
|
|
||||||
alter table forget_partition drop partition '20240101';
|
alter table forget_partition drop partition '20240101';
|
||||||
alter table forget_partition drop partition '20240102';
|
alter table forget_partition drop partition '20240102';
|
||||||
|
"""
|
||||||
|
|
||||||
|
# DROP PARTITION do not wait for a part to be removed from memory due to possible concurrent SELECTs, so we have to do wait manually here
|
||||||
|
while [[ $(${CLICKHOUSE_CLIENT} -q "select count() from system.parts where database=currentDatabase() and table='forget_partition' and partition='20240101'") != 0 ]]; do sleep 0.1; done
|
||||||
|
|
||||||
|
${CLICKHOUSE_CLIENT} --multiline --multiquery -q """
|
||||||
set allow_unrestricted_reads_from_keeper=1;
|
set allow_unrestricted_reads_from_keeper=1;
|
||||||
|
|
||||||
select '---before---';
|
select '---before---';
|
||||||
@ -31,3 +43,4 @@ select '---after---';
|
|||||||
select name from system.zookeeper where path = '/test/02995/' || currentDatabase() || '/rmt/block_numbers' order by name;
|
select name from system.zookeeper where path = '/test/02995/' || currentDatabase() || '/rmt/block_numbers' order by name;
|
||||||
|
|
||||||
drop table forget_partition;
|
drop table forget_partition;
|
||||||
|
"""
|
Loading…
Reference in New Issue
Block a user