ParseExpection:输入时没有可行的替代方案
Posted
技术标签:
【中文标题】ParseExpection:输入时没有可行的替代方案【英文标题】:ParseExpection: no viable alternative at input 【发布时间】:2021-12-31 09:32:15 【问题描述】:我试图在 Azure 数据块中运行以下查询。
query=s"""WITH pre_file_user AS(
SELECT id,
typeid,
CASE when dttm is null or dttm='' then cast('1900-01-01 00:00:00.000' as timestamp)
else cast(dttm as timestamp)
end as dttm
from dde_pre_file_user_supp
)"""
spark.sql(query)
然后我收到以下错误
ParseException: 在输入 'with pre_file_users AS 时没有可行的替代方案 (\n select id, \n typid, in case\n 当 dttm 为 null 或 dttm = '' then cast('1900-01-01 00:00:00.000 as timestamp)\n end as dttm\n from dde_pre_file_user_supp\n)'
我可以在数据块中使用 WITH 子句还是有其他替代方法?
【问题讨论】:
您只是在声明 CTE,但并未使用它。尝试在 cte 后添加select * from pre_file_user
【参考方案1】:
我已经提到了可能导致“输入时没有可行的替代方案”错误的原因:
-
当我们键入的字符不适合该行的上下文时,会出现 “输入时没有可行的替代方案” 错误消息。
还要检查某些字段的数据类型是否可能不匹配。
“输入时没有可行的替代”错误没有提及我们使用了哪个错误字符。
参考thispiotrwest的回答
也可以参考这个article
【讨论】:
以上是关于ParseExpection:输入时没有可行的替代方案的主要内容,如果未能解决你的问题,请参考以下文章
Spark SQL 嵌套 JSON 错误“输入时没有可行的替代方案”
如何修复 Javadoc 注释有解析错误,详细信息:在解析 JAVADOC_TAG [NonEmptyAtClauseDescription] 时输入“*”没有可行的替代方案