Skip to content
All writing Part 02 of 09 · [object Object]
Engineering · 1 min read

Spark SQL Data Types: Primitives, Nested, and struct vs map

Spark SQL's everyday data types — string, long, double, decimal(20,0), binary, timestamp — plus the nested trio array, map, and struct, and how struct differs from map.

The set of Spark types you’ll actually run into in real projects:

string
integer
array
struct
long
boolean
double
map
binary
float
decimal(20,0)
timestamp
date

Common types

TypeSpark SQL nameDescription
stringSTRING / StringTypevariable-length Unicode text
integerINT / IntegerType4-byte signed integer
longBIGINT / LongType8-byte signed integer
booleanBOOLEAN / BooleanTypetrue / false
doubleDOUBLE / DoubleType8-byte IEEE 754 double-precision float
floatFLOAT / FloatType4-byte single-precision float
decimal(20,0)DECIMAL(20,0)20-digit exact number, 0 decimal places (i.e. an exact 20-digit integer) — good for financial/precise values
timestampTIMESTAMP / TimestampTypedate + time, microsecond precision, usually UTC
dateDATE / DateTypeyear-month-day only
binaryBINARY / BinaryTypevariable-length byte array (raw binary)

Nested types

TypeSpark SQL nameDescription
arrayARRAY<T>ordered list, all elements the same type T
mapMAP<K,V>key-value pairs; all keys share a type, all values share a type
structSTRUCT<...>a composite record with named fields, each field with its own type; each key-value pair can have its own type; more flexible than map (a subset)

References

Related: back to the Cross-Engine DB Query overview, or on to Spark array functions and collect.

Tags #spark #databases
// connect

Be brave | Be wise | Be grateful

21 BreakinCode

// elsewhere
LinkedInMedium (lang: en)Life RecordYoutube
wh:~$William Hung· © 2026 Taipei · GMT+8 · Available for collaboration