dremio map 数据查询

官方提供了具体的操作说明,可以很好的体验dremio 对于map 的使用,内容来自官方文档

数据生成

  • 使用pyarrow
import pyarrow as pa
import pyarrow.parquet as pq
 
description = ["Dictionary", "Dress", "Wagon"]
 
properties = [
    [("Cover", "Hardcover"), ("Publication Year", "2002"), ("Color", "Blue")],
    [("Size", "Medium"), ("Color", "Red")],
    [("Material", "Metal"), ("Color", "Red")],
]
 
assert len(description) == len(properties)
maparr = pa.array(properties, type=pa.map_(pa.string(), pa.string()))
table = pa.table([description, maparr], names=["description", "properties"])
pq.write_table(table, "products.parquet")
  • 查询效果

 

 

支持的操作

包含了size,map_keys, map_values, typeof 等,还是比较有用的,同时也支持基于属性key 的数据过滤

与struct 的区别

map 只能是基本类型,同时map 所有的值类型必须是一样的

说明

从测试来看map 的属性是不区分大小写的,同时注意目前是从23 版本才开始支持的,迁移的老版本需要进行元数据的刷新

参考资料

https://www.dremio.com/blog/introducing-map-data-type-in-dremio/

posted on 2022-10-27 18:48  荣锋亮  阅读(40)  评论(0编辑  收藏  举报

导航