I am querying a hive table using spark.
frame = sqlContext.sql("select max(id) from testing.test123") frame1=frame.map(lambda row: [str(c) for c in row]).collect() lastval =''.join(frame1[0][0]) I am getting a lastval which is what I expect
Now Using this lastval I want to query another table like below
abc = sqlcontext.sql("select * from testing.abc123 where id > {}". format(lastval)) When the lastval is a integer I am getting No errors. but when the lastval is None then I am getting the script as failed. Because the lastval should be an integer.
How do I specify if the lastvalue is None then take the lastval as 0
I tried like belwo but still when I do lastval it shows 'None'
if lastval is 'None': lastval = 0
None.if lastval is None:, or possibly actually testing for the empty string''.'None', but the error is closely related: He should instead check:lastval == 'None'.if not lastval:be more Pythonic? Edit: Misread. Would it really return"None"?''.join(frame1[0][0]), I don't believejoinreturnsNone. But I think it can return a string'None'...