I have a hive table partitoned by ds
where ds
is a string like 2017-11-07
. Since string is comparable, I want to select latest partition of data from hive by sparksql, so I wrote this code:
Dataset<Row> ds = sparkSession.sql("select max(ds) from admin_zpw123_user_meta");
String s = ds.first().getString(0);
sparkSession.sql("select * from admin_zpw123_user_meta where ds="+s).show();
I can print the string s, which is 2017-11-07
but I didn't get any output from the third statement. I want to know why and is there an elegent way to do this?