Merge remote-tracking branch 'upstream/master' into cache-better-locks

This commit is contained in:
kssenii 2023-04-22 17:17:19 +02:00
commit 6054fc4c99
6 changed files with 35 additions and 7 deletions

View File

@ -158,8 +158,9 @@ public:
Int64 ms = 0;
memcpy(reinterpret_cast<UInt8 *>(&ms) + 2, buffer, 6);
if constexpr (std::endian::native == std::endian::little)
std::reverse(reinterpret_cast<UInt8 *>(&ms), reinterpret_cast<UInt8 *>(&ms) + sizeof(Int64));
# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
ms = std::byteswap(ms);
# endif
return DecimalUtils::decimalFromComponents<DateTime64>(ms / intExp10(DATETIME_SCALE), ms % intExp10(DATETIME_SCALE), DATETIME_SCALE);
}

View File

@ -771,7 +771,7 @@ public:
configuration_.request_settings,
std::nullopt,
DBMS_DEFAULT_BUFFER_SIZE,
threadPoolCallbackRunner<void>(IOThreadPool::get(), "S3ParallelRead"),
threadPoolCallbackRunner<void>(IOThreadPool::get(), "S3ParallelWrite"),
context->getWriteSettings()),
compression_method,
3);

View File

@ -8,6 +8,7 @@
#include <Parsers/ASTIdentifier.h>
#include <Parsers/ASTSelectWithUnionQuery.h>
#include <Parsers/ASTSetQuery.h>
#include <Parsers/ASTSubquery.h>
#include <Parsers/parseQuery.h>
#include <Storages/checkAndGetLiteralArgument.h>
#include <Storages/StorageExecutable.h>
@ -25,7 +26,8 @@ namespace ErrorCodes
{
extern const int LOGICAL_ERROR;
extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH;
extern const int UNSUPPORTED_METHOD;
extern const int BAD_ARGUMENTS;
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
}
std::vector<size_t> TableFunctionExecutable::skipAnalysisForArguments(const QueryTreeNodePtr & query_node_table_function, ContextPtr) const
@ -61,6 +63,21 @@ void TableFunctionExecutable::parseArguments(const ASTPtr & ast_function, Contex
"Table function '{}' requires minimum 3 arguments: script_name, format, structure, [input_query...]",
getName());
auto check_argument = [&](size_t i, const std::string & argument_name)
{
if (!args[i]->as<ASTIdentifier>() &&
!args[i]->as<ASTLiteral>() &&
!args[i]->as<ASTQueryParameter>() &&
!args[i]->as<ASTSubquery>())
throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
"Illegal type of argument '{}' for table function '{}': must be an identifier or string literal",
argument_name, getName());
};
check_argument(0, "script_name");
check_argument(1, "format");
check_argument(2, "structure");
for (size_t i = 0; i <= 2; ++i)
args[i] = evaluateConstantExpressionOrIdentifierAsLiteral(args[i], context);
@ -83,15 +100,18 @@ void TableFunctionExecutable::parseArguments(const ASTPtr & ast_function, Contex
}
else
{
ASTPtr query = args[i]->children.at(0);
if (query->as<ASTSelectWithUnionQuery>())
ASTPtr query;
if (!args[i]->children.empty())
query = args[i]->children.at(0);
if (query && query->as<ASTSelectWithUnionQuery>())
{
input_queries.emplace_back(std::move(query));
}
else
{
throw Exception(
ErrorCodes::UNSUPPORTED_METHOD,
ErrorCodes::BAD_ARGUMENTS,
"Table function '{}' argument is invalid {}",
getName(),
args[i]->formatForErrorMessage());

View File

@ -180,6 +180,8 @@ def check_pr_description(pr_info: PRInfo) -> Tuple[str, str]:
entry = " ".join(entry_lines)
# Don't accept changelog entries like '...'.
entry = re.sub(r"[#>*_.\- ]", "", entry)
# Don't accept changelog entries like 'Close #12345'.
entry = re.sub(r"^[\w\-\s]{0,10}#?\d{5,6}\.?$", "", entry)
else:
i += 1

View File

@ -6,3 +6,4 @@ FROM executable(\'\', \'JSON\', \'data String\', SETTINGS max_command_execution_
--------------------
SELECT data
FROM executable(\'\', \'JSON\', \'data String\', SETTINGS max_command_execution_time = 100, command_read_timeout = 1)
--------------------

View File

@ -3,3 +3,7 @@ SELECT '--------------------';
EXPLAIN SYNTAX SELECT * from executable('', 'JSON', 'data String', SETTINGS max_command_execution_time=100);
SELECT '--------------------';
EXPLAIN SYNTAX SELECT * from executable('', 'JSON', 'data String', SETTINGS max_command_execution_time=100, command_read_timeout=1);
SELECT '--------------------';
SELECT * from executable('JSON', 'data String', SETTINGS max_command_execution_time=100); -- { serverError ILLEGAL_TYPE_OF_ARGUMENT }
SELECT * from executable('JSON', 'data String', 'TEST', 'TEST'); -- { serverError BAD_ARGUMENTS }