def main(args: Array[String]): Unit = {
val res = fetchFromDruid()
// res comes as null here
}
def fetchFromDruid(): GroupByResponse {
implicit val executionContext = ExecutionContext.Implicits.global
val client = DruidClient("http://localhost:8082")
val query = GroupByQuery(
source = "wikipedia",
interval = new Interval(new DateTime().minusMonths(60), new DateTime()),
dimensions = Seq("countryName"),
descending = true,
granularity = Granularity.All,
aggregate = Seq(
DSL.count("row_count")
),
postAggregate = Seq(
),
limit = Some(100)
)
client(query).onComplete {
case Success(resp) =>
resp.data.foreach { row =>
println(row)
}
return resp
println("none")
//System.exit(0)
case Failure(ex) =>
ex.printStackTrace()
return null
//System.exit(0)
}
}
But somehow I am not able to return the response to the caller; i.e the main function. What could be the issue?
Thanks,
Tushar