【发布时间】:2018-01-03 18:48:03
【问题描述】:
我有一个日期数据类型的 python 变量(我正在使用 pyspark): 变量值为2016-10-31
print type(load_dt)
>> <type 'datetime.date'>
我很难将它传递给 sparksql 查询:
hive_context.sql("select * from tbl t1 where cast (substring(t1.dt,1,10) as date) ={0}".format(load_dt));
Error:
u"cannot resolve '(cast(substring(dt,1,10) as date) = ((2016 - 10) - 31))' due to data type mismatch: differing types in '(cast(substring(period_dt,1,10) as date) = ((2016 - 10) - 31))'
(date and int)
【问题讨论】:
标签: python sql apache-spark pyspark