Welcome to Dremio client’s documentation!¶
Dremio client¶
The un-official python client for Dremio’s REST API. This enables both administrators and data scientists to get the most out of Dremio in Python
- Documentation: https://dremio-client.readthedocs.io.
- Github: https://github.com/rymurr/dremio_client
- PyPI: https://pypi.python.org/pypi/dremio_client
- Free software: Apache Software License 2.0
Features¶
Cross platform support
All Pythons between 2.7 - 3.7 supported
Full support for Dremio’s REST API
Optional Support for Dremio’s ODBC or experimental Arrow Flight capabilities
Rich config file support via confuse yaml config library. Simple to create a client (config stored in a yaml file)
from dremio_client import init client = init() # initialise connectivity to Dremio via config file catalog = client.data # fetch catalog vds = catalog.space.vds.get() # fetch a specific dataset df = vds.query() # query the first 1000 rows of the dataset and return as a DataFrame pds = catalog.source.pds.get() # fetch a physical dataset pds.metadata_refresh() # refresh metadata on that dataset
CLI interface for integration with scripts
$ dremio_client query --sql 'select * from sys.options' {'results':results} $ dremio_client refresh-metadata --table 'my.vds.name' {'result':'ok'}
Catalog autocompletion in Jupyter Notebooks

Status¶
This is still alpha software and is relatively incomplete. Contributions in the form of Github Issues or Pull requests are welcome. See CONTRIBUTING
TODO¶
- see issues
Installation¶
Stable release¶
To install basic Dremio client, run this command in your terminal:
$ pip install dremio_client
This installs a minimal set of dependencies suitable for only interacting with the REST API and for restricted environments. To get full set of dependencies run:
$ pip install dremio_client[noarrow] # everything but pyarrow
$ pip install dremio_client[full] # all dependencies
This is the preferred method to install Dremio client, as it will always install the most recent stable release.
If you don’t have pip installed, this Python installation guide can guide you through the process.
Conda release¶
You can use conda to install Dremio Client by doing:
$ conda install dremio_client -c rymurr -c conda-forge
From sources¶
The sources for Dremio client can be downloaded from the Github repo.
You can either clone the public repository:
$ git clone git://github.com/rymurr/dremio_client
Or download the tarball:
$ curl -OL https://github.com/rymurr/dremio_client/tarball/master
Once you have a copy of the source, you can install it with:
$ python setup.py install
Usage¶
To use Dremio client in a project:
import dremio_client
Configuration¶
The Dremio Client is configured using the confuse yaml based configuration library. This looks for a configuration
file called config.yaml
in:
- macOS:
~/.config/dremio_client
and~/Library/Application Support/dremio_client
- Other Unix:
~/.config/dremio_client
and/etc/dremio_client
- Windows:
%APPDATA%\dremio_client
where the APPDATA environment variable falls back to%HOME%\AppData\Roaming
if undefined - Via the environment variable
DREMIO_CLIENTDIR
The default config file is as follows:
auth: type: basic # currently only basic is supported username: dremio password: dremio123 timeout: 10 hostname: localhost port: 9047 ssl: false
The command line interface can be configured with most of the above parameters via flags or by setting a config directory.
The relevant configs can also be set via environment variables. These take precedence. The environment variable format is
to append DREMIO_
to a config parameter and nested configs are separated by a _. For example:
DREMIO_AUTH_TIMEOUT
maps to auth.timeout
in the default configuration file above.
Utilities¶
We provide several useful utilities to help with common tasks
Async and sync queries¶
To execute a query synchronously run the following:
from dremio_client import init import pandas as pd query = 'select * from sys.options' client = init(simple_client=True) results = client.query(self, query) pd.DataFrame(results)
This will submit the sql query to the sql
endpoint then poll the job-status
endpoint until the job completed.
If the job has succeeded a list
of dicts
is returned else it throws an exception.
One can execute many queries at once via async querys also:
from dremio_client import init from concurrent.futures.thread import ThreadPoolExecutor from concurrent.futures import as_completed queries = ['select * from table0', 'select * from table1', 'select * from table2', 'select * from table3', 'select * from table4', 'select * from table5' ] client = init(simple_client=True) def execute(query): client.query(query, asynchronous=True) # example shamelessly taken from https://docs.python.org/3/library/concurrent.futures.html with ThreadPoolExecutor(max_workers=4) as executor: futures = {executor.submit(execute, query): query for query in queries} for future in as_completed(futures): query = futures[future] try: result = future.result() except Exception as exc: print('%r generated an exception: %s' % (url, exc)) else: print('%r returned %d rows' % (url, len(results)))
Command Line Interface¶
The Dremio Client uses the Click library to generate its command line interface. This is installed as
dremio_client
by pip
All of the REST API calls are exposed via the command line interface. To see a list of what is available run:
$ dremio_client --help Usage: dremio_client [OPTIONS] COMMAND [ARGS]... Options: --config DIRECTORY Custom config file. -h, --hostname TEXT Hostname if different from config file -p, --port INTEGER Hostname if different from config file --ssl Use SSL if different from config file -u, --username TEXT username if different from config file -p, --password TEXT password if different from config file --help Show this message and exit. Commands: catalog_item return the details of a given catalog item if... delete_catalog delete a catalog entity given by cid and tag... delete_pat delete a personal access token graph return graph info of PDS or VDS group return group info job_results return results for a given job id pagenated... job_status Return status of job for a given job id pat return personal access token info for a given... query execute a query given by sql and print... reflection return the reflection set reflections return the reflection set refresh_pds refresh metadata/reflections for a given... set_catalog set a catalog entity with the given json... set_pat create a personal access token sql Execute sql statement and return job id tags returns tags for a given catalog entity id or... update_catalog update a catalog entity (cid) given a json... user return user info votes return reflection votes wiki returns wiki for a given catalog entity id or... wlm_queues return the list of wlm queues wlm_rules return the list of wlm rules
The config directory and a number of other settings can be configured from the command line and overwrite the default config locations.
Run a Query¶
We can run a query on the command line and have the results returned as json. We use jq to manipulate the json after it is returned. This could be combined into more complete scripts for maintenance and monitoring.
$ dremio_client query --help Usage: dremio_client query [OPTIONS] execute a query given by sql and print results as json Options: --sql TEXT sql query to execute. [required] --help Show this message and exit. $ dremio_client query --sql 'select * from sys.options' | jq '. | length' 477 $ dremio_client query --sql 'select * from sys.options' | jq [ { "name": "vote.release.leadership.ms", "kind": "LONG", "type": "SYSTEM", "status": "DEFAULT", "num_val": 126000000, "string_val": null, "bool_val": null, "float_val": null }, { "name": "vote.schedule.millis", "kind": "LONG", "type": "SYSTEM", ... $ dremio_client query --sql 'select * from sys.options' | jq 'to_entries[] | "\(.value | .name)"' "acceleration.orphan.cleanup_in_milliseconds" "accelerator.enable.subhour.policies" "accelerator.enable_agg_join" ...
dremio_client¶
dremio_client package¶
Subpackages¶
dremio_client.auth package¶
Submodules¶
dremio_client.auth.basic module¶
-
dremio_client.auth.basic.
login
(base_url, username, password, timeout=10, verify=True)[source]¶ Log into dremio using basic auth :param base_url: Dremio url :param username: username :param password: password :param timeout: optional timeout :param verify: If false ignore ssl errors :return: auth token
Module contents¶
-
dremio_client.auth.
basic_auth
(base_url, username, password, timeout=10, verify=True)¶ Log into dremio using basic auth :param base_url: Dremio url :param username: username :param password: password :param timeout: optional timeout :param verify: If false ignore ssl errors :return: auth token
-
dremio_client.auth.
config_auth
(base_url, config_dict)¶ Log into dremio using basic auth and looking for config :param base_url: Dremio url :param config_dict: config dict :param timeout: optional timeout :return: auth token
dremio_client.conf package¶
Submodules¶
dremio_client.conf.cli_helper module¶
dremio_client.conf.config_parser module¶
dremio_client.flight package¶
Submodules¶
dremio_client.flight.command_pb2 module¶
dremio_client.flight.flight_auth module¶
-
class
dremio_client.flight.flight_auth.
HttpDremioClientAuthHandler
(username, password)[source]¶ Bases:
pyarrow._flight.ClientAuthHandler
Module contents¶
-
dremio_client.flight.
connect
(hostname='localhost', port=47470, username='dremio', password='dremio123', tls_root_certs_filename=None)[source]¶ Connect to and authenticate against Dremio’s arrow flight server. Auth is skipped if username is None
Parameters: - hostname – Dremio coordinator hostname
- port – Dremio coordinator port
- username – Username on Dremio
- password – Password on Dremio
- tls_root_certs_filename – use ssl to connect with root certs from filename
Returns: arrow flight client
-
dremio_client.flight.
query
(sql, client=None, hostname='localhost', port=47470, username='dremio', password='dremio123', pandas=True, tls_root_certs_filename=False)[source]¶ Run an sql query against Dremio and return a pandas dataframe or arrow table
Either host,port,user,pass tuple or a pre-connected client should be supplied. Not both
Parameters: - sql – sql query to execute on dremio
- client – pre-connected client (optional)
- hostname – Dremio coordinator hostname (optional)
- port – Dremio coordinator port (optional)
- username – Username on Dremio (optional)
- password – Password on Dremio (optional)
- pandas – return a pandas dataframe (default) or an arrow table
- tls_root_certs_filename – use ssl to connect with root certs from filename
Returns:
dremio_client.model package¶
Submodules¶
dremio_client.model.catalog module¶
dremio_client.model.data module¶
-
class
dremio_client.model.data.
AccessControlList
(users=None, groups=None, version=None)[source]¶ Bases:
object
-
class
dremio_client.model.data.
Catalog
(token=None, base_url=None, flight_endpoint=None, ssl_verify=True, dirty=False)[source]¶ Bases:
dict
-
promote
(file_format='parquet', **kwargs)[source]¶ promote this file/folder to a PDS
Note
can only be run on a file or folder in a Source
Parameters: file_format – file format of the file/folder (only parquet, xls, excel, json, text are accepted) :return None
-
-
class
dremio_client.model.data.
Dataset
(token=None, base_url=None, flight_endpoint=None, ssl_verify=True, dirty=False, **kwargs)[source]¶
-
class
dremio_client.model.data.
DatasetMetaData
(entityType=None, id=None, path=None, tag=None, type=None, fields=None, createdAt=None, accelerationRefreshPolicy=None, sql=None, sqlContext=None, format=None, approximateStatisticsAllowed=None, accessControlList=None)[source]¶ Bases:
object
-
class
dremio_client.model.data.
File
(token=None, base_url=None, flight_endpoint=None, ssl_verify=True, dirty=False, **kwargs)[source]¶
-
class
dremio_client.model.data.
FileMetaData
(entityType=None, id=None, path=None, accessControlList=None)[source]¶ Bases:
object
-
class
dremio_client.model.data.
Folder
(token=None, base_url=None, flight_endpoint=None, ssl_verify=True, dirty=False, **kwargs)[source]¶
-
class
dremio_client.model.data.
FolderMetaData
(entityType=None, id=None, path=None, tag=None, accessControlList=None)[source]¶ Bases:
object
-
class
dremio_client.model.data.
Home
(token=None, base_url=None, flight_endpoint=None, ssl_verify=True, dirty=False, **kwargs)[source]¶
-
class
dremio_client.model.data.
MetadataPolicy
(authTTLMs=None, datasetRefreshAfterMs=None, datasetExpireAfterMs=None, namesRefreshMs=None, datasetUpdateMode=None)[source]¶ Bases:
object
-
class
dremio_client.model.data.
PhysicalDataset
(token=None, base_url=None, flight_endpoint=None, ssl_verify=True, dirty=False, **kwargs)[source]¶
-
class
dremio_client.model.data.
QueueMetadata
(id=None, tag=None, name=None, cpuTier=None, maxAllowedRunningJobs=None, maxStartTimeoutMs=None)[source]¶ Bases:
object
-
class
dremio_client.model.data.
ReflectionMetadata
(entityType=None, id=None, tag=None, name=None, enabled=None, createdAt=None, updatedAt=None, type=None, datasetId=None, currentSizeBytes=None, totalSizeBytes=None, status=None, dimensionFields=None, measureFields=None, displayFields=None, distributionFields=None, partitionFields=None, sortFields=None, partitionDistributionStrategy=None)[source]¶ Bases:
object
-
class
dremio_client.model.data.
ReflectionSummaryMetadata
(entityType=None, id=None, createdAt=None, updatedAt=None, type=None, name=None, datasetId=None, datasetPath=None, datasetType=None, currentSizeBytes=None, totalSizeBytes=None, enabled=None, status=None)[source]¶ Bases:
object
-
class
dremio_client.model.data.
Root
(token=None, base_url=None, flight_endpoint=None, ssl_verify=True, dirty=False)[source]¶
-
class
dremio_client.model.data.
RuleMetadata
(name=None, conditions=None, acceptId=None, acceptName=None, action=None, id=None)[source]¶ Bases:
object
-
class
dremio_client.model.data.
Source
(token=None, base_url=None, flight_endpoint=None, ssl_verify=True, dirty=False, **kwargs)[source]¶
-
class
dremio_client.model.data.
SourceMetadata
(entityType=None, id=None, name=None, description=None, tag=None, type=None, config=None, createdAt=None, metadataPolicy=None, state=None, accelerationGracePeriodMs=None, accelerationRefreshPeriodMs=None, accelerationNeverExpire=None, accelerationNeverRefresh=None, path=None, accessControlList=None)[source]¶ Bases:
object
-
class
dremio_client.model.data.
Space
(token=None, base_url=None, flight_endpoint=None, ssl_verify=True, dirty=False, **kwargs)[source]¶
-
class
dremio_client.model.data.
SpaceMetaData
(entityType=None, id=None, name=None, tag=None, path=None, accessControlList=None)[source]¶ Bases:
object
-
class
dremio_client.model.data.
VirtualDataset
(token=None, base_url=None, flight_endpoint=None, ssl_verify=True, dirty=False, **kwargs)[source]¶
-
class
dremio_client.model.data.
VoteMetadata
(id=None, votes=None, datasetId=None, datasetPath=None, datasetType=None, datasetReflectionCount=None, entityType=None)[source]¶ Bases:
object
-
dremio_client.model.data.
create
(item, token, base_url, flight_endpoint, trim_path=0, ssl_verify=True, dirty=False)[source]¶
dremio_client.model.endpoints module¶
-
dremio_client.model.endpoints.
cancel_job
(token, base_url, jid, ssl_verify=True)[source]¶ cancel running job with job id = jid
https://docs.dremio.com/rest-api/jobs/post-job.html
Parameters: - token – auth token
- base_url – sql query
- jid – id of the job to cancel
- ssl_verify – ignore ssl errors if False
Returns: result object
:exception DremioNotFoundException no job found :exception DremioBadRequestException job already finished
-
dremio_client.model.endpoints.
catalog
(token, base_url, ssl_verify=True)[source]¶ https://docs.dremio.com/rest-api/catalog/get-catalog.html populate the root dremio catalog
Parameters: - token – auth token from previous login attempt
- base_url – base Dremio url
- ssl_verify – ignore ssl errors if False
Returns: json of root resource
-
dremio_client.model.endpoints.
catalog_item
(token, base_url, cid=None, path=None, ssl_verify=True)[source]¶ fetch a specific catalog item by id or by path
https://docs.dremio.com/rest-api/catalog/get-catalog-id.html https://docs.dremio.com/rest-api/catalog/get-catalog-path.html
Parameters: - token – auth token from previous login attempt
- base_url – base Dremio url
- cid – unique dremio id for resource
- path – list [‘space’, ‘folder’, ‘vds’]
- ssl_verify – ignore ssl errors if False
Returns: json of resource
fetch tags for a catalog entry
https://docs.dremio.com/rest-api/user/get-catalog-collaboration.html
Parameters: - token – auth token
- base_url – sql query
- cid – id of a catalog entity
- ssl_verify – ignore ssl errors if False
Returns: result object
-
dremio_client.model.endpoints.
collaboration_wiki
(token, base_url, cid, ssl_verify=True)[source]¶ fetch wiki for a catalog entry
https://docs.dremio.com/rest-api/user/get-catalog-collaboration.html
Parameters: - token – auth token
- base_url – sql query
- cid – id of a catalog entity
- ssl_verify – ignore ssl errors if False
Returns: result object
-
dremio_client.model.endpoints.
create_queue
(token, base_url, json, ssl_verify=True)[source]¶ create a single queue
https://docs.dremio.com/rest-api/reflections/post-wlm-queue.html
Parameters: - token – auth token
- base_url – sql query
- json – json document for new queue
- ssl_verify – ignore ssl errors if False
Returns: result object
-
dremio_client.model.endpoints.
create_reflection
(token, base_url, json, ssl_verify=True)[source]¶ create a single reflection
https://docs.dremio.com/rest-api/reflections/post-reflection.html
Parameters: - token – auth token
- base_url – sql query
- json – json document for new reflection
- ssl_verify – ignore ssl errors if False
Returns: result object
-
dremio_client.model.endpoints.
delete_catalog
(token, base_url, cid, tag, ssl_verify=True)[source]¶ remove a catalog item from Dremio
https://docs.dremio.com/rest-api/catalog/delete-catalog-id.html
Parameters: - token – auth token
- base_url – sql query
- cid – id of a catalog entity
- tag – version tag of entity
- ssl_verify – ignore ssl errors if False
Returns: None
-
dremio_client.model.endpoints.
delete_personal_access_token
(token, base_url, uid, tid=None, ssl_verify=True)[source]¶ create a pat for a given user
https://docs.dremio.com/rest-api/user/delete-user-uid-token.html
Parameters: - token – auth token
- base_url – sql query
- uid – id user
- tid – label of token (optional)
- ssl_verify – ignore ssl errors if False
Returns: updated catalog entity
-
dremio_client.model.endpoints.
delete_queue
(token, base_url, queueid, ssl_verify=True)[source]¶ delete a single queue by id
https://docs.dremio.com/rest-api/reflections/delete-wlm-queue.html
Parameters: - token – auth token
- base_url – sql query
- queueid – id of the queue to delete
- ssl_verify – ignore ssl errors if False
Returns: result object
-
dremio_client.model.endpoints.
delete_reflection
(token, base_url, reflectionid, ssl_verify=True)[source]¶ delete a single reflection by id
https://docs.dremio.com/rest-api/reflections/delete-reflection.html
Parameters: - token – auth token
- base_url – sql query
- reflectionid – id of the reflection to delete
- ssl_verify – ignore ssl errors if False
Returns: result object
-
dremio_client.model.endpoints.
graph
(token, base_url, cid=None, ssl_verify=True)[source]¶ Retrieves graph information about a specific catalog entity by id
https://docs.dremio.com/rest-api/catalog/get-catalog-id-graph.html
Parameters: - token – auth token from previous login attempt
- base_url – base Dremio url
- cid – unique dremio id for resource
- ssl_verify – ignore ssl errors if False
Returns: json of resource
-
dremio_client.model.endpoints.
group
(token, base_url, gid=None, name=None, ssl_verify=True)[source]¶ fetch a group based on id or name
https://docs.dremio.com/rest-api/reflections/get-group.html
Parameters: - token – auth token
- base_url – sql query
- gid – unique dremio id for group
- name – name for a group
- ssl_verify – ignore ssl errors if False
Returns: result object
-
dremio_client.model.endpoints.
job_results
(token, base_url, job_id, offset=0, limit=100, ssl_verify=True)[source]¶ fetch job results
https://docs.dremio.com/rest-api/jobs/get-job.html
Parameters: - token – auth token
- base_url – sql query
- job_id – job id (as returned by sql)
- offset – offset of result set to return
- limit – number of results to return (max 500)
- ssl_verify – ignore ssl errors if False
Returns: result object
-
dremio_client.model.endpoints.
job_status
(token, base_url, job_id, ssl_verify=True)[source]¶ fetch job status
https://docs.dremio.com/rest-api/jobs/get-job.html
Parameters: - token – auth token
- base_url – sql query
- job_id – job id (as returned by sql)
- ssl_verify – ignore ssl errors if False
Returns: status object
-
dremio_client.model.endpoints.
modify_queue
(token, base_url, queueid, json, ssl_verify=True)[source]¶ update a single queue by id
https://docs.dremio.com/rest-api/reflections/put-wlm-queue.html
Parameters: - token – auth token
- base_url – sql query
- queueid – id of the reflection to fetch
- json – json document for modified queue
- ssl_verify – ignore ssl errors if False
Returns: result object
-
dremio_client.model.endpoints.
modify_reflection
(token, base_url, reflectionid, json, ssl_verify=True)[source]¶ update a single reflection by id
https://docs.dremio.com/rest-api/reflections/put-reflection.html
Parameters: - token – auth token
- base_url – sql query
- reflectionid – id of the reflection to fetch
- json – json document for modified reflection
- ssl_verify – ignore ssl errors if False
Returns: result object
-
dremio_client.model.endpoints.
modify_rules
(token, base_url, json, ssl_verify=True)[source]¶ update wlm rules. Order of rules array is important!
The order of the rules is the order in which they will be applied. If a rule isn’t included it will be deleted new ones will be created https://docs.dremio.com/rest-api/reflections/put-wlm-rule.html
Parameters: - token – auth token
- base_url – sql query
- json – json document for modified reflection
- ssl_verify – ignore ssl errors if False
Returns: result object
-
dremio_client.model.endpoints.
personal_access_token
(token, base_url, uid, ssl_verify=True)[source]¶ fetch a PAT for a user based on id
https://docs.dremio.com/rest-api/user/get-user-id-token.html
Parameters: - token – auth token
- base_url – sql query
- uid – id of a user
- ssl_verify – ignore ssl errors if False
Returns: result object
-
dremio_client.model.endpoints.
promote_catalog
(token, base_url, cid, json, ssl_verify=True)[source]¶ promote a catalog entity (only works on folders and files in sources
https://docs.dremio.com/rest-api/catalog/post-catalog-id.html
Parameters: - token – auth token
- base_url – sql query
- cid – id of catalog entity
- json – json document for new catalog entity
- ssl_verify – ignore ssl errors if False
Returns: updated catalog entity
-
dremio_client.model.endpoints.
reflection
(token, base_url, reflectionid, ssl_verify=True)[source]¶ fetch a single reflection by id
https://docs.dremio.com/rest-api/reflections/get-reflection.html
Parameters: - token – auth token
- base_url – sql query
- reflectionid – id of the reflection to fetch
- ssl_verify – ignore ssl errors if False
Returns: result object
-
dremio_client.model.endpoints.
reflections
(token, base_url, summary=False, ssl_verify=True)[source]¶ fetch all reflections
https://docs.dremio.com/rest-api/reflections/get-reflection.html
Parameters: - token – auth token
- base_url – sql query
- summary – fetch only the reflection summary
- ssl_verify – ignore ssl errors if False
Returns: result object
-
dremio_client.model.endpoints.
refresh_pds
(token, base_url, pid, ssl_verify=True)[source]¶ refresh a physical dataset and all its child reflections
https://docs.dremio.com/rest-api/catalog/post-catalog-id-refresh.html
Parameters: - token – auth token
- base_url – sql query
- pid – id of a catalog entity
- ssl_verify – ignore ssl errors if False
Returns: None
-
dremio_client.model.endpoints.
set_catalog
(token, base_url, json, ssl_verify=True)[source]¶ add a new catalog entity
https://docs.dremio.com/rest-api/catalog/post-catalog.html
Parameters: - token – auth token
- base_url – sql query
- json – json document for new catalog entity
- ssl_verify – ignore ssl errors if False
Returns: new catalog entity
set tags on a given catalog entity
https://docs.dremio.com/rest-api/catalog/post-catalog-collaboration.html
Parameters: - token – auth token
- base_url – sql query
- cid – id of a catalog entity
- tags – list of strings for tags
- ssl_verify – ignore ssl errors if False
Returns: None
-
dremio_client.model.endpoints.
set_collaboration_wiki
(token, base_url, cid, wiki, ssl_verify=True)[source]¶ set wiki on a given catalog entity
https://docs.dremio.com/rest-api/catalog/post-catalog-collaboration.html
Parameters: - token – auth token
- base_url – sql query
- cid – id of a catalog entity
- wiki – text representing markdown for entity
- ssl_verify – ignore ssl errors if False
Returns: None
-
dremio_client.model.endpoints.
set_personal_access_token
(token, base_url, uid, label, lifetime=24, ssl_verify=True)[source]¶ create a pat for a given user
https://docs.dremio.com/rest-api/user/post-user-uid-token.html
Parameters: - token – auth token
- base_url – sql query
- uid – id user
- label – label of token
- lifetime – lifetime in hours of token
- ssl_verify – ignore ssl errors if False
Returns: updated catalog entity
-
dremio_client.model.endpoints.
sql
(token, base_url, query, context=None, ssl_verify=True)[source]¶ submit job w/ given sql
https://docs.dremio.com/rest-api/sql/post-sql.html
Parameters: - token – auth token
- base_url – base Dremio url
- query – sql query
- context – optional dremio context
- ssl_verify – ignore ssl errors if False
Returns: job id json object
-
dremio_client.model.endpoints.
update_catalog
(token, base_url, cid, json, ssl_verify=True)[source]¶ update a catalog entity
https://docs.dremio.com/rest-api/catalog/put-catalog-id.html
Parameters: - token – auth token
- base_url – sql query
- cid – id of catalog entity
- json – json document for new catalog entity
- ssl_verify – ignore ssl errors if False
Returns: updated catalog entity
-
dremio_client.model.endpoints.
user
(token, base_url, uid=None, name=None, ssl_verify=True)[source]¶ fetch user based on id or name https://docs.dremio.com/rest-api/reflections/get-user.html
Parameters: - token – auth token
- base_url – sql query
- uid – unique dremio id for user
- name – name for a user
- ssl_verify – ignore ssl errors if False
Returns: result object
-
dremio_client.model.endpoints.
votes
(token, base_url, ssl_verify=True)[source]¶ fetch all votes
https://docs.dremio.com/rest-api/reflections/get-vote.html
Parameters: - token – auth token
- base_url – sql query
- ssl_verify – ignore ssl errors if False
Returns: result object
-
dremio_client.model.endpoints.
wlm_queues
(token, base_url, ssl_verify=True)[source]¶ fetch all wlm queues
https://docs.dremio.com/rest-api/reflections/get-wlm-queue.html
Parameters: - token – auth token
- base_url – sql query
- ssl_verify – ignore ssl errors if False
Returns: result object
-
dremio_client.model.endpoints.
wlm_rules
(token, base_url, ssl_verify=True)[source]¶ fetch all wlm rules
https://docs.dremio.com/rest-api/reflections/get-wlm-queue.html
Parameters: - token – auth token
- base_url – sql query
- ssl_verify – ignore ssl errors if False
Returns: result object
Module contents¶
dremio_client.util package¶
Submodules¶
dremio_client.util.query module¶
-
dremio_client.util.query.
refresh_metadata
(token, base_url, table, ssl_verify=True)[source]¶ Refresh the metadata of a given PDS
This requests a metadata refresh of a given Physical Dataset
Parameters: - token – API token from auth
- base_url – base url of Dremio instance
- table – valid dremio table name
- ssl_verify – verify ssl on web requests
Raise: DremioException if job failed
Raise: DremioUnauthorizedException if token is incorrect or invalid
Returns: None
Example: >>> refresh_metadata('abc', 'http://localhost:9047', 'source.pds')
-
dremio_client.util.query.
run
(token, base_url, query, context=None, sleep_time=10, ssl_verify=True)[source]¶ Run a single sql query
This runs a single sql query against the rest api and returns a json document of the results
Parameters: - token – API token from auth
- base_url – base url of Dremio instance
- query – valid sql query
- context – optional context in which to execute the query
- sleep_time – seconds to sleep between checking for finished state
- ssl_verify – verify ssl on web requests
Raise: DremioException if job failed
Raise: DremioUnauthorizedException if token is incorrect or invalid
Returns: json array of result rows
Example: >>> run('abc', 'http://localhost:9047', 'select * from sys.options') [{'record':'1'}, {'record':'2'}]
-
dremio_client.util.query.
run_async
(token, base_url, query, context=None, sleep_time=10, ssl_verify=True)[source]¶ Run a single sql query asynchronously
This executes a single sql query against the rest api asynchronously and returns a future for the result
Parameters: - token – API token from auth
- base_url – base url of Dremio instance
- query – valid sql query
- context – optional context in which to execute the query
- sleep_time – seconds to sleep between checking for finished state
- ssl_verify – verify ssl on web requests
Raise: DremioException if job failed
Raise: DremioUnauthorizedException if token is incorrect or invalid
Returns: concurrent.futures.Future for the result
Example: >>> f = run_async('abc', 'http://localhost:9047', 'select * from sys.options') >>> f.result() [{'record':'1'}, {'record':'2'}]
dremio_client.util.refresh module¶
Warning
dremio_client.util.refresh.refresh_reflections_of_one_dataset Caution using this function. It can has an critical impact on source system due to disabled reflection.
Module contents¶
-
dremio_client.util.
run
(token, base_url, query, context=None, sleep_time=10, ssl_verify=True)[source]¶ Run a single sql query
This runs a single sql query against the rest api and returns a json document of the results
Parameters: - token – API token from auth
- base_url – base url of Dremio instance
- query – valid sql query
- context – optional context in which to execute the query
- sleep_time – seconds to sleep between checking for finished state
- ssl_verify – verify ssl on web requests
Raise: DremioException if job failed
Raise: DremioUnauthorizedException if token is incorrect or invalid
Returns: json array of result rows
Example: >>> run('abc', 'http://localhost:9047', 'select * from sys.options') [{'record':'1'}, {'record':'2'}]
-
dremio_client.util.
run_async
(token, base_url, query, context=None, sleep_time=10, ssl_verify=True)[source]¶ Run a single sql query asynchronously
This executes a single sql query against the rest api asynchronously and returns a future for the result
Parameters: - token – API token from auth
- base_url – base url of Dremio instance
- query – valid sql query
- context – optional context in which to execute the query
- sleep_time – seconds to sleep between checking for finished state
- ssl_verify – verify ssl on web requests
Raise: DremioException if job failed
Raise: DremioUnauthorizedException if token is incorrect or invalid
Returns: concurrent.futures.Future for the result
Example: >>> f = run_async('abc', 'http://localhost:9047', 'select * from sys.options') >>> f.result() [{'record':'1'}, {'record':'2'}]
-
dremio_client.util.
refresh_metadata
(token, base_url, table, ssl_verify=True)[source]¶ Refresh the metadata of a given PDS
This requests a metadata refresh of a given Physical Dataset
Parameters: - token – API token from auth
- base_url – base url of Dremio instance
- table – valid dremio table name
- ssl_verify – verify ssl on web requests
Raise: DremioException if job failed
Raise: DremioUnauthorizedException if token is incorrect or invalid
Returns: None
Example: >>> refresh_metadata('abc', 'http://localhost:9047', 'source.pds')
-
dremio_client.util.
refresh_vds_reflection_by_path
(client, path=None)[source]¶ By providing a path from VDS the reflection of that vds will be refreshed Script will find which pds is responsible for the reflection and trigger the refresh based on pds
Parameters: path – list [‘space’, ‘folder’, ‘vds’]
-
dremio_client.util.
refresh_reflections_of_one_dataset
(client, path=None)[source]¶ By providing a path from dataset the reflection of that dataset will be refreshed through reenable Enebled reflections of dataset and all reflections from derived dataset will be refreshed
Parameters: path – list [‘space’, ‘folder’, ‘vds’]
Submodules¶
dremio_client.cli module¶
Console script for dremio_client.
dremio_client.dremio_client module¶
Main module.
-
class
dremio_client.dremio_client.
DremioClient
(config)[source]¶ Bases:
object
-
data
¶
-
group
(gid=None, name=None)[source]¶ return details for a group
User must supply one of gid or name. gid takes precedence if both are supplied .. note:: can only be run by admin
Parameters: - gid – group id
- name – group name
Raise: DremioUnauthorizedException if token is incorrect or invalid
Raise: DremioPermissionException user does not have permission
Raise: DremioNotFoundException group could not be found
Returns: group info as a dict
-
personal_access_token
(uid)[source]¶ return a list of personal access tokens for a user
Note
can only be run for the logged in user
Parameters: uid – user id Raise: DremioUnauthorizedException if token is incorrect or invalid Raise: DremioPermissionException user does not have permission Raise: DremioNotFoundException user could not be found Returns: personal access token list
-
reflections
¶
-
user
(uid=None, name=None)[source]¶ return details for a user
User must supply one of uid or name. uid takes precedence if both are supplied .. note:: can only be run by admin
Parameters: - uid – group id
- name – group name
Raise: DremioUnauthorizedException if token is incorrect or invalid
Raise: DremioPermissionException user does not have permission
Raise: DremioNotFoundException user could not be found
Returns: user info as a dict
-
votes
¶
-
wlm_queues
¶
-
wlm_rules
¶
-
dremio_client.dremio_simple_client module¶
-
class
dremio_client.dremio_simple_client.
SimpleClient
(config)[source]¶ Bases:
object
-
cancel_job
(jobid)[source]¶ cancel running job with job id = jobid
https://docs.dremio.com/rest-api/jobs/post-job.html
Parameters: jobid – id of the job to cancel Returns: result object :exception DremioNotFoundException no job found :exception DremioBadRequestException job already finished
-
collaboration_tag
(cid)[source]¶ returns a list of tags for catalog entity
Parameters: cid – catalog entity id Raise: DremioBadRequestException if tags can’t exist on this entity Raise: DremioUnauthorizedException if token is incorrect or invalid Raise: DremioPermissionException user does not have permission Raise: DremioNotFoundException user could not be found Returns: list of tags
-
collaboration_wiki
(cid)[source]¶ returns a wiki details for catalog entity
Parameters: cid – catalog entity id Raise: DremioUnauthorizedException if token is incorrect or invalid Raise: DremioPermissionException user does not have permission Raise: DremioNotFoundException user could not be found Returns: wiki details
-
create_queue
(json)[source]¶ create a single queue
https://docs.dremio.com/rest-api/reflections/post-wlm-queue.html
Parameters: json – json document for new queue Returns: result object
-
create_reflection
(json)[source]¶ create a single reflection
https://docs.dremio.com/rest-api/reflections/post-reflection.html
Parameters: json – json document for new reflection Returns: result object
-
delete_catalog
(cid, tag)[source]¶ remove a catalog item from Dremio
https://docs.dremio.com/rest-api/catalog/delete-catalog-id.html
Parameters: - cid – id of a catalog entity
- tag – version tag of entity
Returns: None
-
delete_personal_access_token
(uid)[source]¶ create a pat for a given user
https://docs.dremio.com/rest-api/user/delete-user-uid-token.html
Parameters: uid – id user Returns: updated catalog entity
-
delete_queue
(queueid)[source]¶ delete a single queue by id
https://docs.dremio.com/rest-api/reflections/delete-wlm-queue.html
Parameters: queueid – id of the queue to delete Returns: result object
-
delete_reflection
(reflectionid)[source]¶ delete a single reflection by id
https://docs.dremio.com/rest-api/reflections/delete-reflection.html
Parameters: reflectionid – id of the reflection to fetch Returns: result object
-
group
(gid=None, name=None)[source]¶ return details for a group
User must supply one of gid or name. gid takes precedence if both are supplied .. note:: can only be run by admin
Parameters: - gid – group id
- name – group name
Raise: DremioUnauthorizedException if token is incorrect or invalid
Raise: DremioPermissionException user does not have permission
Raise: DremioNotFoundException group could not be found
Returns: group info as a dict
-
modify_queue
(queueid, json)[source]¶ update a single queue by id
https://docs.dremio.com/rest-api/reflections/put-wlm-queue.html
Parameters: - queueid – id of the reflection to fetch
- json – json document for modified queue
Returns: result object
-
modify_reflection
(reflectionid, json)[source]¶ update a single reflection by id
https://docs.dremio.com/rest-api/reflections/put-reflection.html
Parameters: - reflectionid – id of the reflection to fetch
- json – json document for modified reflection
Returns: result object
-
modify_rules
(json)[source]¶ update wlm rules. Order of rules array is important!
The order of the rules is the order in which they will be applied. If a rule isn’t included it will be deleted new ones will be created https://docs.dremio.com/rest-api/reflections/put-wlm-rule.html
Parameters: json – json document for modified reflection Returns: result object
-
personal_access_token
(uid)[source]¶ return a list of personal access tokens for a user
Note
can only be run for the logged in user
Parameters: uid – user id Raise: DremioUnauthorizedException if token is incorrect or invalid Raise: DremioPermissionException user does not have permission Raise: DremioNotFoundException user could not be found Returns: personal access token list
-
promote_catalog
(cid, json)[source]¶ promote a catalog entity
https://docs.dremio.com/rest-api/catalog/put-catalog-id.html
Parameters: - cid – id of catalog entity
- json – json document for new catalog entity
Returns: updated catalog entity
-
query
(query, context=None, sleep_time=10, asynchronous=False)[source]¶ Run a single sql query asynchronously
This executes a single sql query against the rest api asynchronously and returns a future for the result
Parameters: - query – valid sql query
- context – optional context in which to execute the query
- sleep_time – seconds to sleep between checking for finished state
- asynchronous – boolean execute asynchronously
Raise: DremioException if job failed
Raise: DremioUnauthorizedException if token is incorrect or invalid
Returns: concurrent.futures.Future for the result
Example: >>> client = >>> f = query('select * from sys.options', asynchronous=True) >>> f.result() [{'record':'1'}, {'record':'2'}]
-
refresh_metadata
(table)[source]¶ Refresh the metadata for a given physical dataset
Parameters: table – the physical dataset to be refreshed Raise: DremioException if job failed Raise: DremioUnauthorizedException if token is incorrect or invalid Returns: None
-
refresh_pds
(pid)[source]¶ refresh a physical dataset and all its child reflections
https://docs.dremio.com/rest-api/catalog/post-catalog-id-refresh.html
Parameters: pid – id of a catalog entity Returns: None
-
refresh_reflections_of_one_dataset
(path)[source]¶ Refresh the reflection for a given dataset Refresh will disable and enable reflection. As long reflection will be reenabled all queries will be redirected to source dataset. All VDS Reflection derived from this VDS will be refreshed as well
Parameters: path – list [‘space’, ‘folder’, ‘vds’] Returns: None
-
refresh_vds_reflection_by_path
(path)[source]¶ Refresh the reflection for a given virtual dataset
Parameters: path – list [‘space’, ‘folder’, ‘vds’] Returns: None
-
set_catalog
(json)[source]¶ add a new catalog entity
https://docs.dremio.com/rest-api/catalog/post-catalog.html
Parameters: json – json document for new catalog entity Returns: new catalog entity
-
set_collaboration_tag
(cid, tags)[source]¶ returns a list of tags for catalog entity
Parameters: - cid – catalog entity id
- tags – string list
Raise: DremioBadRequestException if tags can’t exist on this entity
Raise: DremioUnauthorizedException if token is incorrect or invalid
Raise: DremioPermissionException user does not have permission
Raise: DremioNotFoundException user could not be found
Returns: list of tags
-
set_personal_access_token
(uid, label, lifetime=24)[source]¶ create a pat for a given user
https://docs.dremio.com/rest-api/user/post-user-uid-token.html
Parameters: - uid – id user
- label – label of token
- lifetime – lifetime in hours of token
Returns: updated catalog entity
-
update_catalog
(cid, json)[source]¶ update a catalog entity
https://docs.dremio.com/rest-api/catalog/put-catalog-id.html
Parameters: - cid – id of catalog entity
- json – json document for new catalog entity
Returns: updated catalog entity
-
user
(uid=None, name=None)[source]¶ return details for a user
User must supply one of uid or name. uid takes precedence if both are supplied .. note:: can only be run by admin
Parameters: - uid – group id
- name – group name
Raise: DremioUnauthorizedException if token is incorrect or invalid
Raise: DremioPermissionException user does not have permission
Raise: DremioNotFoundException user could not be found
Returns: user info as a dict
-
votes
()[source]¶ return details all reflection votes
Summarizes all votes in the system https://docs.dremio.com/rest-api/votes/get-vote.html .. note:: can only be run by admin
Raise: DremioUnauthorizedException if token is incorrect or invalid Raise: DremioPermissionException user does not have permission Returns: votes as a list of dicts
-
wlm_queues
()[source]¶ return details all workload management queues
Summarizes all workload management queues in the system https://docs.dremio.com/rest-api/wlm/get-wlm-queue.html .. note:: can only be run by admin .. note:: Enterprise only
Raise: DremioUnauthorizedException if token is incorrect or invalid Raise: DremioPermissionException user does not have permission Raise: DremioNotFoundException queues not found Returns: queues as a list of dicts
-
wlm_rules
()[source]¶ return details all workload management rules
Summarizes all workload management rules in the system https://docs.dremio.com/rest-api/wlm/get-wlm-rule.html .. note:: can only be run by admin .. note:: Enterprise only
Raise: DremioUnauthorizedException if token is incorrect or invalid Raise: DremioPermissionException user does not have permission Raise: DremioNotFoundException ruleset is not found Returns: rules as a list of dicts
-
dremio_client.error module¶
-
exception
dremio_client.error.
DremioBadRequestException
(msg, original_exception, response=None)[source]¶
-
exception
dremio_client.error.
DremioException
(msg, original_exception, response=None)[source]¶ Bases:
Exception
base dremio exception
-
exception
dremio_client.error.
DremioNotFoundException
(msg, original_exception, response=None)[source]¶
Module contents¶
-
dremio_client.
init
(config_dir=None, simple_client=False, config_dict=None)[source]¶ create a new Dremio client object
This returns a rich client by default. This client abstracts the Dremio catalog into a a set of Python objects and enables <Tab> completion where possible. It also supports fetching datasets via flight or odbc
The simple client simply wraps the Dremio REST endpoints an returns
dict
objectsParameters: - config_dir – optional directory to look for config in
- simple_client – return the ‘simple’ client.
- config_dict – dictionary of extra config arguments
Returns: either a simple or rich client
Example: >>> client = init('/my/config/dir')
-
dremio_client.
catalog
(token, base_url, ssl_verify=True)[source]¶ https://docs.dremio.com/rest-api/catalog/get-catalog.html populate the root dremio catalog
Parameters: - token – auth token from previous login attempt
- base_url – base Dremio url
- ssl_verify – ignore ssl errors if False
Returns: json of root resource
-
dremio_client.
catalog_item
(token, base_url, cid=None, path=None, ssl_verify=True)[source]¶ fetch a specific catalog item by id or by path
https://docs.dremio.com/rest-api/catalog/get-catalog-id.html https://docs.dremio.com/rest-api/catalog/get-catalog-path.html
Parameters: - token – auth token from previous login attempt
- base_url – base Dremio url
- cid – unique dremio id for resource
- path – list [‘space’, ‘folder’, ‘vds’]
- ssl_verify – ignore ssl errors if False
Returns: json of resource
-
dremio_client.
sql
(token, base_url, query, context=None, ssl_verify=True)[source]¶ submit job w/ given sql
https://docs.dremio.com/rest-api/sql/post-sql.html
Parameters: - token – auth token
- base_url – base Dremio url
- query – sql query
- context – optional dremio context
- ssl_verify – ignore ssl errors if False
Returns: job id json object
-
dremio_client.
job_status
(token, base_url, job_id, ssl_verify=True)[source]¶ fetch job status
https://docs.dremio.com/rest-api/jobs/get-job.html
Parameters: - token – auth token
- base_url – sql query
- job_id – job id (as returned by sql)
- ssl_verify – ignore ssl errors if False
Returns: status object
-
dremio_client.
job_results
(token, base_url, job_id, offset=0, limit=100, ssl_verify=True)[source]¶ fetch job results
https://docs.dremio.com/rest-api/jobs/get-job.html
Parameters: - token – auth token
- base_url – sql query
- job_id – job id (as returned by sql)
- offset – offset of result set to return
- limit – number of results to return (max 500)
- ssl_verify – ignore ssl errors if False
Returns: result object
Contributing¶
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
You can contribute in many ways:
Types of Contributions¶
Report Bugs¶
Report bugs at https://github.com/rymurr/dremio_client/issues.
If you are reporting a bug, please include:
- Your operating system name and version.
- Any details about your local setup that might be helpful in troubleshooting.
- Detailed steps to reproduce the bug.
Fix Bugs¶
Look through the GitHub issues for bugs. Anything tagged with “bug” and “help wanted” is open to whoever wants to implement it.
Implement Features¶
Look through the GitHub issues for features. Anything tagged with “enhancement” and “help wanted” is open to whoever wants to implement it.
Write Documentation¶
Dremio client could always use more documentation, whether as part of the official Dremio client docs, in docstrings, or even on the web in blog posts, articles, and such.
Submit Feedback¶
The best way to send feedback is to file an issue at https://github.com/rymurr/dremio_client/issues.
If you are proposing a feature:
- Explain in detail how it would work.
- Keep the scope as narrow as possible, to make it easier to implement.
- Remember that this is a volunteer-driven project, and that contributions are welcome :)
Get Started!¶
Ready to contribute? Here’s how to set up dremio_client for local development.
Fork the dremio_client repo on GitHub.
Clone your fork locally:
$ git clone git@github.com:your_name_here/dremio_client.git
Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:
$ mkvirtualenv dremio_client $ cd dremio_client/ $ python setup.py develop
Create a branch for local development:
$ git checkout -b name-of-your-bugfix-or-feature
Now you can make your changes locally.
When you’re done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:
$ flake8 dremio_client tests $ python setup.py test or py.test $ tox
To get flake8 and tox, just pip install them into your virtualenv.
Commit your changes and push your branch to GitHub:
$ git add . $ git commit -m "Your detailed description of your changes." $ git push origin name-of-your-bugfix-or-feature
Submit a pull request through the GitHub website.
Pull Request Guidelines¶
Before you submit a pull request, check that it meets these guidelines:
- The pull request should include tests.
- If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst.
- The pull request should work for Python 2.7, 3.4, 3.5 and 3.6, and for PyPy. Check https://travis-ci.org/rymurr/dremio_client/pull_requests and make sure that the tests pass for all supported Python versions.
Deploying¶
A reminder for the maintainers on how to deploy. Make sure all your changes are committed (including an entry in HISTORY.rst). Then run:
$ bumpversion patch # possible: major / minor / patch
$ git push
$ git push --tags
Travis will then deploy to PyPI if tests pass.
Credits¶
Development Lead¶
- Ryan Murray <rymurr@gmail.com>
Contributors¶
- markfjohnson
- insatomcat
- narendrans
- viktordremio
History¶
0.1.0 (2019-07-04)¶
- First code, unreleased.
0.2.4 (2019-08-13)¶
- Alpha quality release with partial implementation of features. First PyPI release.
0.3.0 (2019-08-14)¶
- Beta quality release for GET based endpoints
0.5.0 (2019-10-30)¶
- Most endpoint supported
- flight support with tls & auth
- minor bugfixes
0.6.3 (2020-01-29)¶
- All endpoints supported
- lots of bugfixes
- utilities for building spaces/folders vds
- removed recordclass library in favor of attrs
0.8.4 (2020-01-29)¶
- history re-written
0.8.8 (2020-02-19)¶
- minor bug fixes
0.8.9 (2020-02-19)¶
- ensure use correct name for Spaces
0.8.11 (2020-03-09)¶
- bug fixes when creating sources and folders
0.9.2 (2020-03-17)¶
- add promote endpoint
- update versions from pyup
0.10.1 (2020-03-19)¶
- fix ssl verify flag in cli
0.11.1 (2020-04-09)¶
- a number of bug fixes and improvements from the community
0.12.0 (2020-04-22)¶
- add graph endpoint and cli flag
- add more detailed exception handling
0.12.1 (2020-05-04)¶
- few bug fixes and API extensions
0.13.0 (2020-05-21)¶
- add version flag
- upgrades and additions to some commands
0.13.1 (2020-05-21)¶
- simplify delete cli command
0.13.2 (2020-05-22)¶
- bugfixes