parquet_get_column_type Interface

interface
public module subroutine parquet_get_column_type(reader, name, type_name)

Arguments

Type IntentOptional Attributes Name
type(parquet_reader), intent(in) :: reader

open reader.

character(len=*), intent(in) :: name

existing column name (dotted struct-leaf path allowed).

character(len=:), intent(out), allocatable :: type_name

resolved canonical type token.

Description

Returns the Fortran type existing column name is READ INTO, in type_name: one of valid_query_data_types's nine tokens ("int32"/"int64"/"float32"/"float64"/"string"/ "boolean"/"date"/"time"/"timestamp"), or "unknown" for a column this library cannot read at all. A vector (FIXED_SIZE_LIST) column reports its element type, e.g. an int32 vector column reports "int32" (see parquet_get_col_size for its element count).

The question it answers is "what do I declare?", so the answer is the narrowest lossless Fortran kind for the column's physical type, not the physical type's own name -- all four numeric targets accept the same 15 physical types, so which one a read actually uses is chosen by the caller's declaration rather than by the file:

  • int8, int16, int32, uint8, uint16 -> "int32"
  • int64, uint32 -> "int64"
  • uint64 -> "int64", lossy: no Fortran kind covers its range, and a value above huge(int64) aborts on read
  • half_float, float -> "float32"; double -> "double" is "float64"
  • decimal32/64/128/256 -> "float64", lossy, mapped on the type ID alone: no precision/scale awareness, so decimal(9,0) answers "float64" like every other decimal
  • bool -> "boolean"; string/large_string -> "string"
  • date32/date64 -> "date"; time32/time64 -> "time"; timestamp -> "timestamp"
  • anything else -> "unknown"

The two lossy rows return the conventional target rather than "unknown" on purpose: a caller asking what to declare is better served by the kind the library will actually use than by being told a readable column is unreadable.

error stops only if name doesn't exist -- that is a caller mistake, and parquet_column_exists is the query for it. An unreadable type is an answer ("unknown"), not an error.