I have a python variable (I am using pyspark) of date datatype: The variable value is 2016-10-31
print type(load_dt)
>> <type 'datetime.date'>
I am having difficulty passing this to a sparksql query:
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)