Skip to content

Commit 34c4a56

Browse files
authored
Revert "Refactor python example (dremio-hub#41)" (dremio-hub#49)
This reverts commit 7da259a.
1 parent 1a028e6 commit 34c4a56

18 files changed

Lines changed: 443 additions & 734 deletions

File tree

.gitignore

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,3 @@ java/.idea
22
java/target
33
java/*.iml
44
.idea
5-
*.env
6-
**/__pycache__
7-
**/*.egg-info
8-
**/build
9-
**/dist
10-
**/*.pytest_cache

QUICKSTART.md

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,41 @@
1212
## 1 Query data using Flight clients
1313
This process is the same if you launched the Dremio locally or via docker.
1414

15-
### 1.1 Query your datasets with Python
15+
### 1.1 Query your datasets with arrow flight client in python
16+
17+
This lightweight Python client application connects to the Dremio Arrow Flight server endpoint. It requires the username and password for authentication. Developers can use admin or regular user credentials for authentication. Any datasets in Dremio that are accessible by the provided Dremio user can be queried. By default, the hostname is `localhost` and the port is `32010`. Developers can change these default settings by providing the hostname and port as arguments when running the client. Moreover, the tls option can be provided to establish an encrypted connection.
18+
19+
> Note: Trusted certificates must be provided when the tls option is enabled.
1620
>
17-
#### 1.1.1 Getting Started
21+
#### 1.1.1 Prerequisites
22+
23+
- Python 3
1824

19-
1. Install [Python 3](https://www.python.org/downloads/)
20-
2. Download and install the [dremio-flight-endpoint whl file](https://github.com/dremio-hub/arrow-flight-client-examples/releases)
21-
- `python -m pip install <PATH TO WHEEL>`
22-
3. Copy the contents of arrow-flight-client-examples/python/example.py into your own python file.
23-
4. Run your pthon file with a local instance of Dremio:
24-
- `python3 example.py -username <USER> -password <password> -query 'SELECT 1'`
25+
#### 1.1.2 Instructions on using this Python sample application
2526

27+
- This application also requires `pyarrow` and `pandas`. Consider one of the dependency installation methods below. We recommend using `conda` for its ease of use.
28+
- Install dependencies using `conda`
29+
- `conda install -c conda-forge --file requirements.txt`
30+
- Alternatively, install dependencies using `pip`
31+
- `pip3 install -r requirements.txt`
32+
- Run the Python sample application:
33+
- `python3 example.py -host '<DREMIO_HOST>' -user '<DREMIO_USERNAME>' -pass '<DREMIO_PASSWORD>'`
34+
35+
#### 1.1.3 Usage
36+
```
37+
example.py [-h] [-host HOSTNAME] [-port FLIGHTPORT] -user USERNAME -pass PASSWORD [-query SQLQUERY] [-tls] [-certs TRUSTEDCERTIFICATES]
38+
39+
optional arguments:
40+
-h, --help show this help message and exit
41+
-host HOSTNAME, --hostname HOSTNAME Dremio co-ordinator hostname
42+
-port FLIGHTPORT, --flightPort FLIGHTPORT Dremio flight server port
43+
-user USERNAME, --username USERNAME Dremio username
44+
-pass PASSWORD, --password PASSWORD Dremio password
45+
-query SQLQUERY, --sqlquery SQLQUERY SQL query to test
46+
-tls, --tls Enable encrypted connection
47+
-certs TRUSTEDCERTIFICATES, --trustedCertificates TRUSTEDCERTIFICATES Path to trusted certificates for encrypted connection
48+
```
49+
---
2650

2751
### 1.2 Query your dataset with arrow flight client in java
2852
This lightweight Java client application connects to the Dremio Arrow Flight server endpoint. It requires the username and password for authentication. Developers can use admin or regular user credentials for authentication. Any datasets in Dremio that are accessible by the provided Dremio user can be queried. By default, the hostname is `localhost` and the port is `32010`. Developers can change these default settings by providing the hostname and port as arguments when running the client. Moreover, the tls option can be provided to establish an encrypted connection.

python/README.md

Lines changed: 60 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,23 @@
11
# Python Arrow Flight Client Application Example
2+
![Build Status](https://github.com/dremio-hub/arrow-flight-client-examples/workflows/python-build/badge.svg)
23

3-
## Getting Started
4-
1. Install [Python 3](https://www.python.org/downloads/)
5-
2. Download and install the [dremio-flight-endpoint whl file](https://github.com/dremio-hub/arrow-flight-client-examples/releases)
6-
- `python -m pip install <PATH TO WHEEL>`
7-
3. Copy the contents of arrow-flight-client-examples/python/example.py into your own python file.
8-
4. Run your pthon file with a local instance of Dremio:
9-
- `python3 example.py -username <USER> -password <password> -query 'SELECT 1'`
10-
11-
## How to connect to Dremio Cloud
12-
13-
Get started with your first query to Dremio Cloud.
14-
15-
* The following example requires you to create a [Personal Access Token](https://docs.dremio.com/cloud/security/authentication/personal-access-token/) in Dremio. Replace ```<INSERT PAT HERE>``` in the example below with your actual PAT token.
16-
* You may need to wait for a Dremio engine to start up or start it manually if no Dremio engine for your Organization is running.
17-
18-
This example queries the Dremio Sample dataset ```NYC-taxi-trips``` and returns the first 10 values.
19-
20-
```python3 example.py -host data.dremio.cloud -port 443 -pat '<INSERT PAT HERE>' -tls -query 'SELECT * FROM Samples."samples.dremio.com"."NYC-taxi-trips" limit 10'```
21-
22-
You have now run your first Flight query on Dremio Cloud!
4+
This lightweight Python client application connects to the Dremio Arrow Flight server endpoint. Developers can use token based or regular user credentials (username/password) for authentication. Please note username/password is not supported for Dremio Cloud. Any datasets in Dremio that are accessible by the provided Dremio user can be queried. By default, the hostname is `localhost` and the port is `32010`. Developers can change these default settings by providing the hostname and port as arguments when running the client.
5+
Moreover, the tls option can be provided to establish an encrypted connection.
236

24-
## Configuration Options
7+
### Instructions on using this Python sample application
8+
- Install and setup Python3 as `pyarrow` requires Python3
9+
- This application also requires `pyarrow` and `pandas`. Consider one of the dependency installation methods below. We recommend using `conda` for its ease of use.
10+
- Install dependencies using `conda`
11+
- `conda install -c conda-forge --file requirements.txt`
12+
- Alternatively, install dependencies using `pip`
13+
- `pip3 install -r requirements.txt`
14+
- Run the Python sample application with a local instance of Dremio (with default parameters):
15+
- `python3 example.py -query 'SELECT 1'`
2516

2617
```
27-
usage: example.py [-h] [-host HOSTNAME] [-port PORT] -user USERNAME -pass PASSWORD -pat TOKEN -query QUERY [-tls] [-dcv DISABLE_CERTIFICATE_VERIFICATION]
28-
[-path_to_certs PATH_TO_CERTS] [-sp [SESSION_PROPERTIES ...]] [-engine ENGINE]
18+
usage: example.py [-h] [-host HOSTNAME] [-port PORT] [-user USERNAME] [-pass PASSWORD]
19+
[-pat, -authToken PAT_OR_AUTH_TOKEN] [-query QUERY] [-tls] [-dsv DISABLE_SERVER_VERIFICATION]
20+
[-certs TRUSTED_CERTIFICATES] [-sessionProperties [SESSION_PROPERTIES ...]] [-engine ENGINE]
2921
3022
optional arguments:
3123
-h, --help show this help message and exit
@@ -34,27 +26,57 @@ optional arguments:
3426
-port PORT, --flightport PORT
3527
Dremio flight server port. Defaults to 32010.
3628
-user USERNAME, --username USERNAME
37-
Dremio username. Not required when connecting to Dremio Cloud
29+
Dremio username. Defaults to "dremio".
3830
-pass PASSWORD, --password PASSWORD
39-
Dremio password. Not required when connecting to Dremio Cloud
40-
-pat TOKEN, --token TOKEN
31+
Dremio password. Defaults to "dremio123".
32+
-pat PAT_OR_AUTH_TOKEN, --personalAccessToken PAT_OR_AUTH_TOKEN, -authToken PAT_OR_AUTH_TOKEN, --authToken PAT_OR_AUTH_TOKEN
4133
Either a Personal Access Token or an OAuth2 Token.
4234
-query QUERY, --sqlQuery QUERY
43-
SQL query to test. Must be enclosed in single quotes. If single quotes are already present within the query, change those to double quotes and
44-
enclose entire query in single quotes.
35+
SQL query to test.
4536
-tls, --tls Enable encrypted connection. Defaults to False.
46-
-dcv DISABLE_CERTIFICATE_VERIFICATION, --disableCertificateVerification DISABLE_CERTIFICATE_VERIFICATION
47-
Disables TLS server verification. Defaults to False.
48-
-path_to_certs PATH_TO_CERTS, --trustedCertificates PATH_TO_CERTS
37+
-dsv DISABLE_SERVER_VERIFICATION, --disableServerVerification DISABLE_SERVER_VERIFICATION
38+
Disable TLS server verification. Defaults to False.
39+
-certs TRUSTED_CERTIFICATES, --trustedCertificates TRUSTED_CERTIFICATES
4940
Path to trusted certificates for encrypted connection. Defaults to system certificates.
50-
-sp [SESSION_PROPERTIES ...], --sessionProperty [SESSION_PROPERTIES ...]
51-
Key value pairs of SessionProperty, example: -sp schema='Samples."samples.dremio.com"' -sp key=value
41+
-sessionProperties [SESSION_PROPERTIES ...], --sessionProperties [SESSION_PROPERTIES ...]
42+
Key value pairs of SessionProperty, example: -sessionProperties schema='Samples."samples.dremio.com"'
5243
-engine ENGINE, --engine ENGINE
53-
The specific engine to run against. Only applicable to Dremio Cloud.
44+
The specific engine to run against.
45+
```
5446

47+
### Getting Started
48+
49+
Get started with your first query to Dremio Cloud.
50+
51+
* The following example requires you to create a [Personal Access Token](https://docs.dremio.com/software/security/personal-access-tokens/) in Dremio. Replace ```<INSERT PAT HERE>``` in the example below with your actual PAT token.
52+
* You may need to wait for a Dremio engine to start up if no Dremio engine for your Organization is running.
53+
54+
This example queries the Dremio Sample dataset ```NYC-taxi-trips``` and returns the first 10 values.
55+
56+
```python3 example.py -host data.dremio.cloud -port 443 -pat '<INSERT PAT HERE>' -tls -query 'SELECT * FROM Samples."samples.dremio.com"."NYC-taxi-trips" limit 10'```
57+
58+
Running the command will return the following.
59+
60+
``` [INFO] Enabling TLS connection
61+
[INFO] Trusted certificates provided
62+
[INFO] Authentication skipped until first request
63+
[INFO] Query: SELECT * FROM Samples."samples.dremio.com"."NYC-taxi-trips" limit 10
64+
[INFO] GetSchema was successful
65+
[INFO] Schema: <pyarrow._flight.SchemaResult object at 0x7febe2944610>
66+
[INFO] GetFlightInfo was successful
67+
[INFO] Ticket: <Ticket b'\nDSELECT * FROM Samples."samples.dremio.com"."NYC-taxi-trips" limit 10\x12^\n\\\nDSELECT * FROM Samples."samples.dremio.com"."NYC-taxi-trips" limit 10\x10(\x1a\x12\t\x8a\x883#\x12\xd1\xd9\x1d\x11\x00\xb3\xbbC\xdb\xd9J\t'>
68+
[INFO] Reading query results from Dremio
69+
pickup_datetime passenger_count trip_distance_mi fare_amount tip_amount total_amount
70+
0 2013-05-27 19:15:00 1 1.26 7.5 0.00 8.00
71+
1 2013-05-31 16:40:00 1 0.73 5.0 1.20 7.70
72+
2 2013-05-27 19:03:00 2 9.23 27.5 5.00 38.33
73+
3 2013-05-31 16:24:00 1 2.27 12.0 0.00 13.50
74+
4 2013-05-27 19:17:00 1 0.71 5.0 0.00 5.50
75+
5 2013-05-27 19:11:00 1 2.52 10.5 3.15 14.15
76+
6 2013-05-31 16:41:00 5 1.01 6.0 1.10 8.60
77+
7 2013-05-31 16:37:00 1 1.25 8.5 0.00 10.00
78+
8 2013-05-31 16:39:00 1 2.04 10.0 1.50 13.00
79+
9 2013-05-27 19:02:00 1 11.73 32.5 8.12 41.12
5580
```
5681

57-
## Description
58-
![Build Status](https://github.com/dremio-hub/arrow-flight-client-examples/workflows/python-build/badge.svg)
59-
This lightweight Python client application connects to the Dremio Arrow Flight server endpoint. Developers can use token based or regular user credentials (username/password) for authentication. Please note username/password is not supported for Dremio Cloud. Any datasets in Dremio that are accessible by the provided Dremio user can be queried. By default, the hostname is `localhost` and the port is `32010`. Developers can change these default settings by providing the hostname and port as arguments when running the client.
60-
Moreover, the tls option can be provided to establish an encrypted connection.
82+
You have now run your first Flight query on Dremio Cloud!

python/dremio/__init__.py

Whitespace-only changes.

python/dremio/arguments/__init__.py

Whitespace-only changes.

python/dremio/arguments/parse.py

Lines changed: 0 additions & 128 deletions
This file was deleted.

python/dremio/flight/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)