Skip to content
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

Add support for ODBC Server Side Parameters #201

Merged
merged 3 commits into from
Aug 11, 2021
Merged
Changes from 1 commit
Commits
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
13 changes: 11 additions & 2 deletions dbt/adapters/spark/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import sqlparams

from hologram.helpers import StrEnum
from dataclasses import dataclass
from typing import Optional
from dataclasses import dataclass, field
from typing import Any, Dict, Optional
try:
from thrift.transport.TSSLSocket import TSSLSocket
import thrift
Expand Down Expand Up @@ -72,6 +72,7 @@ class SparkCredentials(Credentials):
connect_retries: int = 0
connect_timeout: int = 10
use_ssl: bool = False
server_side_parameters: Dict[str, Any] = field(default_factory=dict)

@classmethod
def __pre_deserialize__(cls, data):
Expand Down Expand Up @@ -401,6 +402,12 @@ def open(cls, connection):
dbt_spark_version = __version__.version
user_agent_entry = f"fishtown-analytics-dbt-spark/{dbt_spark_version} (Databricks)" # noqa

# http://simba.wpengine.com/products/Spark/doc/ODBC_InstallGuide/unix/content/odbc/hi/configuring/serverside.htm
ssp = {
f"SSP_{k}": f"{{{v}}}"
for k, v in creds.server_side_parameters.items()
}

# https://www.simba.com/products/Spark/doc/v2/ODBC_InstallGuide/unix/content/odbc/options/driver.htm
connection_str = _build_odbc_connnection_string(
DRIVER=creds.driver,
Expand All @@ -414,6 +421,8 @@ def open(cls, connection):
ThriftTransport=2,
SSL=1,
UserAgentEntry=user_agent_entry,
LCaseSspKeyName=0 if ssp else 1,
**ssp,
)

conn = pyodbc.connect(connection_str, autocommit=True)
Expand Down