簡體   English   中英

ParseExpection:輸入時沒有可行的替代方案

[英]ParseExpection: no viable alternative at input

我試圖在 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 = '' 時沒有可行的替代方案然后 cast('1900-00.00:00:000:01-00: )\n 以 dttm\n 結尾,來自 dde_pre_file_user_supp\n )'

我可以在數據塊中使用 WITH 子句還是有其他選擇?

我已經提到了可能導致“輸入時沒有可行的替代方案”錯誤的原因:

  1. 當我們鍵入一個不適合該行上下文的字符時,會出現“輸入時沒有可行的替代方案”錯誤消息。
  2. 還要檢查某些字段的數據類型是否可能不匹配。

“輸入時沒有可行的替代方案”錯誤沒有提到我們使用了哪個不正確的字符。

請參閱piotrwest這個答案

也可以參考這篇文章

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM