Skip to content

Commit

Permalink
Final ODBC Version (#13)
Browse files Browse the repository at this point in the history
### Summary

Final ODBC Adapter Version

### Description

Updates to make the adapter more user-friendly, in addition to:
- use the Flight SQL ODBC driver
- use dbt-core 1.2.2

### Related Issue

[None](#9)

### Additional Reviewers
@ArgusLi @ravjotbrar

Co-authored-by: ArgusLi <[email protected]>
  • Loading branch information
jlarue26 and ArgusLi authored Oct 7, 2022
1 parent 44dcfd2 commit 99d7244
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 58 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
recursive-include dbt/include *.sql *.yml *.md
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,24 @@
> *This project is developed during my spare time, along side my lead dev position at [MAIF-VIE](http://www.maif.fr), and aims to provide a competitive alternative solution for our current ETL stack.*
# dbt-dremio
[dbt](https://www.getdbt.com/)'s adapter for [dremio](https://www.dremio.com/)
[dbt](https://www.getdbt.com/)'s adapter for [dremio](https://www.dremio.com/), v1.1.0b

If you are reading this documentation, I assume you already know well both dbt and dremio. Please refer to their respective documentation.

# Installation
dbt dependencies :
- dbt-core>=1.0.6,
- dbt-core=1.2.2,
- pyodbc>=4.0.27

dremio dependency :
- latest dremio's odbc driver
- dremio >= 21.0.0
- latest Dremio's Flight SQL ODBC driver
- Dremio >= 21.0.0
- `dremio.iceberg.enabled`, `dremio.iceberg.ctas.enabled` and `dremio.execution.support_unlimited_splits` enabled

os dependency :
- odbc (unixodbc-dev on linux)
- Windows OS
- Linux
- Not currently supported: Apple Silicon MacOS (current limitation on Flight SQL ODBC driver)

`pip install dbt-dremio`

Expand Down
1 change: 0 additions & 1 deletion dbt/__init__.py

This file was deleted.

1 change: 0 additions & 1 deletion dbt/adapters/__init__.py

This file was deleted.

1 change: 1 addition & 0 deletions dbt/adapters/dremio/__version__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version = "1.1.0b"
33 changes: 26 additions & 7 deletions dbt/adapters/dremio/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@
class DremioCredentials(Credentials):
driver: str
host: str
UID: str
PWD: str
environment: Optional[str]
database: Optional[str]
schema: Optional[str]
datalake: Optional[str]
root_path: Optional[str]
port: Optional[int] = 31010
UID: Optional[str] = None
PWD: Optional[str] = None
port: Optional[int] = 32010
use_ssl: Optional[bool] = True
additional_parameters: Optional[str] = None
pat: Optional[str] = None

_ALIASES = {
'user': 'UID'
Expand All @@ -56,7 +58,8 @@ def unique_field(self):
def _connection_keys(self):
# return an iterator of keys to pretty-print in 'dbt debug'
# raise NotImplementedError
return 'driver', 'host', 'port', 'UID', 'database', 'schema', 'additional_parameters', 'datalake', 'root_path', 'environment'
return 'driver', 'host', 'port', 'UID', 'database', 'schema',
'additional_parameters', 'datalake', 'root_path', 'environment', 'use_ssl'

@classmethod
def __pre_deserialize__(cls, data):
Expand All @@ -71,6 +74,8 @@ def __pre_deserialize__(cls, data):
data['root_path'] = None
if 'environment' not in data:
data['environment'] = None
if 'pat' not in data:
data['pat'] = None
return data

def __post_init__(self):
Expand Down Expand Up @@ -123,18 +128,32 @@ def open(cls, connection):
return connection

credentials = connection.credentials
logger.debug(credentials.pat)

try:
con_str = ["ConnectionType=Direct", "AuthenticationType=Plain", "QueryTimeout=600"]
con_str.append(f"Driver={{{credentials.driver}}}")
con_str.append(f"HOST={credentials.host}")
con_str.append(f"PORT={credentials.port}")
con_str.append(f"UID={credentials.UID}")
con_str.append(f"PWD={credentials.PWD}")

if credentials.pat != None:
con_str.append(f"token={credentials.pat}")
if credentials.UID != None or credentials.PWD != None:
logger.warning("""A username or password is not required when using a personal
access token with Dremio Cloud.""")
else:
con_str.append(f"UID={credentials.UID}")
con_str.append(f"PWD={credentials.PWD}")

if credentials.use_ssl == True:
con_str.append("useEncryption=1")
else:
con_str.append("useEncryption=0")

if credentials.additional_parameters:
con_str.append(f"{credentials.additional_parameters}")

con_str_concat = ';'.join(con_str)
logger.debug(f'Using connection string: {con_str_concat}')

handle = pyodbc.connect(con_str_concat, autocommit=True)

Expand Down
1 change: 0 additions & 1 deletion dbt/include/__init__.py

This file was deleted.

1 change: 0 additions & 1 deletion dbt/include/dremio/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

name: dbt_dremio
version: 1.0
config-version: 2
Expand Down
35 changes: 35 additions & 0 deletions dbt/include/dremio/profile_template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
fixed:
type: dremio
driver: Arrow Flight SQL ODBC Driver
use_ssl: true
prompts:
_choose_cloud_or_software:
cloud:
host:
default: data.dremio.cloud
hint: data.dremio.cloud or data.eu.dremio.cloud
port:
default: 443
database:
hint: "@[Dremio Cloud user email]"
pat:
hint: 'personal access token'
hide_input: true
software:
host:
hint:
port:
default: 32010
user:
hint: "username"
password:
hint: 'password or personal access token'
hide_input: true
use_ssl:
default: false
hint: 'use encrypted connection'
threads:
hint: '1 or more'
type: 'int'
default: 1

25 changes: 0 additions & 25 deletions dbt/include/dremio/sample_profiles.yml

This file was deleted.

25 changes: 8 additions & 17 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,21 @@
#!/usr/bin/env python
from setuptools import find_packages
from setuptools import setup
from setuptools import find_namespace_packages, setup

package_name = "dbt-dremio"
package_version = "1.0.6.5"
description = """The dremio adapter plugin for dbt (data build tool)"""
package_version = "1.1.0b"
description = """The Dremio adapter plugin for dbt"""

setup(
name=package_name,
version=package_version,
description=description,
long_description=description,
author="Fabrice Etanchaud",
author_email="[email protected]",
url="https://github.com/fabrice-etanchaud/dbt-dremio",
packages=find_packages(),
package_data={
'dbt': [
'include/dremio/macros/*.sql',
'include/dremio/macros/**/*.sql',
'include/dremio/macros/**/**/*.sql',
'include/dremio/dbt_project.yml',
]
},
author="Dremio",
url="https://github.com/dremio/dbt-dremio",
packages=find_namespace_packages(include=["dbt", "dbt.*"]),
include_package_data=True,
install_requires=[
'dbt-core~=1.2.0',
'dbt-core==1.2.2',
'pyodbc>=4.0.27',
]
)

0 comments on commit 99d7244

Please sign in to comment.