Skip to content

Commit 988e6c1

Browse files
niteshyNitesh Yadav
andauthored
DBT-704: Changes required for making it compatible with dbt-core 1.4 and 1.5 (#175)
Co-authored-by: Nitesh Yadav <[email protected]>
1 parent 9c2be85 commit 988e6c1

File tree

7 files changed

+26
-17
lines changed

7 files changed

+26
-17
lines changed

dbt/adapters/impala/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
version = "1.3.2"
15+
version = "1.4.0"

dbt/adapters/impala/connections.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def __pre_deserialize__(cls, data):
7878
def __post_init__(self):
7979
# impala classifies database and schema as the same thing
8080
if self.database is not None and self.database != self.schema:
81-
raise dbt.exceptions.RuntimeException(
81+
raise dbt.exceptions.DbtRuntimeError(
8282
f" schema: {self.schema} \n"
8383
f" database: {self.database} \n"
8484
f"On Impala, database must be omitted or have the same value as"
@@ -169,20 +169,20 @@ def exception_handler(self, sql: str):
169169
yield
170170
except HttpError as httpError:
171171
logger.debug(f"Authorization error: {httpError}")
172-
raise dbt.exceptions.RuntimeException(
172+
raise dbt.exceptions.DbtRuntimeError(
173173
"HTTP Authorization error: " + str(httpError) + ", please check your credentials"
174174
)
175175
except HiveServer2Error as servError:
176176
logger.debug(f"Server connection error: {servError}")
177-
raise dbt.exceptions.RuntimeException(
177+
raise dbt.exceptions.DbtRuntimeError(
178178
"Unable to establish connection to Impala server: " + str(servError)
179179
)
180180
except DatabaseError as dbError:
181181
logger.debug(f"Database connection error: {str(dbError)}")
182182
raise dbt.exceptions.DatabaseException("Database Connection error: " + str(dbError))
183183
except Exception as exc:
184184
logger.debug(f"Error running SQL: {sql}")
185-
raise dbt.exceptions.RuntimeException(str(exc))
185+
raise dbt.exceptions.DbtRuntimeError(str(exc))
186186

187187
@classmethod
188188
def open(cls, connection):

dbt/adapters/impala/impl.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
from dbt.clients import agate_helper
2525
from dbt.clients.agate_helper import ColumnTypeBuilder, NullableAgateType, _NullMarker
2626
from dbt.events import AdapterLogger
27-
from dbt.exceptions import warn_or_error
2827
from dbt.utils import executor
2928

3029
import dbt.adapters.impala.cloudera_tracking as tracker
@@ -103,7 +102,7 @@ def list_relations_without_caching(
103102

104103
try:
105104
results = self.execute_macro(LIST_RELATIONS_MACRO_NAME, kwargs=kwargs)
106-
except dbt.exceptions.RuntimeException as e:
105+
except dbt.exceptions.DbtRuntimeError as e:
107106
errmsg = getattr(e, "msg", "")
108107
if f"Database '{schema_relation}' not found" in errmsg:
109108
return []
@@ -115,7 +114,7 @@ def list_relations_without_caching(
115114
relations = []
116115
for row in results:
117116
if len(row) != 2:
118-
raise dbt.exceptions.RuntimeException(
117+
raise dbt.exceptions.DbtRuntimeError(
119118
f'Invalid value from "show table extended ...", '
120119
f"got {len(row)} values, expected 4"
121120
)
@@ -152,7 +151,7 @@ def get_columns_in_relation(self, relation: Relation) -> List[ImpalaColumn]:
152151
try:
153152
rows: List[agate.Row] = super().get_columns_in_relation(relation)
154153
columns = self.parse_describe_extended(relation, rows)
155-
except dbt.exceptions.RuntimeException as e:
154+
except dbt.exceptions.DbtRuntimeError as e:
156155
# impala would throw error when table doesn't exist
157156
errmsg = getattr(e, "msg", "")
158157
if (

dbt/adapters/impala/relation.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from dataclasses import dataclass
15+
from dataclasses import dataclass, field
1616

1717
from dbt.adapters.base.relation import BaseRelation, Policy
18-
from dbt.exceptions import RuntimeException
1918

2019
import dbt.adapters.impala.cloudera_tracking as tracker
2120

@@ -36,8 +35,8 @@ class ImpalaIncludePolicy(Policy):
3635

3736
@dataclass(frozen=True, eq=False, repr=False)
3837
class ImpalaRelation(BaseRelation):
39-
quote_policy: ImpalaQuotePolicy = ImpalaQuotePolicy()
40-
include_policy: ImpalaIncludePolicy = ImpalaIncludePolicy()
38+
quote_policy: ImpalaQuotePolicy = field(default_factory=lambda: ImpalaQuotePolicy())
39+
include_policy: ImpalaIncludePolicy = field(default_factory=lambda: ImpalaIncludePolicy())
4140
quote_character: str = None
4241
information: str = None
4342

dev-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
dbt-tests-adapter==1.3.*
1+
dbt-tests-adapter==1.4.*
22
pre-commit~=2.21;python_version=="3.7"
33
pre-commit~=3.2;python_version>="3.8"
44
pytest

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def _get_dbt_core_version():
4646

4747
package_name = "dbt-impala"
4848
# make sure this always matches dbt/adapters/dbt_impala/__version__.py
49-
package_version = "1.3.2"
49+
package_version = "1.4.0"
5050
description = """The Impala adapter plugin for dbt"""
5151

5252
dbt_core_version = _get_dbt_core_version()

tests/functional/adapter/test_utils.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,19 @@ def models(self):
168168

169169

170170
models__test_escape_single_quotes_quote_sql = """
171-
select '{{ escape_single_quotes("they're") }}' as actual, 'they\\'re' as expected union all
172-
select '{{ escape_single_quotes("they are") }}' as actual, 'they are' as expected
171+
select
172+
'{{ escape_single_quotes("they're") }}' as actual,
173+
'they\\'re' as expected,
174+
{{ length(string_literal(escape_single_quotes("they're"))) }} as actual_length,
175+
7 as expected_length
176+
177+
union all
178+
179+
select
180+
'{{ escape_single_quotes("they are") }}' as actual,
181+
'they are' as expected,
182+
{{ length(string_literal(escape_single_quotes("they are"))) }} as actual_length,
183+
8 as expected_length
173184
"""
174185

175186

0 commit comments

Comments
 (0)