mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 07:31:57 +00:00
Add setting to enable/disable template deduction for Values
This commit is contained in:
parent
dd45f3c2bd
commit
a5f194cae9
@ -176,6 +176,7 @@ struct Settings : public SettingsCollection<Settings>
|
||||
M(SettingBool, input_format_null_as_default, false, "For CSV format initialize null fields with default values if data type of this field is not nullable") \
|
||||
\
|
||||
M(SettingBool, input_format_values_interpret_expressions, true, "For Values format: if field could not be parsed by streaming parser, run SQL parser and try to interpret it as SQL expression.") \
|
||||
M(SettingBool, input_format_values_deduce_templates_of_expressions, true, "For Values format: if field could not be parsed by streaming parser, run SQL parser, deduce template of the SQL expression, try to parse all rows using template and then interpret expression for all rows.") \
|
||||
\
|
||||
M(SettingBool, output_format_json_quote_64bit_integers, true, "Controls quoting of 64-bit integers in JSON output format.") \
|
||||
\
|
||||
|
@ -162,8 +162,8 @@ void ConstantExpressionTemplate::parseExpression(ReadBuffer & istr, const Format
|
||||
Field number = ast->as<ASTLiteral&>().value;
|
||||
|
||||
WhichDataType type_info(type);
|
||||
if ((number.getType() == Field::Types::UInt64 && type_info.isUInt64() )
|
||||
|| (number.getType() == Field::Types::Int64 && type_info.isInt64() )
|
||||
if ((number.getType() == Field::Types::UInt64 && type_info.isUInt64())
|
||||
|| (number.getType() == Field::Types::Int64 && type_info.isInt64())
|
||||
|| (number.getType() == Field::Types::Float64 && type_info.isFloat64()))
|
||||
{
|
||||
columns[cur_column]->insert(number);
|
||||
|
@ -41,6 +41,7 @@ static FormatSettings getInputFormatSetting(const Settings & settings)
|
||||
format_settings.csv.empty_as_default = settings.input_format_defaults_for_omitted_fields;
|
||||
format_settings.csv.null_as_default = settings.input_format_null_as_default;
|
||||
format_settings.values.interpret_expressions = settings.input_format_values_interpret_expressions;
|
||||
format_settings.values.deduce_templates_of_expressions = settings.input_format_values_deduce_templates_of_expressions;
|
||||
format_settings.with_names_use_header = settings.input_format_with_names_use_header;
|
||||
format_settings.skip_unknown_fields = settings.input_format_skip_unknown_fields;
|
||||
format_settings.import_nested_json = settings.input_format_import_nested_json;
|
||||
|
@ -46,6 +46,7 @@ struct FormatSettings
|
||||
struct Values
|
||||
{
|
||||
bool interpret_expressions = true;
|
||||
bool deduce_templates_of_expressions = true;
|
||||
};
|
||||
|
||||
Values values;
|
||||
|
@ -136,7 +136,7 @@ void ValuesBlockInputStream::readValue(IColumn & column, size_t column_idx, bool
|
||||
}
|
||||
catch (const Exception & e)
|
||||
{
|
||||
if (!format_settings.values.interpret_expressions)
|
||||
if (!format_settings.values.interpret_expressions && !(format_settings.values.deduce_templates_of_expressions && generate_template))
|
||||
throw;
|
||||
|
||||
/** The normal streaming parser could not parse the value.
|
||||
@ -197,7 +197,7 @@ ValuesBlockInputStream::parseExpression(IColumn & column, size_t column_idx, boo
|
||||
|
||||
istr.position() = const_cast<char *>(token_iterator->begin);
|
||||
|
||||
if (generate_template)
|
||||
if (format_settings.values.deduce_templates_of_expressions && generate_template)
|
||||
{
|
||||
if (templates[column_idx])
|
||||
throw DB::Exception("Template for column " + std::to_string(column_idx) + " already exists and it was not evaluated yet",
|
||||
@ -212,6 +212,8 @@ ValuesBlockInputStream::parseExpression(IColumn & column, size_t column_idx, boo
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
if (!format_settings.values.interpret_expressions)
|
||||
throw;
|
||||
/// Continue parsing without template
|
||||
templates[column_idx].reset();
|
||||
istr.position() = const_cast<char *>(token_iterator->begin);
|
||||
|
Loading…
Reference in New Issue
Block a user