hive - 在 DataFrame 中不能有调用集合操作的地图类型列
问题描述
:org.apache.spark.sql.AnalysisException:不能在调用集合操作(相交,除外等)的DataFrame中有地图类型列,但列map_col的类型是地图
我有一个带有类型列的配置单元表 - MAP<Float, Float>
。当我尝试在 spark 上下文中对该表进行插入时,出现上述错误。没有'distinct',插入工作正常。
create table test_insert2(`test_col` string, `map_col` MAP<INT,INT>)
location 's3://mybucket/test_insert2';
insert into test_insert2
select distinct 'a' as test_col, map(0,0) as map_col
解决方案
尝试将数据框转换为.rdd
然后应用.distinct
函数。
例子:
spark.sql("select 'a'test_col,map(0,0)map_col
union all
select 'a'test_col,map(0,0)map_col").rdd.distinct.collect
结果:
Array[org.apache.spark.sql.Row] = Array([a,Map(0 -> 0)])
推荐阅读
- ios - react-native-ios xcode Capabilities for Signing & Capabilities 可能无法正常运行,因为它的权利使用占位符团队 ID
- python-2.7 - PYQT5 连接两个 QSpinBox
- java - 在 Java 中获取接口的类型
- python - 构建我的 Python 包以便导入语句正常工作
- python - 如何将元组中的所有值添加到字典中?
- react-navigation - 在 React Navigation 中使用 iOS 13 样式的模式时如何修改“深”背景?
- laravel - 同步不同数据库表的最佳方法
- c - 在文件范围内进行可变修改
- javascript - 为 Angular 包扩展缓存 TTL
- firebase - Nuxt generate 和 firebase 给出计时器警告