Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Processors/Formats/Impl/Parquet/Decoding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1096,6 +1096,8 @@ void IntConverter::convertField(std::span<const char> data, bool /*is_max*/, Fie
UInt64 val = 0;
switch (input_size)
{
case 1: val = unalignedLoad<UInt8>(data.data()); break;
case 2: val = unalignedLoad<UInt16>(data.data()); break;
case 4: val = unalignedLoad<UInt32>(data.data()); break;
case 8: val = unalignedLoad<UInt64>(data.data()); break;
default: chassert(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ bool canDumpIcebergStats(const Field & field, DataTypePtr type)
case TypeIndex::Int64:
case TypeIndex::DateTime64:
case TypeIndex::String:
case TypeIndex::UInt8: /// Boolean
return true;
default:
return false;
Expand Down Expand Up @@ -156,6 +157,14 @@ std::vector<uint8_t> dumpFieldToBytes(const Field & field, DataTypePtr type)
return dumpValue(field.safeGet<Float64>());
case TypeIndex::Float32:
return dumpValue(field.safeGet<Float32>());
case TypeIndex::UInt8: /// Boolean - stored as single byte in Iceberg
{
/// Field can be Bool or UInt64 type depending on source
UInt8 value = (field.getType() == Field::Types::Bool)
? static_cast<UInt8>(field.safeGet<bool>())
: static_cast<UInt8>(field.safeGet<UInt64>());
return dumpValue(value);
}
default:
{
throw Exception(ErrorCodes::LOGICAL_ERROR, "Can not dump such stats");
Expand Down
13 changes: 12 additions & 1 deletion src/Storages/ObjectStorage/DataLakes/Iceberg/ManifestFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,20 @@ namespace
return std::nullopt;
}
}
else if (DB::isBool(non_nullable_type))
{
/// Boolean type needs special handling:
/// When UInt8 is extracted from column to Field, it becomes Field(Types::UInt64).
/// But query conditions like WHERE bool_col = true create Field(Types::Bool).
/// While accurateLess/accurateEquals handle type differences correctly,
/// we create a Bool-typed Field for consistency.
if (str.empty())
return std::nullopt;
return static_cast<bool>(static_cast<unsigned char>(str[0]) != 0);
}
else
{
/// For all other types except decimal binary representation
/// For all other types except decimal and boolean, binary representation
/// matches our internal representation
column->insertData(str.data(), str.length());
DB::Field result;
Expand Down
Loading