Need help with calling and returning value from a function in scala

16 views
Skip to first unread message

tushar pandit

unread,
May 7, 2019, 10:06:54 PM5/7/19
to scala-functional
Hi,

I am trying to call function fetchFromDruid

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

Jed Wesley-Smith

unread,
May 7, 2019, 10:14:53 PM5/7/19
to scala-fu...@googlegroups.com
Tushar, this is a duplicate question. Please see the other one for a response, and please try not to double post if possible, thanks!

--
You received this message because you are subscribed to the Google Groups "scala-functional" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-function...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/scala-functional/e420e90d-a7f4-45d9-b87e-cbaf2e31da58%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

tushar pandit

unread,
May 7, 2019, 10:20:46 PM5/7/19
to scala-functional
Yeah sorry. Somehow mty questions were not getting posted and accidentally I clicked twice. It got posted three hours later. Sorry about that.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-fu...@googlegroups.com.

Jed Wesley-Smith

unread,
May 7, 2019, 10:28:20 PM5/7/19
to scala-fu...@googlegroups.com
this is a moderated forum to prevent spam, you are now authorised to post

To unsubscribe from this group and stop receiving emails from it, send an email to scala-function...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/scala-functional/564c57fa-db7d-46b8-a959-b9b1848d8001%40googlegroups.com.

tushar pandit

unread,
May 7, 2019, 10:42:32 PM5/7/19
to scala-functional
Ok. Thanks for clarifying
Reply all
Reply to author
Forward
0 new messages