use tryConvertFieldToType in getHyperrectangleForRowGroup

This commit is contained in:
Michael Stetsyuk 2024-09-19 10:22:00 +00:00
parent 52dc9a54a7
commit 9ce8bf0b1e
3 changed files with 14 additions and 2 deletions

View File

@ -572,6 +572,16 @@ Field convertFieldToTypeImpl(const Field & src, const IDataType & type, const ID
}
Field tryConvertFieldToType(const Field & from_value, const IDataType & to_type, const IDataType * from_type_hint, const FormatSettings & format_settings)
{
try
{
return convertFieldToType(from_value, to_type, from_type_hint, format_settings);
} catch (...)
{
return {};
}
}
Field convertFieldToType(const Field & from_value, const IDataType & to_type, const IDataType * from_type_hint, const FormatSettings & format_settings)
{

View File

@ -18,6 +18,8 @@ class IDataType;
*/
Field convertFieldToType(const Field & from_value, const IDataType & to_type, const IDataType * from_type_hint = nullptr, const FormatSettings & format_settings = {});
Field tryConvertFieldToType(const Field & from_value, const IDataType & to_type, const IDataType * from_type_hint = nullptr, const FormatSettings & format_settings = {});
/// Does the same, but throws ARGUMENT_OUT_OF_BOUND if value does not fall into the range.
Field convertFieldToTypeOrThrow(const Field & from_value, const IDataType & to_type, const IDataType * from_type_hint = nullptr, const FormatSettings & format_settings = {});

View File

@ -344,8 +344,8 @@ static std::vector<Range> getHyperrectangleForRowGroup(const parquet::FileMetaDa
/// Allow conversion in some simple cases, otherwise ignore the min/max values.
auto min_type = min.getType();
auto max_type = max.getType();
min = convertFieldToType(min, *type);
max = convertFieldToType(max, *type);
min = tryConvertFieldToType(min, *type);
max = tryConvertFieldToType(max, *type);
auto ok_cast = [&](Field::Types::Which from, Field::Types::Which to) -> bool
{
if (from == to)