Skip to content

[PECO-1803] Splitting the PySql connector into the core and the non core part #417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
335fc0c
Implemented ColumnQueue to test the fetchall without pyarrow
jprakash-db Jul 24, 2024
ad2b014
order of fields in row corrected
shivam2680 Jul 24, 2024
882e080
Changed the folder structure and tested the basic setup to work
jprakash-db Aug 6, 2024
98c4cd6
Refractored the code to make connector to work
jprakash-db Aug 6, 2024
25a006d
Basic Setup of connector, core and sqlalchemy is working
jprakash-db Aug 7, 2024
1cfaae2
Basic integration of core, connect and sqlalchemy is working
jprakash-db Aug 7, 2024
c576110
Setup working dynamic change from ColumnQueue to ArrowQueue
jprakash-db Aug 7, 2024
0ddca9d
Refractored the test code and moved to respective folders
jprakash-db Aug 8, 2024
786dc1e
Added the unit test for column_queue
jprakash-db Aug 14, 2024
c91d43d
venv_main added to git ignore
jprakash-db Aug 20, 2024
b67b739
Added code for merging columnar table
jprakash-db Aug 21, 2024
32e3dcd
Merging code for columnar
jprakash-db Aug 21, 2024
d062887
Fixed the retry_close sesssion test issue with logging
jprakash-db Aug 22, 2024
9908976
Fixed the databricks_sqlalchemy tests and introduced pytest.ini for t…
jprakash-db Aug 22, 2024
af0cd4f
Added pyarrow_test mark on pytest
jprakash-db Aug 25, 2024
a07c232
Fixed databricks.sqlalchemy to databricks_sqlalchemy imports
jprakash-db Aug 25, 2024
f0c8e7a
Added poetry.lock
jprakash-db Aug 26, 2024
46ae0f7
Added dist folder
jprakash-db Aug 26, 2024
8c5e7dd
Changed the pyproject.toml
jprakash-db Aug 26, 2024
24730dd
Minor Fix
jprakash-db Aug 27, 2024
61de281
Added the pyarrow skip tag on unit tests and tested their working
jprakash-db Aug 30, 2024
bad7c0b
Fixed the Decimal and timestamp conversion issue in non arrow pipeline
jprakash-db Sep 1, 2024
520d2c8
Removed not required files and reformatted
jprakash-db Sep 2, 2024
051bdce
Fixed test_retry error
jprakash-db Sep 2, 2024
4d64034
Changed the folder structure to src / databricks
jprakash-db Sep 13, 2024
93848d7
Removed the columnar non arrow flow to another PR
jprakash-db Sep 13, 2024
f37f42c
Moved the README to the root
jprakash-db Sep 15, 2024
0e4b599
removed columnQueue instance
jprakash-db Sep 15, 2024
8199832
Revmoved databricks_sqlalchemy dependency in core
jprakash-db Sep 15, 2024
613e7dc
Changed the pysql_supports_arrow predicate, introduced changes in the…
jprakash-db Sep 17, 2024
c4a2e08
Ran the black formatter with the original version
jprakash-db Sep 17, 2024
6f10ec6
Extra .py removed from all the __init__.py files names
jprakash-db Sep 17, 2024
2115db1
Undo formatting check
jprakash-db Sep 18, 2024
36c0f95
Check
jprakash-db Sep 18, 2024
15d5047
Check
jprakash-db Sep 18, 2024
8415230
Check
jprakash-db Sep 18, 2024
15df683
Check
jprakash-db Sep 18, 2024
b4c3029
Check
jprakash-db Sep 18, 2024
bc758d8
Check
jprakash-db Sep 18, 2024
31da868
Check
jprakash-db Sep 18, 2024
f79fc69
Check
jprakash-db Sep 18, 2024
d121fed
Check
jprakash-db Sep 18, 2024
6e393b0
Check
jprakash-db Sep 18, 2024
2383caf
Check
jprakash-db Sep 18, 2024
dd4c487
Check
jprakash-db Sep 18, 2024
6be085c
Check
jprakash-db Sep 18, 2024
e7cf5c3
Check
jprakash-db Sep 18, 2024
b6a5668
BIG UPDATE
jprakash-db Sep 18, 2024
4496a04
Refeactor code
jprakash-db Sep 19, 2024
726b8ed
Refractor
jprakash-db Sep 19, 2024
66bfa6d
Fixed versioning
jprakash-db Sep 19, 2024
2c1cfbd
Minor refractoring
jprakash-db Sep 19, 2024
ae20a65
Minor refractoring
jprakash-db Sep 19, 2024
f056c80
Merged databricks:PECO-1803/connector-split into jprakash-db/PECO-1803
jprakash-db Sep 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ __pycache__/
.Python
build/
develop-eggs/
dist/
#dist/
downloads/
eggs/
.eggs/
Expand Down Expand Up @@ -200,7 +200,7 @@ cython_debug/
# End of https://www.toptal.com/developers/gitignore/api/python,macos

databricks_sql_connector.egg-info/
dist/
#dist/
build/

# vs code stuff
Expand Down
File renamed without changes.
Binary file not shown.
Binary file not shown.
47 changes: 47 additions & 0 deletions databricks_sql_connector/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[tool.poetry]
name = "databricks-sql-connector"
version = "1.0.0"
description = "Databricks SQL Connector for Python"
authors = ["Databricks <[email protected]>"]
license = "Apache-2.0"
readme = "README.md"
packages = [{ include = "databricks", from = "src" }]
include = ["CHANGELOG.md"]

[tool.poetry.dependencies]
python = "^3.8.0"
pyarrow = ">=14.0.1,<17"
databricks_sql_connector_core = { version = ">=1.0.0"}
databricks_sqlalchemy = { version = ">=1.0.0", optional = true }

[tool.poetry.extras]
databricks_sqlalchemy = ["databricks_sqlalchemy"]

[tool.poetry.dev-dependencies]
pytest = "^7.1.2"
mypy = "^1.10.1"
pylint = ">=2.12.0"
black = "^22.3.0"
pytest-dotenv = "^0.5.2"

[tool.poetry.urls]
"Homepage" = "https://github.com/databricks/databricks-sql-python"
"Bug Tracker" = "https://github.com/databricks/databricks-sql-python/issues"

[tool.poetry.plugins."sqlalchemy.dialects"]
"databricks" = "databricks_sqlalchemy:DatabricksDialect"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.black]
exclude = '/(\.eggs|\.git|\.hg|\.mypy_cache|\.nox|\.tox|\.venv|\.svn|_build|buck-out|build|dist|thrift_api)/'

#[tool.pytest.ini_options]
#markers = {"reviewed" = "Test case has been reviewed by Databricks"}
#minversion = "6.0"
#log_cli = "false"
#log_cli_level = "INFO"
#testpaths = ["tests", "databricks_sql_connector/src"]
#env_files = ["test.env"]
1 change: 1 addition & 0 deletions databricks_sql_connector/src/databricks/sql/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from databricks_sql_connector_core.sql import *
1 change: 1 addition & 0 deletions databricks_sql_connector/src/databricks/sql/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from databricks_sql_connector_core.sql.utils import *
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
try:
from databricks_sqlalchemy import *
except:
import warnings

warnings.warn("Install databricks_sqlalchemy plugin before using this")
4 changes: 2 additions & 2 deletions README.md → databricks_sql_connector_core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ or to a Databricks Runtime interactive cluster (e.g. /sql/protocolv1/o/123456789

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md)
See [CONTRIBUTING.md](../CONTRIBUTING.md)

## License

[Apache License 2.0](LICENSE)
[Apache License 2.0](../LICENSE)
Binary file not shown.
Binary file not shown.
24 changes: 9 additions & 15 deletions pyproject.toml → databricks_sql_connector_core/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[tool.poetry]
name = "databricks-sql-connector"
version = "3.3.0"
description = "Databricks SQL Connector for Python"
name = "databricks-sql-connector-core"
version = "1.0.0"
description = "Databricks SQL Connector core for Python"
authors = ["Databricks <[email protected]>"]
license = "Apache-2.0"
readme = "README.md"
packages = [{ include = "databricks", from = "src" }]
packages = [{ include = "databricks_sql_connector_core", from = "src" }]
include = ["CHANGELOG.md"]

[tool.poetry.dependencies]
Expand All @@ -14,23 +14,17 @@ thrift = ">=0.16.0,<0.21.0"
pandas = [
{ version = ">=1.2.5,<2.2.0", python = ">=3.8" }
]
pyarrow = ">=14.0.1,<17"

lz4 = "^4.0.2"
requests = "^2.18.1"
oauthlib = "^3.1.0"
numpy = [
{ version = "^1.16.6", python = ">=3.8,<3.11" },
{ version = "^1.23.4", python = ">=3.11" },
]
sqlalchemy = { version = ">=2.0.21", optional = true }
openpyxl = "^3.0.10"
databricks_sqlalchemy = { version = ">=1.0.0", optional = true }
alembic = { version = "^1.0.11", optional = true }
urllib3 = ">=1.26"

[tool.poetry.extras]
sqlalchemy = ["sqlalchemy"]
alembic = ["sqlalchemy", "alembic"]
databricks_sqlalchemy = ["databricks_sqlalchemy"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need databricks_sqlalchemy in sql_connector_core, it should NOT have this dependency or declaration.

alembic = ["databricks_sqlalchemy", "alembic"]

[tool.poetry.dev-dependencies]
pytest = "^7.1.2"
Expand All @@ -44,7 +38,7 @@ pytest-dotenv = "^0.5.2"
"Bug Tracker" = "https://github.com/databricks/databricks-sql-python/issues"

[tool.poetry.plugins."sqlalchemy.dialects"]
"databricks" = "databricks.sqlalchemy:DatabricksDialect"
"databricks" = "databricks_sqlalchemy:DatabricksDialect"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand All @@ -62,5 +56,5 @@ markers = {"reviewed" = "Test case has been reviewed by Databricks"}
minversion = "6.0"
log_cli = "false"
log_cli_level = "INFO"
testpaths = ["tests", "src/databricks/sqlalchemy/test_local"]
testpaths = ["tests", "databricks_sql_connector_core/tests"]
env_files = ["test.env"]
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import datetime

from databricks.sql.exc import *
from databricks_sql_connector_core.sql.exc import *

# PEP 249 module globals
apilevel = "2.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from enum import Enum
from typing import Optional, List

from databricks.sql.auth.authenticators import (
from databricks_sql_connector_core.sql.auth.authenticators import (
AuthProvider,
AccessTokenAuthProvider,
ExternalAuthProvider,
Expand Down Expand Up @@ -107,9 +107,11 @@ def get_python_sql_connector_auth_provider(hostname: str, **kwargs):
tls_client_cert_file=kwargs.get("_tls_client_cert_file"),
oauth_scopes=PYSQL_OAUTH_SCOPES,
oauth_client_id=kwargs.get("oauth_client_id") or client_id,
oauth_redirect_port_range=[kwargs["oauth_redirect_port"]]
if kwargs.get("oauth_client_id") and kwargs.get("oauth_redirect_port")
else redirect_port_range,
oauth_redirect_port_range=(
[kwargs["oauth_redirect_port"]]
if kwargs.get("oauth_client_id") and kwargs.get("oauth_redirect_port")
else redirect_port_range
),
oauth_persistence=kwargs.get("experimental_oauth_persistence"),
credentials_provider=kwargs.get("credentials_provider"),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@
import logging
from typing import Callable, Dict, List

from databricks.sql.auth.oauth import OAuthManager
from databricks.sql.auth.endpoint import get_oauth_endpoints, infer_cloud_from_host
from databricks_sql_connector_core.sql.auth.oauth import OAuthManager
from databricks_sql_connector_core.sql.auth.endpoint import (
get_oauth_endpoints,
infer_cloud_from_host,
)

# Private API: this is an evolving interface and it will change in the future.
# Please must not depend on it in your applications.
from databricks.sql.experimental.oauth_persistence import OAuthToken, OAuthPersistence
from databricks_sql_connector_core.sql.experimental.oauth_persistence import (
OAuthToken,
OAuthPersistence,
)


class AuthProvider:
Expand All @@ -25,12 +31,10 @@ class CredentialsProvider(abc.ABC):
for authenticating requests to Databricks REST APIs"""

@abc.abstractmethod
def auth_type(self) -> str:
...
def auth_type(self) -> str: ...

@abc.abstractmethod
def __call__(self, *args, **kwargs) -> HeaderFactory:
...
def __call__(self, *args, **kwargs) -> HeaderFactory: ...


# Private API: this is an evolving interface and it will change in the future.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
from oauthlib.oauth2.rfc6749.errors import OAuth2Error
from requests.exceptions import RequestException

from databricks.sql.auth.oauth_http_handler import OAuthHttpSingleRequestHandler
from databricks.sql.auth.endpoint import OAuthEndpointCollection
from databricks_sql_connector_core.sql.auth.oauth_http_handler import (
OAuthHttpSingleRequestHandler,
)
from databricks_sql_connector_core.sql.auth.endpoint import OAuthEndpointCollection

logger = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from urllib3 import Retry
from urllib3.util.retry import RequestHistory

from databricks.sql.exc import (
from databricks_sql_connector_core.sql.exc import (
CursorAlreadyClosedError,
MaxRetryDurationError,
NonRecoverableNetworkError,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@

from urllib3 import HTTPConnectionPool, HTTPSConnectionPool, ProxyManager
from urllib3.util import make_headers
from databricks.sql.auth.retry import CommandType, DatabricksRetryPolicy
from databricks_sql_connector_core.sql.auth.retry import (
CommandType,
DatabricksRetryPolicy,
)


class THttpClient(thrift.transport.THttpClient.THttpClient):
Expand Down
Loading