Merge pull request #55541 from ClickHouse/sample-segfault

Better exception messages but without SEGFAULT
This commit is contained in:
Antonio Andelic 2023-10-16 08:43:52 +02:00 committed by GitHub
commit b6b92f46cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 1 deletions

View File

@ -684,7 +684,15 @@ InterpreterSelectQuery::InterpreterSelectQuery(
if (!options.only_analyze)
{
if (query.sampleSize() && (input_pipe || !storage || !storage->supportsSampling()))
throw Exception(ErrorCodes::SAMPLING_NOT_SUPPORTED, "Illegal SAMPLE: table {} doesn't support sampling", storage->getStorageID().getNameForLogs());
{
if (storage)
throw Exception(
ErrorCodes::SAMPLING_NOT_SUPPORTED,
"Storage {} doesn't support sampling",
storage->getStorageID().getNameForLogs());
else
throw Exception(ErrorCodes::SAMPLING_NOT_SUPPORTED, "Illegal SAMPLE: sampling is only allowed with the table engines that support it");
}
if (query.final() && (input_pipe || !storage || !storage->supportsFinal()))
{

View File

@ -0,0 +1 @@
SELECT * FROM (SELECT 1) SAMPLE 1 / 2; -- { serverError SAMPLING_NOT_SUPPORTED, UNSUPPORTED_METHOD }