文档

数据类型

更新时间:

了解Spark数据类型、Scala中的值类型、表格存储中多元索引数据类型和表格存储表中数据类型的对应关系。使用过程中请确保Spark、Scala和表格存储中字段或值的数据类型相匹配。

基础数据类型

基础数据类型的支持情况请参见下表。

Spark数据类型

Scala中的值类型

多元索引数据类型

表中数据类型

ByteType

Byte

Long

Integer

ShortType

Short

Long

Integer

IntegerType

Int

Long

Integer

LongType

Long

Long

Integer

FloatType

Float

Double

Double

DoubleType

Double

Double

Double

StringType

String

Keyword/Text

String

BinaryType

Array[Byte]

Binary

Binary

BooleanType

Boolean

Boolean

Boolean

地理坐标(String JSON)

String(JSON)

Geopoint

String(JSON)

地理位置类型(Geopoint类型)

多元索引支持地理位置查询方式,将其提供到计算层,使Spark在能查询分析基础类型数据的同时,也可以结合地理位置对数据进行查询分析。

地理位置查询包括地理距离查询、地理矩形查询和地理多边形范围查询三种查询方式。地理位置查询广泛应用于物联网设备位置信息、骑手订单、打卡位置信息、快递地理信息等场景中。使用方式如下:

  • 使用表格存储的多元索引查询,详情请参见地理距离查询

  • 使用Spark SQL方式查询。

    • 地理半径圆查询

      select * from table where  val_geo = '{"centerPoint":"3,0", "distanceInMeter": 100000}' and name like 'ali%'
    • 地理矩形查询

      select * from table where geo = '{"topLeft":"8,0", "bottomRight": "0,10"}' and id in { 123 , 321 }
    • 地理多边形查询

      select * from table where geo = '{"points":["5,0", "5,1", "6,1", "6,10"]}'

地理位置数据类型的支持情况请参见下表。

Spark数据类型

Scala中的值类型

多元索引数据类型

表中数据类型

地理坐标(String JSON)半径圆

String(JSON)

Geopoint

STRING(JSON)

地理坐标(String JSON)矩形

String(JSON)

Geopoint

STRING(JSON)

地理坐标(String JSON)多边形

String(JSON)

Geopoint

STRING(JSON)

  • 本页导读 (1)
文档反馈