Skip to content

Commit

Permalink
Read decimal column (#406)
Browse files Browse the repository at this point in the history
Reading a parquet file with a decimal column isn't loaded with logical
type information. This behavior was not implemented. `decimalType` is
more complex from the other types because a parquet decimal can be
backed by multiple different physical types.

This PR loads logical type information for `DECIMAL` fields.

Closes #365
  • Loading branch information
Larry Marburger authored Nov 14, 2022
1 parent 6c2e5f4 commit 629a510
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions column.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,27 @@ func schemaElementTypeOf(s *format.SchemaElement) Type {
case lt.Enum != nil:
return (*enumType)(lt.Enum)
case lt.Decimal != nil:
// TODO:
// return (*decimalType)(lt.Decimal)
// A parquet decimal can be one of several different physical types.
if t := s.Type; t != nil {
var typ Type
switch kind := Kind(*s.Type); kind {
case Int32:
typ = Int32Type
case Int64:
typ = Int64Type
case FixedLenByteArray:
if s.TypeLength == nil {
panic("DECIMAL using FIXED_LEN_BYTE_ARRAY must specify a length")
}
typ = FixedLenByteArrayType(int(*s.TypeLength))
default:
panic("DECIMAL must be of type INT32, INT64, or FIXED_LEN_BYTE_ARRAY but got " + kind.String())
}
return &decimalType{
decimal: *lt.Decimal,
Type: typ,
}
}
case lt.Date != nil:
return (*dateType)(lt.Date)
case lt.Time != nil:
Expand Down

0 comments on commit 629a510

Please sign in to comment.