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(ingestion/vertica): support columns with timestamp precision #6295

Merged
35 changes: 34 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,41 @@ class UUID(String):
__visit_name__ = "UUID"


class TIMESTAMPWP(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.TIMESTAMPWP`.

: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_PRECISION(*args, **kwargs):
hsheth2 marked this conversation as resolved.
Show resolved Hide resolved
return TIMESTAMPWP(*args, **kwargs)


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


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

self.ischema_names["UUID"] = UUID
self.ischema_names["TIMESTAMP"] = TIMESTAMP_WITH_PRECISION
hsheth2 marked this conversation as resolved.
Show resolved Hide resolved
self.ischema_names["TIMESTAMPTZ"] = TIMESTAMP_WITH_TIMEZONE
self.ischema_names["TIMETZ"] = TIME_WITH_TIMEZONE

Expand Down