如何在 Databricks SQL 中创建和使用地图

问题描述 投票:0回答:1

我想创建一个地图并在同一个 SQL 查询中使用它。我正在尝试类似的东西

select sample_map[t1.col1], t1.col2 from table1 as t1, (select map(1,2,3,4)) as sample_map group by t1.col2;
apache-spark-sql databricks databricks-sql
1个回答
0
投票

检查以下

sql
查询。

SELECT 
    m.s_map[t1.col1] AS m_col1,
    t1.col2 AS col2
FROM table1 t1,
(SELECT map(1,2,3,4) as s_map) as m
GROUP BY col2, m_col1
© www.soinside.com 2019 - 2024. All rights reserved.