Skip to content

Commit 40d17c7

Browse files
committed
Merge branch 'main' into fix-oauth-log
2 parents eadfd5c + 6949aba commit 40d17c7

Some content is hidden

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

69 files changed

+5587
-2931
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: 5 additions & 8 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
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
python-version: [3.7, 3.8, 3.9, "3.10", "3.11"]
14+
python-version: [3.8, 3.9, "3.10", "3.11"]
1515
steps:
1616
#----------------------------------------------
1717
# check-out repo and set-up python
@@ -29,7 +29,6 @@ jobs:
2929
- name: Install Poetry
3030
uses: snok/install-poetry@v1
3131
with:
32-
version: ${{ matrix.python-version == 3.7 && '1.5.1' || 'latest' }}
3332
virtualenvs-create: true
3433
virtualenvs-in-project: true
3534
installer-parallel: true
@@ -63,7 +62,7 @@ jobs:
6362
runs-on: ubuntu-latest
6463
strategy:
6564
matrix:
66-
python-version: [3.7, 3.8, 3.9, "3.10"]
65+
python-version: [3.8, 3.9, "3.10"]
6766
steps:
6867
#----------------------------------------------
6968
# check-out repo and set-up python
@@ -81,7 +80,6 @@ jobs:
8180
- name: Install Poetry
8281
uses: snok/install-poetry@v1
8382
with:
84-
version: ${{ matrix.python-version == 3.7 && '1.5.1' || 'latest' }}
8583
virtualenvs-create: true
8684
virtualenvs-in-project: true
8785
installer-parallel: true
@@ -116,7 +114,7 @@ jobs:
116114
runs-on: ubuntu-latest
117115
strategy:
118116
matrix:
119-
python-version: [3.7, 3.8, 3.9, "3.10"]
117+
python-version: [3.8, 3.9, "3.10"]
120118
steps:
121119
#----------------------------------------------
122120
# check-out repo and set-up python
@@ -134,7 +132,6 @@ jobs:
134132
- name: Install Poetry
135133
uses: snok/install-poetry@v1
136134
with:
137-
version: ${{ matrix.python-version == 3.7 && '1.5.1' || 'latest' }}
138135
virtualenvs-create: true
139136
virtualenvs-in-project: true
140137
installer-parallel: true
@@ -160,7 +157,7 @@ jobs:
160157
- name: Install library
161158
run: poetry install --no-interaction
162159
#----------------------------------------------
163-
# black the code
160+
# mypy the code
164161
#----------------------------------------------
165162
- name: Mypy
166163
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: 78 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,82 @@
11
# Release History
22

3-
## 2.9.4 (Unreleased)
3+
# (Unreleased)
44

5-
- Other: Introduce SQLAlchemy dialect compliance test suite and enumerate all excluded tests
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+
36+
## 3.0.1 (2023-12-01)
37+
38+
- Other: updated docstring comment about default parameterization approach (#287)
39+
- Other: added tests for reading complex types and revised docstrings and type hints (#293)
40+
- Fix: SQLAlchemy dialect raised DeprecationWarning due to `dbapi` classmethod (#294)
41+
- Fix: SQLAlchemy dialect could not reflect TIMESTAMP_NTZ columns (#296)
42+
43+
## 3.0.0 (2023-11-17)
44+
45+
- Remove support for Python 3.7
46+
- Add support for native parameterized SQL queries. Requires DBR 14.2 and above. See docs/parameters.md for more info.
47+
- Completely rewritten SQLAlchemy dialect
48+
- Adds support for SQLAlchemy >= 2.0 and drops support for SQLAlchemy 1.x
49+
- Full e2e test coverage of all supported features
50+
- Detailed usage notes in `README.sqlalchemy.md`
51+
- Adds support for:
52+
- New types: `TIME`, `TIMESTAMP`, `TIMESTAMP_NTZ`, `TINYINT`
53+
- `Numeric` type scale and precision, like `Numeric(10,2)`
54+
- Reading and writing `PrimaryKeyConstraint` and `ForeignKeyConstraint`
55+
- Reading and writing composite keys
56+
- Reading and writing from views
57+
- Writing `Identity` to tables (i.e. autoincrementing primary keys)
58+
- `LIMIT` and `OFFSET` for paging through results
59+
- Caching metadata calls
60+
- Enable cloud fetch by default. To disable, set `use_cloud_fetch=False` when building `databricks.sql.client`.
661
- Add integration tests for Databricks UC Volumes ingestion queries
762
- Add `_retry_max_redirects` config
863
- Enable cloud fetch by default. To disable, set `use_cloud_fetch=False` when building `databricks.sql.client`.
9-
- Fix: our logger would raise an uncaught exception under certain oauth error conditions
1064

1165
## 2.9.3 (2023-08-24)
1266

1367
- Fix: Connections failed when urllib3~=1.0.0 is installed (#206)
1468

1569
## 2.9.2 (2023-08-17)
1670

17-
__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.__
71+
**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.**
1872

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

2377
## 2.9.1 (2023-08-11)
2478

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

2781
- Other: Explicitly pin urllib3 to ^2.0.0 (#191)
2882

@@ -75,6 +129,7 @@ __Note: this release was yanked from Pypi on 13 September 2023 due to compatibil
75129
- Other: Relax sqlalchemy required version as it was unecessarily strict.
76130

77131
## 2.5.0 (2023-04-14)
132+
78133
- Add support for External Auth providers
79134
- Fix: Python HTTP proxies were broken
80135
- Other: All Thrift requests that timeout during connection will be automatically retried
@@ -96,8 +151,8 @@ __Note: this release was yanked from Pypi on 13 September 2023 due to compatibil
96151

97152
## 2.2.2 (2023-01-03)
98153

99-
- Support custom oauth client id and redirect port
100-
- Fix: Add none check on _oauth_persistence in DatabricksOAuthProvider
154+
- Support custom oauth client id and redirect port
155+
- Fix: Add none check on \_oauth_persistence in DatabricksOAuthProvider
101156

102157
## 2.2.1 (2022-11-29)
103158

@@ -129,57 +184,71 @@ Huge thanks to @dbaxa for contributing this change!
129184

130185
- Add retry logic for `GetOperationStatus` requests that fail with an `OSError`
131186
- Reorganised code to use Poetry for dependency management.
187+
132188
## 2.0.2 (2022-05-04)
189+
133190
- Better exception handling in automatic connection close
134191

135192
## 2.0.1 (2022-04-21)
193+
136194
- Fixed Pandas dependency in setup.cfg to be >= 1.2.0
137195

138196
## 2.0.0 (2022-04-19)
197+
139198
- Initial stable release of V2
140-
- Added better support for complex types, so that in Databricks runtime 10.3+, Arrays, Maps and Structs will get
199+
- Added better support for complex types, so that in Databricks runtime 10.3+, Arrays, Maps and Structs will get
141200
deserialized as lists, lists of tuples and dicts, respectively.
142201
- Changed the name of the metadata arg to http_headers
143202

144203
## 2.0.b2 (2022-04-04)
204+
145205
- Change import of collections.Iterable to collections.abc.Iterable to make the library compatible with Python 3.10
146206
- Fixed bug with .tables method so that .tables works as expected with Unity-Catalog enabled endpoints
147207

148208
## 2.0.0b1 (2022-03-04)
209+
149210
- Fix packaging issue (dependencies were not being installed properly)
150211
- Fetching timestamp results will now return aware instead of naive timestamps
151212
- The client will now default to using simplified error messages
152213

153214
## 2.0.0b (2022-02-08)
215+
154216
- 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.
155-
- Added Unity Catalog support (pass catalog and / or schema key word args to the .connect method to select initial schema and catalog)
217+
- Added Unity Catalog support (pass catalog and / or schema key word args to the .connect method to select initial schema and catalog)
156218

157219
---
158220

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

161223
---
224+
162225
## 1.0.0 (2022-01-20)
226+
163227
- Add operations for retrieving metadata
164228
- Add the ability to access columns by name on result rows
165229
- Add the ability to provide configuration settings on connect
166230

167231
## 0.9.4 (2022-01-10)
232+
168233
- Improved logging and error messages.
169234

170235
## 0.9.3 (2021-12-08)
236+
171237
- Add retries for 429 and 503 HTTP responses.
172238

173239
## 0.9.2 (2021-12-02)
240+
174241
- (Bug fix) Increased Thrift requirement from 0.10.0 to 0.13.0 as 0.10.0 was in fact incompatible
175242
- (Bug fix) Fixed error message after query execution failed -SQLSTATE and Error message were misplaced
176243

177244
## 0.9.1 (2021-09-01)
245+
178246
- Public Preview release, Experimental tag removed
179247
- minor updates in internal build/packaging
180248
- no functional changes
181249

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

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ You are welcome to file an issue here for general use cases. You can also contac
1111

1212
## Requirements
1313

14-
Python 3.7 or above is required.
14+
Python 3.8 or above is required.
1515

1616
## Documentation
1717

@@ -47,8 +47,7 @@ connection = sql.connect(
4747
access_token=access_token)
4848

4949
cursor = connection.cursor()
50-
51-
cursor.execute('SELECT * FROM RANGE(10)')
50+
cursor.execute('SELECT :param `p`, * FROM RANGE(10)', {"param": "foo"})
5251
result = cursor.fetchall()
5352
for row in result:
5453
print(row)

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+
}

0 commit comments

Comments
 (0)