【发布时间】: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
标签: sql apache-spark pyspark apache-spark-sql azure-databricks