Skip to content

Commit c603d7f

Browse files
committed
Merge branch 'main' into jg-proxy
2 parents 61a8ed5 + a6212b6 commit c603d7f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2645
-1608
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
# the repo. Unless a later match takes precedence, these
33
# users will be requested for review when someone opens a
44
# pull request.
5-
* @susodapop @arikfr @yunbodeng-db @andrefurlan-db
5+
* @rcypher-databricks @arikfr @yunbodeng-db @andrefurlan-db @jackyhu-db @benc-db @kravets-levko

.github/workflows/code-quality-checks.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Code Quality Checks
2-
on:
2+
on:
33
push:
44
branches:
55
- main
@@ -157,7 +157,7 @@ jobs:
157157
- name: Install library
158158
run: poetry install --no-interaction
159159
#----------------------------------------------
160-
# black the code
160+
# mypy the code
161161
#----------------------------------------------
162162
- name: Mypy
163163
run: poetry run mypy --install-types --non-interactive src

.github/workflows/integration.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Integration Tests
2+
on:
3+
push:
4+
paths-ignore:
5+
- "**.MD"
6+
- "**.md"
7+
8+
jobs:
9+
run-e2e-tests:
10+
runs-on: ubuntu-latest
11+
environment: azure-prod
12+
env:
13+
DATABRICKS_SERVER_HOSTNAME: ${{ secrets.DATABRICKS_HOST }}
14+
DATABRICKS_HTTP_PATH: ${{ secrets.TEST_PECO_WAREHOUSE_HTTP_PATH }}
15+
DATABRICKS_TOKEN: ${{ secrets.DATABRICKS_TOKEN }}
16+
DATABRICKS_CATALOG: peco
17+
DATABRICKS_USER: ${{ secrets.TEST_PECO_SP_ID }}
18+
steps:
19+
#----------------------------------------------
20+
# check-out repo and set-up python
21+
#----------------------------------------------
22+
- name: Check out repository
23+
uses: actions/checkout@v3
24+
- name: Set up python
25+
id: setup-python
26+
uses: actions/setup-python@v4
27+
with:
28+
python-version: "3.10"
29+
#----------------------------------------------
30+
# ----- install & configure poetry -----
31+
#----------------------------------------------
32+
- name: Install Poetry
33+
uses: snok/install-poetry@v1
34+
with:
35+
virtualenvs-create: true
36+
virtualenvs-in-project: true
37+
installer-parallel: true
38+
39+
#----------------------------------------------
40+
# load cached venv if cache exists
41+
#----------------------------------------------
42+
- name: Load cached venv
43+
id: cached-poetry-dependencies
44+
uses: actions/cache@v2
45+
with:
46+
path: .venv
47+
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ github.event.repository.name }}-${{ hashFiles('**/poetry.lock') }}
48+
#----------------------------------------------
49+
# install dependencies if cache does not exist
50+
#----------------------------------------------
51+
- name: Install dependencies
52+
run: poetry install --no-interaction --all-extras
53+
#----------------------------------------------
54+
# run test suite
55+
#----------------------------------------------
56+
- name: Run e2e tests
57+
run: poetry run python -m pytest tests/e2e
58+
- name: Run SQL Alchemy tests
59+
run: poetry run python -m pytest src/databricks/sqlalchemy/test_local

CHANGELOG.md

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,38 @@
11
# Release History
22

3+
# (Unreleased)
4+
5+
- Fix: our logger would raise an uncaught exception under certain oauth error conditions
6+
7+
# 3.1.2 (2024-04-18)
8+
9+
- Remove broken cookie code (#379)
10+
- Small typing fixes (#382, #384 thanks @wyattscarpenter)
11+
12+
# 3.1.1 (2024-03-19)
13+
14+
- Don't retry requests that fail with code 403 (#373)
15+
- Assume a default retry-after for 429/503 (#371)
16+
- Fix boolean literals (#357)
17+
18+
# 3.1.0 (2024-02-16)
19+
20+
- Revert retry-after behavior to be exponential backoff (#349)
21+
- Support Databricks OAuth on Azure (#351)
22+
- Support Databricks OAuth on GCP (#338)
23+
24+
# 3.0.3 (2024-02-02)
25+
26+
- Revised docstrings and examples for OAuth (#339)
27+
- Redact the URL query parameters from the urllib3.connectionpool logs (#341)
28+
29+
# 3.0.2 (2024-01-25)
30+
31+
- SQLAlchemy dialect now supports table and column comments (thanks @cbornet!)
32+
- Fix: SQLAlchemy dialect now correctly reflects TINYINT types (thanks @TimTheinAtTabs!)
33+
- Fix: `server_hostname` URIs that included `https://` would raise an exception
34+
- Other: pinned to `pandas<=2.1` and `urllib3>=1.26` to avoid runtime errors in dbt-databricks (#330)
35+
336
## 3.0.1 (2023-12-01)
437

538
- Other: updated docstring comment about default parameterization approach (#287)
@@ -37,15 +70,15 @@
3770

3871
## 2.9.2 (2023-08-17)
3972

40-
__Note: this release was yanked from Pypi on 13 September 2023 due to compatibility issues with environments where `urllib3<=2.0.0` were installed. The log changes are incorporated into version 2.9.3 and greater.__
73+
**Note: this release was yanked from Pypi on 13 September 2023 due to compatibility issues with environments where `urllib3<=2.0.0` were installed. The log changes are incorporated into version 2.9.3 and greater.**
4174

4275
- Other: Add `examples/v3_retries_query_execute.py` (#199)
4376
- Other: suppress log message when `_enable_v3_retries` is not `True` (#199)
4477
- Other: make this connector backwards compatible with `urllib3>=1.0.0` (#197)
4578

4679
## 2.9.1 (2023-08-11)
4780

48-
__Note: this release was yanked from Pypi on 13 September 2023 due to compatibility issues with environments where `urllib3<=2.0.0` were installed.__
81+
**Note: this release was yanked from Pypi on 13 September 2023 due to compatibility issues with environments where `urllib3<=2.0.0` were installed.**
4982

5083
- Other: Explicitly pin urllib3 to ^2.0.0 (#191)
5184

@@ -98,6 +131,7 @@ __Note: this release was yanked from Pypi on 13 September 2023 due to compatibil
98131
- Other: Relax sqlalchemy required version as it was unecessarily strict.
99132

100133
## 2.5.0 (2023-04-14)
134+
101135
- Add support for External Auth providers
102136
- Fix: Python HTTP proxies were broken
103137
- Other: All Thrift requests that timeout during connection will be automatically retried
@@ -119,8 +153,8 @@ __Note: this release was yanked from Pypi on 13 September 2023 due to compatibil
119153

120154
## 2.2.2 (2023-01-03)
121155

122-
- Support custom oauth client id and redirect port
123-
- Fix: Add none check on _oauth_persistence in DatabricksOAuthProvider
156+
- Support custom oauth client id and redirect port
157+
- Fix: Add none check on \_oauth_persistence in DatabricksOAuthProvider
124158

125159
## 2.2.1 (2022-11-29)
126160

@@ -152,57 +186,71 @@ Huge thanks to @dbaxa for contributing this change!
152186

153187
- Add retry logic for `GetOperationStatus` requests that fail with an `OSError`
154188
- Reorganised code to use Poetry for dependency management.
189+
155190
## 2.0.2 (2022-05-04)
191+
156192
- Better exception handling in automatic connection close
157193

158194
## 2.0.1 (2022-04-21)
195+
159196
- Fixed Pandas dependency in setup.cfg to be >= 1.2.0
160197

161198
## 2.0.0 (2022-04-19)
199+
162200
- Initial stable release of V2
163-
- Added better support for complex types, so that in Databricks runtime 10.3+, Arrays, Maps and Structs will get
201+
- Added better support for complex types, so that in Databricks runtime 10.3+, Arrays, Maps and Structs will get
164202
deserialized as lists, lists of tuples and dicts, respectively.
165203
- Changed the name of the metadata arg to http_headers
166204

167205
## 2.0.b2 (2022-04-04)
206+
168207
- Change import of collections.Iterable to collections.abc.Iterable to make the library compatible with Python 3.10
169208
- Fixed bug with .tables method so that .tables works as expected with Unity-Catalog enabled endpoints
170209

171210
## 2.0.0b1 (2022-03-04)
211+
172212
- Fix packaging issue (dependencies were not being installed properly)
173213
- Fetching timestamp results will now return aware instead of naive timestamps
174214
- The client will now default to using simplified error messages
175215

176216
## 2.0.0b (2022-02-08)
217+
177218
- Initial beta release of V2. V2 is an internal re-write of large parts of the connector to use Databricks edge features. All public APIs from V1 remain.
178-
- Added Unity Catalog support (pass catalog and / or schema key word args to the .connect method to select initial schema and catalog)
219+
- Added Unity Catalog support (pass catalog and / or schema key word args to the .connect method to select initial schema and catalog)
179220

180221
---
181222

182223
**Note**: The code for versions prior to `v2.0.0b` is not contained in this repository. The below entries are included for reference only.
183224

184225
---
226+
185227
## 1.0.0 (2022-01-20)
228+
186229
- Add operations for retrieving metadata
187230
- Add the ability to access columns by name on result rows
188231
- Add the ability to provide configuration settings on connect
189232

190233
## 0.9.4 (2022-01-10)
234+
191235
- Improved logging and error messages.
192236

193237
## 0.9.3 (2021-12-08)
238+
194239
- Add retries for 429 and 503 HTTP responses.
195240

196241
## 0.9.2 (2021-12-02)
242+
197243
- (Bug fix) Increased Thrift requirement from 0.10.0 to 0.13.0 as 0.10.0 was in fact incompatible
198244
- (Bug fix) Fixed error message after query execution failed -SQLSTATE and Error message were misplaced
199245

200246
## 0.9.1 (2021-09-01)
247+
201248
- Public Preview release, Experimental tag removed
202249
- minor updates in internal build/packaging
203250
- no functional changes
204251

205252
## 0.9.0 (2021-08-04)
253+
206254
- initial (Experimental) release of pyhive-forked connector
207255
- Python DBAPI 2.0 (PEP-0249), thrift based
208256
- see docs for more info: https://docs.databricks.com/dev-tools/python-sql-connector.html

conftest.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import os
2+
import pytest
3+
4+
5+
@pytest.fixture(scope="session")
6+
def host():
7+
return os.getenv("DATABRICKS_SERVER_HOSTNAME")
8+
9+
10+
@pytest.fixture(scope="session")
11+
def http_path():
12+
return os.getenv("DATABRICKS_HTTP_PATH")
13+
14+
15+
@pytest.fixture(scope="session")
16+
def access_token():
17+
return os.getenv("DATABRICKS_TOKEN")
18+
19+
20+
@pytest.fixture(scope="session")
21+
def ingestion_user():
22+
return os.getenv("DATABRICKS_USER")
23+
24+
25+
@pytest.fixture(scope="session")
26+
def catalog():
27+
return os.getenv("DATABRICKS_CATALOG")
28+
29+
30+
@pytest.fixture(scope="session")
31+
def schema():
32+
return os.getenv("DATABRICKS_SCHEMA", "default")
33+
34+
35+
@pytest.fixture(scope="session", autouse=True)
36+
def connection_details(host, http_path, access_token, ingestion_user, catalog, schema):
37+
return {
38+
"host": host,
39+
"http_path": http_path,
40+
"access_token": access_token,
41+
"ingestion_user": ingestion_user,
42+
"catalog": catalog,
43+
"schema": schema,
44+
}

examples/interactive_oauth.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,16 @@
11
from databricks import sql
22
import os
33

4-
"""Bring Your Own Identity Provider with fined grained OAuth scopes is currently public preview on
5-
Databricks in AWS. databricks-sql-connector supports user to machine OAuth login which means the
6-
end user has to be present to login in a browser which will be popped up by the Python process. You
7-
must enable OAuth in your Databricks account to run this example. More information on how to enable
8-
OAuth in your Databricks Account in AWS can be found here:
9-
10-
https://docs.databricks.com/administration-guide/account-settings-e2/single-sign-on.html
4+
"""databricks-sql-connector supports user to machine OAuth login which means the
5+
end user has to be present to login in a browser which will be popped up by the Python process.
116
127
Pre-requisites:
13-
- You have a Databricks account in AWS.
14-
- You have configured OAuth in Databricks account in AWS using the link above.
158
- You have installed a browser (Chrome, Firefox, Safari, Internet Explorer, etc) that will be
169
accessible on the machine for performing OAuth login.
1710
1811
This code does not persist the auth token. Hence after the Python process terminates the
1912
end user will have to login again. See examples/persistent_oauth.py to learn about persisting the
2013
token across script executions.
21-
22-
Bring Your Own Identity Provider is in public preview. The API may change prior to becoming GA.
23-
You can monitor these two links to find out when it will become generally available:
24-
25-
1. https://docs.databricks.com/administration-guide/account-settings-e2/single-sign-on.html
26-
2. https://docs.databricks.com/dev-tools/python-sql-connector.html
2714
"""
2815

2916
with sql.connect(server_hostname = os.getenv("DATABRICKS_SERVER_HOSTNAME"),

examples/persistent_oauth.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
1-
"""Bring Your Own Identity Provider with fined grained OAuth scopes is currently public preview on
2-
Databricks in AWS. databricks-sql-connector supports user to machine OAuth login which means the
3-
end user has to be present to login in a browser which will be popped up by the Python process. You
4-
must enable OAuth in your Databricks account to run this example. More information on how to enable
5-
OAuth in your Databricks Account in AWS can be found here:
6-
7-
https://docs.databricks.com/administration-guide/account-settings-e2/single-sign-on.html
1+
"""databricks-sql-connector supports user to machine OAuth login which means the
2+
end user has to be present to login in a browser which will be popped up by the Python process.
83
94
Pre-requisites:
10-
- You have a Databricks account in AWS.
11-
- You have configured OAuth in Databricks account in AWS using the link above.
125
- You have installed a browser (Chrome, Firefox, Safari, Internet Explorer, etc) that will be
136
accessible on the machine for performing OAuth login.
147
@@ -18,12 +11,6 @@
1811
shows which methods you may implement.
1912
2013
For this example, the DevOnlyFilePersistence class is provided. Do not use this in production.
21-
22-
Bring Your Own Identity Provider is in public preview. The API may change prior to becoming GA.
23-
You can monitor these two links to find out when it will become generally available:
24-
25-
1. https://docs.databricks.com/administration-guide/account-settings-e2/single-sign-on.html
26-
2. https://docs.databricks.com/dev-tools/python-sql-connector.html
2714
"""
2815

2916
import os

0 commit comments

Comments
 (0)