Skip to content

Commit e7c0573

Browse files
committed
attempt to fix
1 parent a53ebd7 commit e7c0573

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

src/Processors/Formats/Impl/Parquet/Decoding.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,6 +1096,8 @@ void IntConverter::convertField(std::span<const char> data, bool /*is_max*/, Fie
10961096
UInt64 val = 0;
10971097
switch (input_size)
10981098
{
1099+
case 1: val = unalignedLoad<UInt8>(data.data()); break;
1100+
case 2: val = unalignedLoad<UInt16>(data.data()); break;
10991101
case 4: val = unalignedLoad<UInt32>(data.data()); break;
11001102
case 8: val = unalignedLoad<UInt64>(data.data()); break;
11011103
default: chassert(false);

src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergWrites.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ bool canDumpIcebergStats(const Field & field, DataTypePtr type)
116116
case TypeIndex::Int64:
117117
case TypeIndex::DateTime64:
118118
case TypeIndex::String:
119+
case TypeIndex::UInt8: /// Boolean
119120
return true;
120121
default:
121122
return false;
@@ -156,6 +157,14 @@ std::vector<uint8_t> dumpFieldToBytes(const Field & field, DataTypePtr type)
156157
return dumpValue(field.safeGet<Float64>());
157158
case TypeIndex::Float32:
158159
return dumpValue(field.safeGet<Float32>());
160+
case TypeIndex::UInt8: /// Boolean - stored as single byte in Iceberg
161+
{
162+
/// Field can be Bool or UInt64 type depending on source
163+
UInt8 value = (field.getType() == Field::Types::Bool)
164+
? static_cast<UInt8>(field.safeGet<bool>())
165+
: static_cast<UInt8>(field.safeGet<UInt64>());
166+
return dumpValue(value);
167+
}
159168
default:
160169
{
161170
throw Exception(ErrorCodes::LOGICAL_ERROR, "Can not dump such stats");

src/Storages/ObjectStorage/DataLakes/Iceberg/ManifestFile.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,20 @@ namespace
116116
return std::nullopt;
117117
}
118118
}
119+
else if (DB::isBool(non_nullable_type))
120+
{
121+
/// Boolean type needs special handling:
122+
/// When UInt8 is extracted from column to Field, it becomes Field(Types::UInt64).
123+
/// But query conditions like WHERE bool_col = true create Field(Types::Bool).
124+
/// While accurateLess/accurateEquals handle type differences correctly,
125+
/// we create a Bool-typed Field for consistency.
126+
if (str.empty())
127+
return std::nullopt;
128+
return static_cast<bool>(static_cast<unsigned char>(str[0]) != 0);
129+
}
119130
else
120131
{
121-
/// For all other types except decimal binary representation
132+
/// For all other types except decimal and boolean, binary representation
122133
/// matches our internal representation
123134
column->insertData(str.data(), str.length());
124135
DB::Field result;

0 commit comments

Comments
 (0)