spark读取hive表字段,区分大小写问题

背景

spark任务读取hive表,查询字段为小写,但Hive表字段为大写,无法读取数据

问题错误:
如何解决呢?
  • In version 2.3 and earlier, when reading from a Parquet data source table, Spark always returns null for any column whose column names in Hive metastore schema and Parquet schema are in different letter cases, no matter whether spark.sql.caseSensitive is set to true or false. Since 2.4, when spark.sql.caseSensitive is set to false, Spark does case insensitive column name resolution between Hive metastore schema and Parquet schema, so even column names are in different letter cases, Spark returns corresponding column values. An exception is thrown if there is ambiguity, i.e. more than one Parquet column is matched. This change also applies to Parquet Hive tables when spark.sql.hive.convertMetastoreParquet is set to true.
sql 复制代码
# 在程序或者sql中添加这个参数即可
set spark.sql.caseSensitive = false

参考地址:

Migration Guide: SQL, Datasets and DataFrame - Spark 3.2.0 Documentation

相关推荐
晨启AI27 分钟前
GPT-5.5 来了!OpenAI 最新提示词指南深度解读
大数据·人工智能·ai·提示词
地球资源数据云44 分钟前
中国陆地生态系统主要植物功能特征空间分布数据
大数据·数据库·人工智能·机器学习
金智维科技官方1 小时前
AI智能体在7×24客服场景中的真实表现评估
大数据·人工智能·ai·rpa·智能体
WL_Aurora1 小时前
MapReduce经典例题【第二期】
大数据·mapreduce
二十六画生的博客1 小时前
每个subtask都提交一份快照到hdfs,会把10个小的快照合并成一个大的吗?谁来合并?
大数据·hadoop·hdfs·flink
摇滚侠1 小时前
数据同步 黑马 Elasticsearch 全套教程,黑马旅游网案例
大数据·elasticsearch·搜索引擎
juniperhan1 小时前
Flink 系列第24篇:Flink SQL 集成维度表指南:存储选型、参数调优与实战避坑
大数据·数据仓库·sql·flink
隐于花海,等待花开2 小时前
41.ABS / POW / SQRT 函数深度解析
大数据·hive
AI周红伟2 小时前
数字人,视频,图片用不过时
大数据·人工智能·搜索引擎·copilot·openclaw
light blue bird3 小时前
设备数据变化上传图表数据汇总组件
大数据·前端·信息可视化