This commit is contained in:
avogar 2022-01-14 19:17:06 +03:00
parent 89a181bd19
commit 253035a5df
6 changed files with 10 additions and 9 deletions

View File

@ -402,7 +402,7 @@ void FormatFactory::registerAppendSupportChecker(const String & name, AppendSupp
void FormatFactory::markFormatDoesntSupportAppend(const String & name)
{
registerAppendSupportChecker(name, [](const FormatSettings &){ return true; });
registerAppendSupportChecker(name, [](const FormatSettings &){ return false; });
}
bool FormatFactory::checkIfFormatSupportAppend(const String & name, ContextPtr context, const std::optional<FormatSettings> & format_settings_)

View File

@ -479,6 +479,7 @@ void registerOutputFormatAvro(FormatFactory & factory)
{
return std::make_shared<AvroRowOutputFormat>(buf, sample, params, settings);
});
factory.markFormatDoesntSupportAppend("Avro");
}
}

View File

@ -94,7 +94,7 @@ void registerOutputFormatCustomSeparated(FormatFactory & factory)
factory.registerAppendSupportChecker(format_name, [](const FormatSettings & settings)
{
return !settings.custom.result_after_delimiter.empty();
return settings.custom.result_after_delimiter.empty();
});
};

View File

@ -239,7 +239,7 @@ void registerOutputFormatTemplate(FormatFactory & factory)
factory.registerAppendSupportChecker("Template", [](const FormatSettings & settings)
{
if (settings.template_settings.resultset_format.empty())
return false;
return true;
auto resultset_format = ParsedTemplateFormatString(
FormatSchemaInfo(settings.template_settings.resultset_format, "Template", false,
settings.schema.is_server, settings.schema.format_schema_path),
@ -247,7 +247,7 @@ void registerOutputFormatTemplate(FormatFactory & factory)
{
return static_cast<size_t>(TemplateBlockOutputFormat::stringToResultsetPart(partName));
});
return !resultset_format.delimiters.empty() && !resultset_format.delimiters.back().empty();
return resultset_format.delimiters.empty() || resultset_format.delimiters.back().empty();
});
}
}

View File

@ -852,8 +852,8 @@ SinkToStoragePtr StorageFile::write(
else
throw Exception(
ErrorCodes::CANNOT_APPEND_TO_FILE,
"Cannot append data in format {} to file, because this format contains suffix and "
"data can be written to a file only once. You can allow to create a new file "
"Cannot append data in format {} to file, because this format doesn't support appends."
" You can allow to create a new file "
"on each insert by enabling setting engine_file_allow_create_multiple_files",
format_name);
}

View File

@ -1,5 +1,5 @@
-- Tags: no-fasttest
insert into table function file('data.avro', 'Avro', 'x UInt64') select * from numbers(10);
insert into table function file('data.avro', 'Avro', 'x UInt64') select * from numbers(10);
insert into table function file('data.avro', 'Avro', 'x UInt64') select * from numbers(10);
insert into table function file('data.avro', 'Parquet', 'x UInt64') select * from numbers(10);
insert into table function file('data.avro', 'Parquet', 'x UInt64') select * from numbers(10); -- { serverError CANNOT_APPEND_TO_FILE }
insert into table function file('data.avro', 'Parquet', 'x UInt64') select * from numbers(10); -- { serverError CANNOT_APPEND_TO_FILE }
select 'OK';