apache-spark - Spark错误地将整数转换为`struct`
问题描述
在火花工作中,我正在使用
.withColumn("year", year(to_timestamp(lit(col("timestamp")))))
该代码曾经有效。但现在我得到了错误:
"cannot resolve 'CAST(`timestamp` AS TIMESTAMP)' due to data type mismatch: cannot cast struct<int:int,long:bigint> to timestamp;"
我看起来像 spark 正在将我的时间戳列读取为 astruct<int:int,long:bigint>
而不是 aint
我怎样才能防止这种情况?
上下文初始数据在 jsonline 中。我使用 AWS GLUE 阅读它glueContext.create_dynamic_frame.from_catalog
。在 GLUE 目录中,时间戳列是键入的int
。
解决方案
最后我以这种方式解决了它:
GF_resolved = ResolveChoice.apply(
frame=GF_raw,
specs=[("timestamp", "cast:int")],
transformation_ctx="resolve timestamp type",
)
ResolveChoice 是 AWS Glue DynamicFrame 上可用的方法
推荐阅读
- sql - Oracle RPD Ago 函数 SQL 等效
- c - 用 C 中的 fgets() 和 strtok() 计算句子中每个单词的字母数
- ruby-on-rails - Spree API 3.7:图像作为单独的对象出现,而不是嵌入产品本身
- python - Python 中的网页抓取(beautifulsoup)
- google-app-engine - Google Cloud appengine - 编辑 appengine-web.xml 以将免费层级应用保留在免费层级中
- python-3.x - Pandas:如何将复杂的数据框转换为更简单的数据框
- c# - 如何在 C# 中使图表实时并连接到 dtgrid 上的数据
- java - 为移动和 Web 构建混合 Java 应用程序的最佳实践
- java - Android Firebase 查询问题
- haskell - 如何让 HIE 检测通过堆栈安装的脚本包