Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit997c266

Browse files
unj1msaishreeeee
authored andcommitted
Introduce SQLAlchemy reusable dialog tests (#125)
Signed-off-by: Jim Fulton <jim.fulton@unsupervised.com>Co-Authored-By: Jesse Whitehouse <jesse.whitehouse@databricks.com>Signed-off-by: Jesse Whitehouse <jesse.whitehouse@databricks.com>Signed-off-by: Sai Shree Pradhan <saishree.pradhan@databricks.com>
1 parent31e2c6d commit997c266

File tree

8 files changed

+1206
-1
lines changed

8 files changed

+1206
-1
lines changed

‎CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
##2.9.4 (Unreleased)
44

5+
- Other: Introduce SQLAlchemy dialect compliance test suite and enumerate all excluded tests
6+
57
##2.9.3 (2023-08-24)
68

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

‎CONTRIBUTING.md‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ End-to-end tests require a Databricks account. Before you can run them, you must
107107
export host=""
108108
export http_path=""
109109
export access_token=""
110+
export catalog=""
111+
export schema=""
110112
```
111113

112114
Or you can write these into a file called`test.env` in the root of the repository:
@@ -141,6 +143,21 @@ The `PySQLLargeQueriesSuite` namespace contains long-running query tests and is
141143
The`PySQLStagingIngestionTestSuite` namespace requires a cluster running DBR version > 12.x which supports staging ingestion commands.
142144

143145
The suites marked`[not documented]` require additional configuration which will be documented at a later time.
146+
147+
####SQLAlchemy dialog tests
148+
149+
SQLAlchemy provides reusable tests for testing dialect implementations.
150+
151+
To run these tests, assuming the environment variables needed for e2e tests are set:
152+
153+
```
154+
poetry run python -m pytest tests/sqlalchemy_dialect_compliance --dburi \
155+
"databricks://token:$access_token@$host?http_path=$http_path&catalog=$catalog&schema=$schema"
156+
```
157+
158+
Some of these of these tests fail currently. We're working on getting
159+
relavent tests passing and others skipped.
160+
144161
###Code formatting
145162

146163
This project uses[Black](https://pypi.org/project/black/).

‎pyproject.toml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,5 @@ log_cli = "false"
6262
log_cli_level ="INFO"
6363
testpaths = ["tests"]
6464
env_files = ["test.env"]
65+
addopts ="--ignore=tests/sqlalchemy_dialect_compliance"
66+

‎setup.cfg‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
[sqla_testing]
3+
requirement_cls=databricks.sqlalchemy.dialect.requirements:Requirements
4+
profile_file=profiles.txt

‎src/databricks/sqlalchemy/dialect/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class DatabricksDialect(default.DefaultDialect):
7171

7272
# Possible attributes are defined here: https://docs.sqlalchemy.org/en/14/core/internals.html#sqlalchemy.engine.Dialect
7373
name:str="databricks"
74-
driver:str="databricks-sql-python"
74+
driver:str="databricks"
7575
default_schema_name:str="default"
7676

7777
preparer=DatabricksIdentifierPreparer# type: ignore
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
"""
2+
This module is supposedly used by the compliance tests to control which tests are run based on database capabilities.
3+
However, based on some experimentation that does not appear to be consistently the case. Until we better understand
4+
when these requirements are and are not implemented, we prefer to manually capture the exact nature of the failures
5+
and errors.
6+
7+
Once we better understand how to use requirements.py, an example exclusion will look like this:
8+
9+
import sqlalchemy.testing.requirements
10+
import sqlalchemy.testing.exclusions
11+
12+
class Requirements(sqlalchemy.testing.requirements.SuiteRequirements):
13+
@property
14+
def __some_example_requirement(self):
15+
return sqlalchemy.testing.exclusions.closed
16+
17+
18+
The complete list of requirements is provided by SQLAlchemy here:
19+
20+
https://github.com/sqlalchemy/sqlalchemy/blob/main/lib/sqlalchemy/testing/requirements.py
21+
"""
22+
23+
importsqlalchemy.testing.requirements
24+
importsqlalchemy.testing.exclusions
25+
26+
importlogging
27+
logger=logging.getLogger(__name__)
28+
29+
logger.warning("requirements.py is not currently employed by Databricks dialect")
30+
31+
classRequirements(sqlalchemy.testing.requirements.SuiteRequirements):
32+
pass
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
fromsqlalchemy.dialectsimportregistry
2+
importpytest
3+
4+
registry.register("databricks","databricks.sqlalchemy","DatabricksDialect")
5+
# sqlalchemy's dialect-testing machinery wants an entry like this.
6+
# This seems to be based around dialects maybe having multiple drivers
7+
# and wanting to test driver-specific URLs, but doesn't seem to make
8+
# much sense for dialects with only one driver.
9+
registry.register("databricks.databricks","databricks.sqlalchemy","DatabricksDialect")
10+
11+
pytest.register_assert_rewrite("sqlalchemy.testing.assertions")
12+
13+
fromsqlalchemy.testing.plugin.pytestpluginimport*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp