Here is an example

# curl  \
  --header "Content-type: application/json" \
  --request POST \
  --data '{
    "queryType" : "SQL",
    "query" : "select * from  dfs.mydata.orderprodview limit 1"
 }' \
  http://192.168.110.133:8047/query.json
[ {
  "order_total" : 13,
  "category" : "Binders and Binder Accessories",
  "prod_id" : 909,
  "name" : "Wilson Jones Ledger-SizePiano-Hinge Binder2Blue",
  "state" : "ca",
  "month" : "June",
  "order_id" : 67212,
  "cust_id" : 10001
}]


Drill provides a Simple REST Interface which you can read more about on the
Drill wiki
https://cwiki.apache.org/confluence/display/DRILL/Apache+Drill+Wiki. Here
is the REST API to submit a query and receive results. You can use HTTP
Post to the Drill URL <drill_node_ip_address>:8047/query.json with a JSON
Request body in the query as shown. You will receive the response as a list
of JSON objects :

POST <drill_node_ip_address>:8047/query.json
Request body:
{
 "queryType" : "SQL",
 "query" : "select * from  dfs.mydata.orderprodview limit 5”
}
Response body (list of JSON objects):
[
 {
   "order_total" : 13,
   "category" : "Binders and Binder Accessories",
   "prod_id" : 909,
   "name" : "Wilson Jones Ledger-SizePiano-Hinge Binder2Blue",
   "state" : "ca", }, …
]



On Wed, Oct 14, 2015 at 3:53 AM, Tugdual Grall <[email protected]> wrote:

> Hello,
>
> You can also look at this blog post:
>
> https://www.mapr.com/blog/how-use-sql-hadoop-drill-rest-json-nosql-and-hbase-simple-rest-client
>
> Regards
> Tug
> @tgrall
>
> On Wed, Oct 14, 2015 at 6:27 AM, Tomer Shiran <[email protected]> wrote:
> > Here are a few slides that show how to use the REST API:
> > http://www.slideshare.net/dremio/drill-rest-api
> >
> > Note:
> >
> >    - The method should be: POST
> >    - Add an HTTP header: "Content-Type: application/json"
> >    - Format the payload in JSON
> >
> >
> >
> >
> > On Tue, Oct 13, 2015 at 9:16 PM, Amandeep Singh <[email protected]
> >
> > wrote:
> >
> >> Right now I am just trying to hit the url, its not working.
> >> Also through mozilla rest client its not working.
> >>
> >> On Tue, Oct 13, 2015 at 3:26 PM, Amandeep Singh <
> [email protected]>
> >> wrote:
> >>
> >> > Hi,
> >> >
> >> > I am using apache drill and I am unable to hit the url :
> >> > http://localhost:8047/query.json
> >> > (as drill is installed on my localhost).
> >> > I want to use the REST service for method query.json to get response
> in
> >> > json form for my sql query.
> >> > Please suggest.
> >> >
> >> > Regards,
> >> > Amandeep Singh
> >> >
> >>
>

Reply via email to