我有一个spark sql查询,它接受的值很长。
Dataset getQuery = spark.sql("select * from trafficdata where message_time between 1486036800000 and 1486108800000 ")
我想把这个时间变成像
这样的变量Long val1 = 1486036800000
Long val2 = 1486108800000
Dataset getQuery = spark.sql("select * from trafficdata where message_time between $val1 and $val2 ")
我尝试使用$val1
,但它不起作用。任何人都可以建议,如何在java中做到这一点?
答案 0 :(得分:0)
我认为您应该将查询编写为
"select * from trafficdata where message_time between '" + val1 + "' and '" + val2 + "'"
答案 1 :(得分:-1)
尝试这样:
getQuery = spark.sql(String.format("select * from trafficdata where message_time between %d and %d ", val1, val2));