Skip to content

Commit

Permalink
Use PyHive pure-sasl import (#818)
Browse files Browse the repository at this point in the history
* Use PyHive pure-sasl import

* Test PyHive pure-sasl import

* update requirements.txt

* use github fix for >3.11

* use github fix for >3.11

* fix pyhive spec

* remove unnecessary requests extra

* remove unnecessary sasl install

* add changie

* specify no-binary for pyodbc install

* conditionally import sasl vs puresasl

* conditionally import sasl vs pure-sasl

* experiment with pure sasl SASLClient

* file formatting

* test using only puresasl

* test using only puresasl

* update requirements.txt

* remove sasl from req

* remove unused sys dependency

* test spark-session

* fix pure-sasl

* allow pre-release installs

* allow pre-release installs

* use pyhive 0.7.0

* add pyhive back to reqs

* fix setup.py and remove sasl from dev-requirements.txt

* Update Dependencies-20230628-121341.yaml

* remove unnecessary pip_pre arg from tox.ini

---------

Co-authored-by: Mike Alfare <13974384+mikealfare@users.noreply.github.com>
  • Loading branch information
colin-rogers-dbt and mikealfare authored Aug 21, 2023
1 parent 6ffd767 commit 07383d9
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 16 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Dependencies-20230628-121341.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Dependencies
body: Replace sasl with pure-sasl for PyHive
time: 2023-06-28T12:13:41.141588-07:00
custom:
Author: colin-rogers-dbt
PR: "818"
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.8", "3.9", "3.10", "3.11"]

env:
TOXENV: "unit"
Expand Down Expand Up @@ -177,7 +177,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.8", "3.9", "3.10", "3.11"]

steps:
- name: Set up Python ${{ matrix.python-version }}
Expand Down
14 changes: 6 additions & 8 deletions dbt/adapters/spark/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
from thrift.transport.TSSLSocket import TSSLSocket
import thrift
import ssl
import sasl
import thrift_sasl
from puresasl.client import SASLClient
except ImportError:
pass # done deliberately: setting modules to None explicitly violates MyPy contracts by degrading type semantics

Expand Down Expand Up @@ -603,17 +603,15 @@ def build_ssl_transport(
# to be nonempty.
password = "x"

def sasl_factory() -> sasl.Client:
sasl_client = sasl.Client()
sasl_client.setAttr("host", host)
def sasl_factory() -> SASLClient:
if sasl_auth == "GSSAPI":
sasl_client.setAttr("service", kerberos_service_name)
sasl_client = SASLClient(host, kerberos_service_name, mechanism=sasl_auth)
elif sasl_auth == "PLAIN":
sasl_client.setAttr("username", username)
sasl_client.setAttr("password", password)
sasl_client = SASLClient(
host, mechanism=sasl_auth, username=username, password=password
)
else:
raise AssertionError
sasl_client.init()
return sasl_client

transport = thrift_sasl.TSaslClientTransport(sasl_factory, sasl_auth, socket)
Expand Down
1 change: 0 additions & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,4 @@ wheel~=0.41

# Adapter specific dependencies
mock~=5.1
sasl~=0.3.1
thrift_sasl~=0.4.3
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PyHive[hive]>=0.6.0,<0.7.0
requests[python]>=2.28.1
pyhive[hive_pure_sasl]~=0.7.0
requests>=2.28.1

pyodbc~=4.0.39
sqlparams>=3.0.0
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
print("Please upgrade to Python 3.8 or higher.")
sys.exit(1)


# require version of setuptools that supports find_namespace_packages
from setuptools import setup

Expand Down Expand Up @@ -54,9 +53,9 @@ def _get_dbt_core_version():
dbt_core_version = _get_dbt_core_version()
description = """The Apache Spark adapter plugin for dbt"""

odbc_extras = ["pyodbc~=4.0.30"]
odbc_extras = ["pyodbc~=4.0.39"]
pyhive_extras = [
"PyHive[hive]>=0.6.0,<0.7.0",
"PyHive[hive_pure_sasl]~=0.7.0",
"thrift>=0.11.0,<0.17.0",
]
session_extras = ["pyspark>=3.0.0,<4.0.0"]
Expand Down Expand Up @@ -93,6 +92,7 @@ def _get_dbt_core_version():
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
],
python_requires=">=3.8",
)

0 comments on commit 07383d9

Please sign in to comment.