PySpark 数据类型

本页提供 Databricks 上可用的 PySpark 数据类型列表,其中包含指向相应参考文档的链接。

数据类型 Description
ArrayType(elementType[, containsNull]) 数组数据类型
BinaryType() 二进制(字节数组)数据类型
BooleanType() Boolean 数据类型
ByteType() 字节数据类型,表示有符号 8 位整数
CalendarIntervalType() 日历间隔
CharType(length) Char 数据类型
DataType() 数据类型的基类
DateType() Date (datetime.date) 数据类型
DayTimeIntervalType([startField, endField]) DayTimeIntervalType (datetime.timedelta)
DecimalType([precision, scale]) 十进制 (decimal.Decimal) 数据类型
DoubleType() 双精度数据类型,表示双精度浮点数
FloatType() Float 数据类型,表示单精度浮点数
Geography (仅限 Databricks) geography 数据类型
Geometry (仅限 Databricks) geometry 数据类型
IntegerType() Int 数据类型,表示有符号 32 位整数
LongType() 长数据类型,表示有符号 64 位整数
MapType(keyType, valueType[, valueContainsNull]) 映射数据类型
NullType() Null 类型
ShortType() 短数据类型,表示有符号 16 位整数
StringType([collation]) 字符串数据类型
StructField(name, dataType[, nullable, metadata]) StructType 中的字段
StructType([fields]) 结构类型,由 StructField 列表组成
TimestampType() Timestamp (datetime.datetime) 数据类型
TimestampNTZType() 时间戳(datetime.datetime)数据类型,不带时区信息
VarcharType(length) Varchar 数据类型
VariantType() 变体数据类型,表示半结构化值
YearMonthIntervalType([startField, endField]) YearMonthIntervalType,表示 SQL 标准的年月间隔