The rest api works great with session variables, and it works in the current version of Drill. The key is you need to have a session created within your web requests. Here is an example using Python and the requests module. Fairly straightforward. I am not sure how requests works without auth enabled, however, it may create a session cookie even without Auth, so if you are not using authentication, just try commenting out the s = authDrill(s) line and see if it works.
Let me know if you have any questions. John #!/usr/bin/python import requests import json import sys import os drill_base_url = "https://drillbit.local:8047" drill_user = "username" drill_pass = "password" print "Drill Rest Endpoint: %s" % (drill_base_url) def main(): s = requests.Session() # Create a session object s = authDrill(s) # Authenticate to Drill r = runQuery(s, "ALTER SESSION set `store.json.all_text_mode` = true") result = runQuery(s, "CREATE TABLE your_new_table as select your_fields from your_src_table where something = somethingelse") print r.text if result.status_code == 200: print "Load Successful" else: print "Error encountered: %s" % result.status_code def runQuery(s, drill): url = drill_base_url + "/query.json" payload = {"queryType":"SQL", "query":drill} headers = {"Content-type": "application/json"} r = s.post(url, data=json.dumps(payload), headers=headers, verify=False) return r def authDrill(s): url = drill_base_url + "/j_security_check" login = {'j_username': drill_user, 'j_password': drill_pass} r = s.post(url, data=login, verify=False) if r.status_code == 200: if r.text.find("Invalid username/password credentials") >= 0: print "Authentication Failed - Please check Secrets - Exiting" sys.exit(1) elif r.text.find("Number of Drill Bits") >= 0: print "Authentication successful" else: print "Unknown Response Code 200 - Exiting" print r.text sys.exit(1) else: print "Non HTTP-200 returned - Unknown Error - Exiting" print "HTTP Code: %s" % r.status_code print r.text sys.exit(1) return s if __name__ == '__main__': main() On Tue, May 3, 2016 at 11:51 PM, Tomer Shiran <[email protected]> wrote: > Actually, there's no reason Drill can't support session variables through a > URL parameter or cookie. I am not sure if it's currently supported through. > > On Tue, May 3, 2016 at 9:11 PM, Abhishek Girish <[email protected] > > > wrote: > > > From my limited knowledge, I believe this is not supported by design. > Refer > > to > https://en.wikipedia.org/wiki/Representational_state_transfer#Stateless > > > > On Tue, May 3, 2016 at 2:47 PM, Payam Sabzmeydani <[email protected]> > wrote: > > > > > Hi all, > > > > > > I was wondering if there is a way to change session options (ALTER > > > SESSION) when using the REST API to query Drill? > > > > > > Thanks, > > > Payam > > > > > >
