apache-spark - Pyspark 错误:“未定义函数:'from_timestamp'
问题描述
我正在尝试使用 spark.sql 从配置单元视图中获取 pyspark 中的一些数据,但每次它都会抛出以下错误:
pyspark.sql.utils.AnalysisException: u"Undefined function: 'from_timestamp'. This function is neither a registered temporary function nor a permanent function registered in the database 'default'.;
我在 SparkSession.builder 上的设置如下:
spark = SparkSession.builder.appName("home_office") \
.config("hive.exec.dynamic.partition", "true") \
.config("hive.exec.dynamic.partition.mode", "nonstrict") \
.config("hive.exec.compress.output=false", "false") \
.config("spark.unsafe.sorter.spill.read.ahead.enabled", "false") \
.config("spark.debug.maxToStringFields", 1000)\
.enableHiveSupport() \
.getOrCreate()
解决方案
Spark SQL中没有这样的功能from_timestamp
。如果您指的是 Impala 中的函数,我相信 Spark SQL 中的等价物是date_format
.
示例用法:
select date_format(current_timestamp(), 'dd/MM/yyyy hh:mm:ss a');
07/01/2021 08:37:11 AM
推荐阅读
- python - 无法从放置在 Google Drive 上并使用 google colab 的文件中解压缩和读取数据
- python - 由于 Apache Superset 中的 JSON 解码错误,无法加载仪表板列表
- mongodb - Mongoose 错误:传入的参数必须是 12 个字节的单个字符串或 24 个十六进制字符的字符串
- r - 在 Databricks 中使用 sparklyr 收集表
- python - Pip ValueError:源代码字符串不能包含空字节
- javascript - 如何保持多个状态页面刷新期间页面上的元素?
- javascript - 根据条件设置折线图标记颜色
- android - 由于某些设备显示不同的应用程序徽标,如何管理应用程序徽标
- angular - 将 FormArray 重置为初始状态
- c++ - 一致性影响并发算法?