apache-spark - 得到这个错误:不匹配的输入'来自'期待而 Spark SQL
问题描述
运行 Spark SQL 时,mismatched input 'from' expecting <EOF>
出现错误。
我检查了可能发生但没有发现的常见语法错误。
val prevPartitionDate = spark.sql(
"select to_date(concat(year_p,'-',month_p,'-',day_p))
from ips.command_room_table
where
to_date(concat(year_p,'-',month_p,'-',day_p)) < to_date(concat($yearAsInt,'-',$monthAsInt,'-',$dayAsInt))
group by year_p, month_p, day_p
order by to_date(concat(year_p,'-',month_p,'-',day_p)) desc limit 1"
).first.getDate(0)
我能做些什么来解决这个问题?
解决方案
不用担心,能够弄清楚问题。当我在查询中使用变量时,我只需在查询的开头添加“s”,如下所示:
val prevPartitionDate = spark.sql(s
"select to_date(concat(year_p,'-',month_p,'-',day_p))
from ips.command_room_table
where
to_date(concat(year_p,'-',month_p,'-',day_p)) < to_date(concat($yearAsInt,'-',$monthAsInt,'-',$dayAsInt))
group by year_p, month_p, day_p
order by to_date(concat(year_p,'-',month_p,'-',day_p)) desc limit 1"
).first.getDate(0)
推荐阅读
- r - 从嵌套 tibble 的 2 个不同列中提取标题和副标题
- azure - 在 Linux 上运行的 .NET Core Azure 函数中的 SharePoint CSOM
- python - 绘制非线性方程的解对
- php - phpMailer 停止发送电子邮件
- string-comparison - 将按钮标签值与字符串变量进行比较
- git - 如何在 SourceTree 中将文件导入我的本地文件?
- html - 加载workDays ejs-schedule时的无限循环
- arrays - 在颤振/飞镖中创建一个二维数组
- c# - 如何在 WinXP 中的 .NET 中使用 TLS 1.2?
- node.js - 快速修改响应头