dbt-firebolt 1.4.3__py3-none-any.whl → 1.4.4__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,7 +7,7 @@ from dbt.adapters.firebolt.connections import (
7
7
  from dbt.adapters.firebolt.impl import FireboltAdapter
8
8
  from dbt.include import firebolt
9
9
 
10
- __version__ = "1.4.3"
10
+ __version__ = "1.4.4"
11
11
 
12
12
  Plugin = AdapterPlugin(
13
13
  adapter=FireboltAdapter, # type: ignore
@@ -14,7 +14,7 @@ from dbt.contracts.connection import (
14
14
  from dbt.events import AdapterLogger # type: ignore
15
15
  from dbt.exceptions import DbtRuntimeError
16
16
  from firebolt.client import DEFAULT_API_URL
17
- from firebolt.client.auth import UsernamePassword
17
+ from firebolt.client.auth import Auth, ClientCredentials, UsernamePassword
18
18
  from firebolt.db import connect as sdk_connect
19
19
  from firebolt.db.connection import Connection as SDKConnection
20
20
  from firebolt.db.cursor import Cursor
@@ -27,14 +27,33 @@ logger = AdapterLogger('Firebolt')
27
27
  @dataclass
28
28
  class FireboltCredentials(Credentials):
29
29
  # These values all come from either profiles.yml or dbt_project.yml.
30
- user: str
31
- password: str
30
+ user: Optional[str] = None
31
+ password: Optional[str] = None
32
+ # New way to authenticate
33
+ client_id: Optional[str] = None
34
+ client_secret: Optional[str] = None
32
35
  api_endpoint: Optional[str] = DEFAULT_API_URL
33
36
  driver: str = 'com.firebolt.FireboltDriver'
34
37
  engine_name: Optional[str] = None
35
38
  account_name: Optional[str] = None
36
39
  retries: int = 1
37
40
 
41
+ def __post_init__(self) -> None:
42
+ # If user and password are not provided, assume client_id and client_secret
43
+ # are provided instead
44
+ if not self.user and not self.password:
45
+ if not self.client_id or not self.client_secret:
46
+ raise dbt.exceptions.DbtProfileError(
47
+ 'Either user and password or client_id and client_secret'
48
+ ' must be provided'
49
+ )
50
+ else:
51
+ if self.client_id or self.client_secret:
52
+ raise dbt.exceptions.DbtProfileError(
53
+ 'Either user and password or client_id and client_secret'
54
+ ' must be provided'
55
+ )
56
+
38
57
  @property
39
58
  def type(self) -> str:
40
59
  return 'firebolt'
@@ -94,10 +113,11 @@ class FireboltConnectionManager(SQLConnectionManager):
94
113
  if connection.state == 'open':
95
114
  return connection
96
115
  credentials = connection.credentials
116
+ auth: Auth = _determine_auth(credentials)
97
117
 
98
118
  def connect() -> SDKConnection:
99
119
  handle = sdk_connect(
100
- auth=UsernamePassword(credentials.user, credentials.password),
120
+ auth=auth,
101
121
  engine_name=credentials.engine_name,
102
122
  database=credentials.database,
103
123
  api_endpoint=credentials.api_endpoint,
@@ -162,3 +182,20 @@ class FireboltConnectionManager(SQLConnectionManager):
162
182
  raise dbt.exceptions.NotImplementedError(
163
183
  '`cancel` is not implemented for this adapter!'
164
184
  )
185
+
186
+
187
+ def _determine_auth(credentials: FireboltCredentials) -> Auth:
188
+ if credentials.client_id and credentials.client_secret:
189
+ return ClientCredentials(credentials.client_id, credentials.client_secret)
190
+ elif '@' in credentials.user: # type: ignore # checked in the dataclass
191
+ # email auth can only be used with UsernamePassword
192
+ return UsernamePassword(
193
+ credentials.user, # type: ignore[arg-type]
194
+ credentials.password, # type: ignore[arg-type]
195
+ )
196
+ else:
197
+ # assume user provided id and secret in the user/password fields
198
+ return ClientCredentials(
199
+ credentials.user, # type: ignore[arg-type]
200
+ credentials.password, # type: ignore[arg-type]
201
+ )
@@ -14,7 +14,6 @@ from dbt.exceptions import (
14
14
  CompilationError,
15
15
  DbtRuntimeError,
16
16
  NotImplementedError,
17
- validator_error_message,
18
17
  )
19
18
 
20
19
  from dbt.adapters.firebolt.column import FireboltColumn
@@ -91,7 +90,7 @@ class FireboltIndexConfig(dbtClassMixin):
91
90
  )
92
91
  return index_config
93
92
  except ValidationError as exc:
94
- msg = validator_error_message(exc)
93
+ msg = DbtRuntimeError('').validator_error_message(exc)
95
94
  raise CompilationError(f'Could not parse index config: {msg}.')
96
95
  return None
97
96
 
@@ -5,17 +5,16 @@
5
5
  {% if unique_key %}
6
6
  {% if unique_key is sequence and unique_key is not string %}
7
7
  delete from {{ target }}
8
- where (
9
- {% for key in unique_key %}
10
- {{ target }}.{{ key }} in (select {{ key }} from {{ source }})
11
- {{ "and " if not loop.last }}
12
- {% endfor %}
8
+ where
9
+ ({{ get_quoted_csv(unique_key) }}) in (
10
+ select {{ get_quoted_csv(unique_key) }}
11
+ from {{ source }}
12
+ )
13
13
  {% if incremental_predicates %}
14
14
  {% for predicate in incremental_predicates %}
15
15
  and {{ predicate }}
16
16
  {% endfor %}
17
- {% endif %}
18
- );
17
+ {% endif %};
19
18
  {% else %}
20
19
  delete from {{ target }}
21
20
  where (
@@ -71,11 +71,19 @@
71
71
  {% do exceptions.raise_compiler_error(
72
72
  'A schema change was detected and `on_schema_change` was set to "fail".') %}
73
73
  {% else %}
74
- {% do exceptions.raise_compiler_error(
75
- 'Schema changes detected. Either revert the change or run the model with the ' ~
76
- '--full-refresh flag on the command line to recreate the model with the new ' ~
77
- 'schema definition. Running with the --full-refresh flag drops and recreates ' ~
78
- 'the database object.') %}
74
+ {% set fail_msg %}
75
+ Schema changes detected on this incremental!
76
+ Either revert the change or run the model with the --full-refresh flag
77
+ on the command line to recreate the model with the new schema definition.
78
+ Running with the --full-refresh flag drops and recreates the database object.
79
+
80
+ Additional troubleshooting context:
81
+ Source columns not in target: {{ schema_changes_dict['source_not_in_target'] }}
82
+ Target columns not in source: {{ schema_changes_dict['target_not_in_source'] }}
83
+ New column types: {{ schema_changes_dict['new_target_types'] }}
84
+ {% endset %}
85
+
86
+ {% do exceptions.raise_compiler_error(fail_msg) %}
79
87
  {% endif %}
80
88
  {% endif %}
81
89
  {{ return(schema_changes_dict['common_columns']) }}
@@ -1,7 +1,7 @@
1
1
  {% macro firebolt__cast_bool_to_text(field) %}
2
2
  CASE
3
- WHEN {{ field }} = 0 THEN 'false'
4
- WHEN {{ field }} = 1 THEN 'true'
3
+ WHEN {{ field }} = false THEN 'false'
4
+ WHEN {{ field }} = true THEN 'true'
5
5
  ELSE NULL
6
6
  END
7
7
  {% endmacro %}
@@ -1,6 +1,6 @@
1
1
  {% macro firebolt__datediff(first_date, second_date, datepart) -%}
2
2
 
3
- datediff(
3
+ date_diff(
4
4
  '{{ datepart }}',
5
5
  {{ first_date }} :: TIMESTAMP,
6
6
  {{ second_date }} :: TIMESTAMP
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dbt-firebolt
3
- Version: 1.4.3
3
+ Version: 1.4.4
4
4
  Summary: The Firebolt adapter plugin for dbt (data build tool)
5
5
  Home-page: https://github.com/firebolt-db/dbt-firebolt
6
6
  Author: Firebolt
@@ -17,13 +17,14 @@ Classifier: Programming Language :: Python :: 3.9
17
17
  Requires-Python: >=3.7
18
18
  Description-Content-Type: text/markdown
19
19
  License-File: LICENSE
20
- Requires-Dist: dbt-core (~=1.4)
21
- Requires-Dist: firebolt-sdk (>=0.10.0)
20
+ Requires-Dist: dbt-core ~=1.4
21
+ Requires-Dist: firebolt-sdk >=1.1.0
22
22
  Provides-Extra: dev
23
- Requires-Dist: dbt-tests-adapter (~=1.4) ; extra == 'dev'
24
- Requires-Dist: mypy (==0.910) ; extra == 'dev'
25
- Requires-Dist: pre-commit (==2.15.0) ; extra == 'dev'
26
- Requires-Dist: pytest (==7.*) ; extra == 'dev'
23
+ Requires-Dist: allure-pytest ==2.* ; extra == 'dev'
24
+ Requires-Dist: dbt-tests-adapter ~=1.4 ; extra == 'dev'
25
+ Requires-Dist: mypy ==0.910 ; extra == 'dev'
26
+ Requires-Dist: pre-commit ==2.15.0 ; extra == 'dev'
27
+ Requires-Dist: pytest ==7.* ; extra == 'dev'
27
28
 
28
29
  <img width="1113" alt="Screen Shot 2021-12-10 at 1 09 09 PM" src="https://user-images.githubusercontent.com/7674553/145641621-a7dabe78-da92-4f0a-bbd2-54ccf7f34b57.png">
29
30
 
@@ -1,8 +1,8 @@
1
- dbt/adapters/firebolt/__init__.py,sha256=Qb0qoQ5VnevRw2MXOhJFHYKCbLXNQcTeisjFFzIMvsk,411
1
+ dbt/adapters/firebolt/__init__.py,sha256=H1o-mp-HofZFT8IxEoZr97TDxLxzw47xngjETDNCTfA,411
2
2
  dbt/adapters/firebolt/__version__.py,sha256=zRlZGglif76ZVuWWSjsH_MMPgtVQqmj-SryYJW25FL4,69
3
3
  dbt/adapters/firebolt/column.py,sha256=COo_wjhCFgS3GFcPIPcoq7WAWgzN6DB2XqG-gk51WBc,539
4
- dbt/adapters/firebolt/connections.py,sha256=3Pkeb9U19VcRKQPHX-eXTp68BEXV2HgT47MXU4YMxn4,5026
5
- dbt/adapters/firebolt/impl.py,sha256=TVAIwGQR9t4JSW4WPQVfG1_-kNaxSpBxnFSic9wwnlo,13013
4
+ dbt/adapters/firebolt/connections.py,sha256=m7PZF_i43LN0q4K_4dV4DhCs0_DoAYwh95rjY8IhUcI,6645
5
+ dbt/adapters/firebolt/impl.py,sha256=Fm_KeGiuQgpMm-pOIFv1DDbeRuX_OeneHL8IQTgIMBY,13004
6
6
  dbt/adapters/firebolt/relation.py,sha256=z-yv_ICJPZB33IIpnr3o_jusoULlKANLj6BlkaudQQ0,1152
7
7
  dbt/include/firebolt/__init__.py,sha256=vBGWeG-dHHkimfnX8axBJ4IgAowFw8xADmo6Auzn2xc,52
8
8
  dbt/include/firebolt/dbt_project.yml,sha256=uHJ-i0wD1D74DWSSSzsFKoKbAN1w4LBgVpnkm8e-M1g,76
@@ -20,16 +20,16 @@ dbt/include/firebolt/macros/materializations/view.sql,sha256=0xg2mO-1UWtZKj2Wlpl
20
20
  dbt/include/firebolt/macros/materializations/models/incremental/column_helpers.sql,sha256=7XQsKdqcnKaIUxll4Etfa59HtF-3R3NfeSgpavBSJQE,917
21
21
  dbt/include/firebolt/macros/materializations/models/incremental/incremental.sql,sha256=bd8f-O9KPo5wpL9MpKDHxTJ8wAjT7BOxyUFybR9MPu8,5905
22
22
  dbt/include/firebolt/macros/materializations/models/incremental/is_incremental.sql,sha256=8Zgg0wOgIDQK_SAwxi7zk7gr_6Q7WyqN8nflTYpoyG0,581
23
- dbt/include/firebolt/macros/materializations/models/incremental/merge.sql,sha256=oKdm2ohWa0PMclfk0m0oDKoQr0equU0MewbMwgUd8mw,1361
24
- dbt/include/firebolt/macros/materializations/models/incremental/on_schema_change.sql,sha256=nZ7uFT42MnEEGtCW--N4K4W-fUm_qG90xar66ErqQe8,3564
23
+ dbt/include/firebolt/macros/materializations/models/incremental/merge.sql,sha256=YPryPkUfVVrKVk5bSdGt0eMa5NdFMMvJW1OuQ6o2umw,1311
24
+ dbt/include/firebolt/macros/materializations/models/incremental/on_schema_change.sql,sha256=WxGhX22oJRhDVsR4nUWilCSIG-bb7efDC3AXcU8VbbQ,3933
25
25
  dbt/include/firebolt/macros/materializations/models/incremental/strategies.sql,sha256=8Xrr-XqWeTRTbgvbVuH7EikklCzooSl0tMtLvhNKT4A,5925
26
26
  dbt/include/firebolt/macros/utils/array_append.sql,sha256=woAedZFXFYh6TYXwJQCxKj4o5yo71yXBdk-nxcF4Kss,117
27
27
  dbt/include/firebolt/macros/utils/array_concat.sql,sha256=Q9yY_rhcITJH0bS12MJOkBl5PXJ-ScgFZTBrqmQtdmw,117
28
28
  dbt/include/firebolt/macros/utils/array_construct.sql,sha256=C1I8STXIEN4-Ms6_b1Fw7QqzaAiesjC3M4RWa6e3pBY,105
29
29
  dbt/include/firebolt/macros/utils/bool_or.sql,sha256=PlnQTFU2NFH1d8nbzLss_VHbYO06dd0f7hEyadSkxkk,87
30
- dbt/include/firebolt/macros/utils/cast_bool_to_text.sql,sha256=zascZw9BPvyNaqHDwSw4uh56a42ZvEW4PvEcrcQMsPA,180
30
+ dbt/include/firebolt/macros/utils/cast_bool_to_text.sql,sha256=ZUst68Bx6Xuls2TO2BjDkBUS1gj0z7upZwvF4r6cmN0,187
31
31
  dbt/include/firebolt/macros/utils/dateadd.sql,sha256=5xRi047b42aOYpCLnVPuQa3wXN9k1-3xNC4ta5p9AEA,202
32
- dbt/include/firebolt/macros/utils/datediff.sql,sha256=t5Fu_3PKeXoJcg8FYnv_UYjFL8qVoMSU7m8t2N_LbFs,213
32
+ dbt/include/firebolt/macros/utils/datediff.sql,sha256=cy-Ex1TOyddF23JnvqprOVFeCEpag_wTvNazEh7BURY,214
33
33
  dbt/include/firebolt/macros/utils/except.sql,sha256=AoIC6Lr9_qMpD3dNw0Fp_wqtT2nM3WhbvF8drHKx_zQ,186
34
34
  dbt/include/firebolt/macros/utils/intersect.sql,sha256=b8T-mB_qXgHN7dHTy0iA5oX029EPnyNfphW_96j0c94,192
35
35
  dbt/include/firebolt/macros/utils/listagg.sql,sha256=ncnvHyiD_S4cdAxU05_yIftkqc3mS6FB6742hyXG1ns,588
@@ -37,8 +37,8 @@ dbt/include/firebolt/macros/utils/position.sql,sha256=WPo9_bhvNYJooEAsHC9OcnNAwU
37
37
  dbt/include/firebolt/macros/utils/right.sql,sha256=_mm1_2MvlOH4O6CmYhgvVxMLfDxAvgv-EMwZ8OBOq-I,254
38
38
  dbt/include/firebolt/macros/utils/split_part.sql,sha256=5dUlbx3Pt1iWWaIlxiXyYUwUqzXuLLXMB-1aGJHNk4o,464
39
39
  dbt/include/firebolt/macros/utils/timestamps.sql,sha256=22g-QpJjBuBUQOHNpQ_TuMRa-cHxaxXPv8ItEUo-vEk,397
40
- dbt_firebolt-1.4.3.dist-info/LICENSE,sha256=Nn0EGvW3qmoZpBV_JVM3iPukFf3RiNCIizrWe_2oTHk,11354
41
- dbt_firebolt-1.4.3.dist-info/METADATA,sha256=Zr1cL27iXNRwApjdFrmyILCQJhIguFaY0Ykp-xFG1rY,4402
42
- dbt_firebolt-1.4.3.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
43
- dbt_firebolt-1.4.3.dist-info/top_level.txt,sha256=B2YH4he17ajilEWOGCKHbRcEJlCuZKwCcgFcLPntLsE,4
44
- dbt_firebolt-1.4.3.dist-info/RECORD,,
40
+ dbt_firebolt-1.4.4.dist-info/LICENSE,sha256=Nn0EGvW3qmoZpBV_JVM3iPukFf3RiNCIizrWe_2oTHk,11354
41
+ dbt_firebolt-1.4.4.dist-info/METADATA,sha256=aULXmg1kh0jJMuxwbO48I7ovklnZVI071m5zNz41c2U,4441
42
+ dbt_firebolt-1.4.4.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
43
+ dbt_firebolt-1.4.4.dist-info/top_level.txt,sha256=B2YH4he17ajilEWOGCKHbRcEJlCuZKwCcgFcLPntLsE,4
44
+ dbt_firebolt-1.4.4.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.40.0)
2
+ Generator: bdist_wheel (0.42.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5