Skip to content

Commit

Permalink
fix(ingestion/vertica): support columns with timestamp precision (dat…
Browse files Browse the repository at this point in the history
…ahub-project#6295)

Co-authored-by: İnanç Dokurel <[email protected]>
Fixes datahub-project#5295
  • Loading branch information
inancdokurel authored and cccs-Dustin committed Feb 1, 2023
1 parent a66390c commit 176359f
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion metadata-ingestion/src/datahub/ingestion/source/sql/vertica.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,37 @@ class UUID(String):
__visit_name__ = "UUID"


class TIMESTAMP_WITH_PRECISION(TIMESTAMP):
"""The SQL TIMESTAMP With Precision type.
Since Vertica supports precision values for timestamp this allows ingestion
of timestamp fields with precision values.
PS: THIS DATA IS CURRENTLY UNUSED, IT JUST FIXES INGESTION PROBLEMS
TODO: Should research the possibility of reflecting the precision in the schema
"""

__visit_name__ = "TIMESTAMP"

def __init__(self, timezone=False, precision=None):
"""Construct a new :class:`_types.TIMESTAMP_WITH_PRECISION`.
:param timezone: boolean. Indicates that the TIMESTAMP type should
enable timezone support, if available on the target database.
On a per-dialect basis is similar to "TIMESTAMP WITH TIMEZONE".
If the target database does not support timezones, this flag is
ignored.
:param precision: integer. Indicates the PRECISION field when provided
"""
super(TIMESTAMP, self).__init__(timezone=timezone)
self.precision = precision


def TIMESTAMP_WITH_TIMEZONE(*args, **kwargs):
kwargs["timezone"] = True
return TIMESTAMP(*args, **kwargs)
return TIMESTAMP_WITH_PRECISION(*args, **kwargs)


def TIME_WITH_TIMEZONE(*args, **kwargs):
Expand Down Expand Up @@ -175,6 +203,7 @@ def _get_column_info( # noqa: C901
break

self.ischema_names["UUID"] = UUID
self.ischema_names["TIMESTAMP"] = TIMESTAMP_WITH_PRECISION
self.ischema_names["TIMESTAMPTZ"] = TIMESTAMP_WITH_TIMEZONE
self.ischema_names["TIMETZ"] = TIME_WITH_TIMEZONE

Expand Down

0 comments on commit 176359f

Please sign in to comment.