MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / parseRangeConfiguration

Method parseRangeConfiguration

src/Dictionaries/DictionaryStructure.cpp:385–436  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

383}
384
385void DictionaryStructure::parseRangeConfiguration(const Poco::Util::AbstractConfiguration & config, const std::string & structure_prefix)
386{
387 static constexpr auto range_default_type = "Date";
388
389 if (config.has(structure_prefix + ".range_min"))
390 range_min.emplace(makeDictionaryTypedSpecialAttribute(config, structure_prefix + ".range_min", range_default_type));
391
392 if (config.has(structure_prefix + ".range_max"))
393 range_max.emplace(makeDictionaryTypedSpecialAttribute(config, structure_prefix + ".range_max", range_default_type));
394
395 if (range_min.has_value() != range_max.has_value())
396 {
397 throw Exception(ErrorCodes::BAD_ARGUMENTS,
398 "Dictionary structure should have both 'range_min' and 'range_max' either specified or not.");
399 }
400
401 if (!range_min)
402 return;
403
404 auto range_min_type = removeNullable(range_min->type);
405 auto range_max_type = removeNullable(range_max->type);
406
407 if (!range_min_type->equals(*range_max_type))
408 {
409 throw Exception(ErrorCodes::BAD_ARGUMENTS,
410 "Dictionary structure 'range_min' and 'range_max' should have same type, "
411 "'range_min' type: {},"
412 "'range_max' type: {}",
413 range_min_type->getName(),
414 range_max_type->getName());
415 }
416
417 range_min.emplace(DictionaryTypedSpecialAttribute{range_min->name, range_min->expression, range_min_type});
418 range_max.emplace(DictionaryTypedSpecialAttribute{range_max->name, range_max->expression, range_max_type});
419
420 WhichDataType range_type(range_min->type);
421
422 bool valid_range = range_type.isInt() || range_type.isUInt() || range_type.isDecimal() || range_type.isFloat() || range_type.isEnum()
423 || range_type.isDate() || range_type.isDate32() || range_type.isDateTime() || range_type.isDateTime64();
424
425 if (!valid_range)
426 {
427 throw Exception(ErrorCodes::BAD_ARGUMENTS,
428 "Dictionary structure type of 'range_min' and 'range_max' should "
429 "be an Integer, Float, Decimal, Date, Date32, DateTime DateTime64, or Enum."
430 " Actual 'range_min' and 'range_max' type is {}",
431 range_min->type->getName());
432 }
433
434 if (!range_min->expression.empty() || !range_max->expression.empty())
435 has_expressions = true;
436}
437
438}

Callers

nothing calls this directly

Calls 15

isIntMethod · 0.80
isUIntMethod · 0.80
isFloatMethod · 0.80
isEnumMethod · 0.80
isDate32Method · 0.80
isDateTime64Method · 0.80
ExceptionClass · 0.50
removeNullableFunction · 0.50
hasMethod · 0.45
emplaceMethod · 0.45
equalsMethod · 0.45

Tested by

no test coverage detected