Hi Rozen,
you  can  get current time by call a java API and then get rowTimestamp by sql;
val currentTimeStamp=System.currentTimeMillis()val  rowTimestatm = 
sqlContext.sql("select  rowTimestamp  from tableName")

and then you can wirte a function like this

def diffDate(currentTimeStamp,rowTimeStamp  ):INT={

here is something you need to do;
}





------------------ ???????? ------------------
??????: "Tal Rozen";<t...@scaleka.com>;
????????: 2015??7??22??(??????) ????0:04
??????: "user"<user@spark.apache.org>; 

????: Timestamp functions for sqlContext



Hi, 

I'm running a query with sql context where one of the fields is of type 
java.sql.Timestamp. I'd like to set a function similar to DATEDIFF in mysql, 
between the date given in each row, and now. So If I was able to use the same 
syntax as in mysql it would be:


val date_diff_df = sqlContext.sql("select DATEDIFF(curdate(), rowTimestamp) 
date_diff from tableName")


What are the relevant key words to replace curdate(), and DATEDIFF?


Thanks

Reply via email to