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

Fix for inconsistent Bigint/Long datatype that makes dbt think there was a schema change #358

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
26c9d42
fixing biging/long unconsistent datatype
francescomucio May 14, 2022
98ea5e3
More consistent results from get_columns_in_relation (#355)
jtcohen6 May 16, 2022
6bb2f82
Merge branch 'main' into main
francescomucio Jun 13, 2022
4c944e3
merged upstream
francescomucio Jun 29, 2022
ccfb64f
added entry in CHANGELOG.md
francescomucio Jun 29, 2022
a8e4302
fixed end-of-file
francescomucio Jul 26, 2022
d39b0a3
Revert #367 (#378)
jtcohen6 Jun 30, 2022
43c1c2d
Not dropping table for incremental full refresh with delta (#287)
grindheim Jul 5, 2022
cfda7ed
Data type macros (#380)
jtcohen6 Jul 6, 2022
3675494
Fix changelog for spark upgrade feature (#385)
nssalian Jul 8, 2022
af7fae3
Use lowercase file ext for CONTRIBUTING.md (#384)
jaceklaskowski Jul 11, 2022
f5db7e6
Add apply_grants call to materialization macros (#381)
gshank Jul 12, 2022
49fb9d4
Bumping version to 1.3.0a1 (#393)
github-actions[bot] Jul 12, 2022
b45d63e
[CT-868] Pin pyodbc in dbt-spark (#398)
barberscott Jul 21, 2022
54a5ef2
Updating CI pip and py10 (#403)
leahwicz Jul 22, 2022
2161d64
Fixing one more pip reference in CI (#405)
leahwicz Jul 22, 2022
2b8d12c
Change to support core incremental refactor (#394)
gshank Jul 25, 2022
f5feb16
Merge branch 'dbt-labs:main' into main
francescomucio Jul 26, 2022
b4d012d
moved fix description to the lates version in the CHANGELOG.md
francescomucio Jul 26, 2022
6edd45f
removed duplicated function definition
francescomucio Jul 26, 2022
424bb7c
Merge branch 'main' into main
francescomucio Sep 16, 2022
477e537
Merge branch 'dbt-labs:main' into main
francescomucio Sep 23, 2022
179311f
Fixed changelog
francescomucio Sep 23, 2022
5e6a7cd
fixed typo
francescomucio Sep 23, 2022
61611ed
changie-ed
francescomucio Sep 23, 2022
f04993f
Merge branch 'main' into main
McKnight-42 Sep 14, 2023
389fc73
Merge branch 'main' into main
colin-rogers-dbt Oct 11, 2023
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
8 changes: 8 additions & 0 deletions .changes/unreleased/Fixes-20220923-185533.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
kind: Fixes
body: Handled inconsistent Bigint/Long datatype returned by Spark using `describe`
and `show table extended`
time: 2022-09-23T18:55:33.119505+02:00
custom:
Author: francescomucio
Issue: "357"
PR: "358"
12 changes: 8 additions & 4 deletions dbt/adapters/spark/column.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dataclasses import dataclass
from typing import Any, Dict, Optional, TypeVar, Union
from typing import Any, ClassVar, Dict, Optional, TypeVar, Union

from dbt.adapters.base.column import Column
from dbt.dataclass_schema import dbtClassMixin
Expand All @@ -17,9 +17,13 @@ class SparkColumn(dbtClassMixin, Column):
table_stats: Optional[Dict[str, Any]] = None
column_index: Optional[int] = None

TYPE_LABELS: ClassVar[Dict[str, str]] = {
"LONG": "BIGINT",
}

@classmethod
def translate_type(cls, dtype: str) -> str:
return dtype
return super().translate_type(dtype).lower()

def can_expand_to(self: Self, other_column: Self) -> bool: # type: ignore
"""returns True if both columns are strings"""
Expand All @@ -34,7 +38,7 @@ def quoted(self) -> str:

@property
def data_type(self) -> str:
return self.dtype
return self.translate_type(self.dtype)

@classmethod
def numeric_type(cls, dtype: str, precision: Any, scale: Any) -> str:
Expand All @@ -45,7 +49,7 @@ def numeric_type(cls, dtype: str, precision: Any, scale: Any) -> str:
return "{}({},{})".format("decimal", precision, scale)

def __repr__(self) -> str:
return "<SparkColumn {} ({})>".format(self.name, self.data_type)
return "<SparkColumn {} ({})>".format(self.name, self.translate_type(self.data_type))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.data_type is already translated?


@staticmethod
def convert_table_stats(raw_stats: Optional[str]) -> Dict[str, Any]:
Expand Down
Loading