全部產品
Search
文件中心

Tablestore:資料類型

更新時間:Jul 24, 2024

使用Spark計算引擎訪問Table Store時,您需要瞭解Spark資料類型、Scala中的實值型別、Table Store中多元索引資料類型和Table Store表中資料類型的對應關係。使用過程中請確保Spark、Scala和Table Store中欄位或值的資料類型相匹配。

基礎資料類型

基礎資料類型的支援情況請參見下表。

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在能查詢分析基礎類型資料的同時,也可以結合地理位置對資料進行查詢分析。

地理位置查詢包括地理距離查詢、地理矩形查詢和地理多邊形範圍查詢三種查詢方式。地理位置查詢廣泛應用於物聯網裝置位置資訊、騎手訂單、打卡位置資訊、快遞地理資訊等情境中。使用方式如下:

  • 使用Table Store的多元索引查詢,詳情請參見地理距離查詢

  • 使用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)