Logical type
| Also known as | Type annotation; LogicalType (Parquet); primitive type (Iceberg) |
|---|---|
| Field | Data storage formats |
| Key parts | Physical type, logical type annotation, ConvertedType (deprecated) |
| Open source implementations | Apache Parquet, Apache Arrow, Apache Iceberg, Apache Spark |
| Related | Open table format, Variant type, Apache ORC |
A logical type is an annotation that tells a reader how to interpret a stored value, layered on top of a small set of physical (storage) types. In Apache Parquet, for example, a string is stored with the physical type BYTE_ARRAY and the logical type STRING, and a date is an INT32 with the logical type DATE.[1] Logical types keep the set of storage types small while letting files carry richer types such as decimals, timestamps and UUIDs. Because each engine and table format has its own type system, the mapping between logical types is where data written by one tool can be read differently by another.
Physical types and logical types
The Apache Parquet format defines a deliberately minimal set of physical types: BOOLEAN, INT32, INT64, INT96, FLOAT, DOUBLE, BYTE_ARRAY and FIXED_LEN_BYTE_ARRAY. The README explains that 16-bit integers, for example, are not stored separately because 32-bit integers with an efficient encoding cover them.[2]
A Parquet logical type is stored in the file metadata as a LogicalType field on the column. Some logical types take parameters. DECIMAL has a precision and a scale and can annotate INT32 (precision up to 9), INT64 (precision up to 18), FIXED_LEN_BYTE_ARRAY or BYTE_ARRAY. UUID annotates a 16-byte fixed-length array in big-endian order. DATE annotates an INT32 that counts days from 1 January 1970.[1]
If a reader finds a logical type it does not recognize, the specification tells it to ignore the annotation and the column order and read the column using only its physical type.[1] A newer annotation therefore degrades to raw integers or bytes in an older reader instead of failing.
Timestamps
The Parquet TIMESTAMP logical type annotates an INT64 and has two parameters. unit is MILLIS, MICROS or NANOS. isAdjustedToUTC selects the semantics: when true, the value is an instant normalized to UTC; when false, the value is a local date and time that does not refer to one point on the time-line.[1] With the NANOS unit, the range of an INT64 limits values to the years 1677 to 2262.[1]
ConvertedType
ConvertedType is the older representation of the same annotations. It is a Thrift enum, so it cannot carry parameters such as the timestamp unit and UTC flag; LogicalType, a union of structs, replaced it. The specification marks ConvertedType as deprecated, but writers must still write the matching ConvertedType next to the LogicalType so that old readers work, and readers should fall back to it when no LogicalType is present.[1] For example, STRING corresponds to the UTF8 converted type, and a microsecond UTC timestamp corresponds to TIMESTAMP_MICROS. Writers must also annotate local (non-UTC) timestamps with the legacy TIMESTAMP_MILLIS or TIMESTAMP_MICROS annotations, because some older libraries used those for local timestamps.[1]
INT96 timestamps
INT96 is a physical type with no logical type. The Parquet Thrift definition marks it as deprecated and says new writers should not write data in it.[3] The same file notes that, at the time of writing, it was still used for legacy timestamps, and parquet-format 2.14.0 added a chronological sort order for INT96 statistics.[3][4] Apache Spark reads INT96 as a timestamp by default (spark.sql.parquet.int96AsTimestamp=true), for compatibility with systems such as Impala that store timestamps this way.[5]
How other systems map onto Parquet
Engines and table formats define their own types and choose a Parquet representation for each.
- Apache Iceberg calls its types primitive types and defines them in the table spec, for example
timestamp(microseconds, without time zone),timestamptz(microseconds, stored as UTC), and from format version 3timestamp_nsandtimestamptz_ns. Appendix A of the spec fixes the Parquet physical type and logical type for each one.[6] - Apache Arrow has a
Timestamptype with a unit (seconds to nanoseconds) and an optional time zone string. A timestamp with a non-empty time zone is a point in time relative to the UTC epoch; one with no time zone is a wall-clock value in an unknown zone, and the Arrow format states that an empty time zone must not be read as UTC.[7] The Arrow C++ Parquet library documents which Arrow type each Parquet logical type maps to, and recognizes and writes deprecated converted types for compatibility.[8] - Spark SQL has
TimestampType(timestamp with local time zone,TIMESTAMP_LTZ) andTimestampNTZType(without time zone). The SQL keywordTIMESTAMPis an alias for one of them, set byspark.sql.timestampType, whose default isTIMESTAMP_LTZ.[9]
Mapping of common types
The table shows how each system represents common types in Parquet, or (for Arrow) which Arrow type a Parquet logical type is read as.
| Meaning | Parquet physical type and logical type | Apache Arrow type | Apache Iceberg type | Spark SQL type written to Parquet |
|---|---|---|---|---|
| UTF-8 string | BYTE_ARRAY + STRING (converted type UTF8)[1] |
String, LargeString or StringView[8] | string, stored as binary + UTF8[6] |
StringType, stored as BINARY + string annotation[10]
|
| Decimal | DECIMAL(P,S) on INT32, INT64, FIXED_LEN_BYTE_ARRAY or BYTE_ARRAY[1] |
Decimal32, Decimal64, Decimal128 or Decimal256[8] | decimal(P,S), P at most 38; int32 if P is at most 9, int64 if at most 18, else fixed[6] |
DecimalType: INT32, INT64 or fixed-length array by precision, unless spark.sql.parquet.writeLegacyFormat (default false) is set[10][5]
|
| Date | INT32 + DATE[1] |
Date32[8] | date[6] |
DateType, INT32 + DATE[10]
|
| Instant (UTC-normalized timestamp) | INT64 + TIMESTAMP(isAdjustedToUTC=true, unit)[1] |
Timestamp with a non-empty time zone[7] | timestamptz, microseconds, adjustToUtc=true[6] |
TimestampType: INT96 by default; TIMESTAMP_MICROS or TIMESTAMP_MILLIS if spark.sql.parquet.outputTimestampType is set[11][10]
|
| Local date-time (no time zone) | INT64 + TIMESTAMP(isAdjustedToUTC=false, unit)[1] |
Timestamp with no time zone[7] | timestamp, microseconds, adjustToUtc=false[6] |
TimestampNTZType, INT64 + TIMESTAMP(false, MICROS)[10]
|
| Nanosecond timestamp | TIMESTAMP with unit NANOS[1] |
Timestamp with nanosecond unit[8] | timestamp_ns and timestamptz_ns, format version 3 only[6] |
Preview types TIMESTAMP_NTZ(p) and TIMESTAMP_LTZ(p), enabled by spark.sql.timestampNanosTypes.enabled (default false)[9][5]
|
| UUID | FIXED_LEN_BYTE_ARRAY(16) + UUID[1] |
Extension type arrow.uuid, when Arrow extensions are enabled in the reader[8] |
uuid, fixed_len_byte_array[16] + UUID[6] |
Not among the Spark SQL data types[9] |
Interoperability pitfalls
The same word, "timestamp", means different things in different systems. Iceberg timestamp and Spark TimestampNTZType are local date-times, while Spark TimestampType and Iceberg timestamptz are instants.[6][9] A tool that maps one to the other without checking isAdjustedToUTC can shift values by the session time zone.
Spark 4.3.0 still writes TimestampType as INT96 by default. Its source code calls TIMESTAMP_MICROS the recommended setting and keeps INT96 as the default to preserve earlier behaviour.[10] INT96 is deprecated in Parquet and carries no logical type annotation, so a reader has to know the legacy convention to treat it as a timestamp; the Iceberg spec's Parquet mapping does not use INT96 for any type.[3][6] Setting the output type to a standard logical type avoids this:
-- Spark SQL: write TimestampType columns as INT64 + TIMESTAMP(isAdjustedToUTC=true, MICROS)
SET spark.sql.parquet.outputTimestampType = TIMESTAMP_MICROS;
Parquet itself does not store a time zone. The Arrow C++ writer can store the serialized Arrow schema in the file metadata (store_schema) so that an Arrow reader can restore the original time zone string.[8] Spark, in the same way, writes its own schema into the Parquet footer and uses it on read, so spark.sql.parquet.inferTimestampNTZ.enabled only affects files not written by Spark.[5]
See also
References
- ↑ 1.00 1.01 1.02 1.03 1.04 1.05 1.06 1.07 1.08 1.09 1.10 1.11 1.12 1.13 Parquet Logical Type Definitions (LogicalTypes.md, parquet-format 2.14.0). Apache Software Foundation.Retrieved 2026-11-22.
- ↑ parquet-format README (2.14.0). Apache Software Foundation.Retrieved 2026-11-22.
- ↑ 3.0 3.1 3.2 parquet.thrift (parquet-format 2.14.0). Apache Software Foundation.Retrieved 2026-11-22.
- ↑ 2.14.0. Apache Software Foundation, 2026-09-11.Retrieved 2026-11-22.
- ↑ 5.0 5.1 5.2 5.3 SQLConf.scala (Apache Spark v4.3.0). Apache Software Foundation.Retrieved 2026-11-22.
- ↑ 6.00 6.01 6.02 6.03 6.04 6.05 6.06 6.07 6.08 6.09 Iceberg Table Spec (format/spec.md at apache-iceberg-1.12.0). Apache Software Foundation.Retrieved 2026-11-22.
- ↑ 7.0 7.1 7.2 Schema.fbs (Apache Arrow 26.0.1). Apache Software Foundation.Retrieved 2026-11-22.
- ↑ 8.0 8.1 8.2 8.3 8.4 8.5 8.6 Reading and writing Parquet files (Apache Arrow C++ documentation, v26.0.1). Apache Software Foundation.Retrieved 2026-11-22.
- ↑ 9.0 9.1 9.2 9.3 Data Types (Spark 4.3.0 documentation). Apache Software Foundation.Retrieved 2026-11-22.
- ↑ 10.0 10.1 10.2 10.3 10.4 10.5 ParquetSchemaConverter.scala (Apache Spark v4.3.0). Apache Software Foundation.Retrieved 2026-11-22.
- ↑ Parquet Files (Spark 4.3.0 documentation). Apache Software Foundation.Retrieved 2026-11-22.