Fix #2678: Fixed vertica import errors and invalid dataTypeDisplay (#2709)

Co-authored-by: Mayur SIngal <mayursingal@Mayurs-MacBook-Pro.local>
This commit is contained in:
Mayur Singal 2022-02-10 20:52:29 +05:30 committed by GitHub
parent dc2c7c0fb7
commit c64f3fef34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 6 deletions

View File

@ -68,7 +68,8 @@
"SET", "SET",
"GEOGRAPHY", "GEOGRAPHY",
"ENUM", "ENUM",
"JSON" "JSON",
"UUID"
] ]
}, },
"constraint": { "constraint": {

View File

@ -522,13 +522,15 @@ class SQLSource(Source[OMetaDatabaseAndTable]):
repr(column["type"]), column["name"] repr(column["type"]), column["name"]
) )
) )
col_data_length = (
1 if col_data_length is None else col_data_length
)
dataTypeDisplay = ( dataTypeDisplay = (
f"{data_type_display}" f"{data_type_display}"
if data_type_display if data_type_display
else "{}({})".format(col_type, col_data_length) else "{}({})".format(col_type, col_data_length)
if col_data_length
else col_type
)
col_data_length = (
1 if col_data_length is None else col_data_length
) )
om_column = Column( om_column = Column(
name=column["name"], name=column["name"],

View File

@ -12,8 +12,10 @@
import re import re
from textwrap import dedent from textwrap import dedent
from sqlalchemy import exc, sql from sqlalchemy import exc, sql, util
from sqlalchemy.engine import reflection from sqlalchemy.engine import reflection
from sqlalchemy.sql import sqltypes
from sqlalchemy.sql.sqltypes import VARCHAR, String
from sqlalchemy_vertica.base import VerticaDialect from sqlalchemy_vertica.base import VerticaDialect
from metadata.ingestion.ometa.openmetadata_rest import MetadataServerConfig from metadata.ingestion.ometa.openmetadata_rest import MetadataServerConfig
@ -26,6 +28,13 @@ from metadata.utils.sql_queries import (
) )
class UUID(String):
"""The SQL UUID type."""
__visit_name__ = "UUID"
@reflection.cache @reflection.cache
def get_columns(self, connection, table_name, schema=None, **kw): def get_columns(self, connection, table_name, schema=None, **kw):
if schema is not None: if schema is not None:
@ -129,7 +138,7 @@ def _get_column_info(
args = () args = ()
elif charlen: elif charlen:
args = (int(charlen),) args = (int(charlen),)
self.ischema_names["UUID"] = UUID
if attype.upper() in self.ischema_names: if attype.upper() in self.ischema_names:
coltype = self.ischema_names[attype.upper()] coltype = self.ischema_names[attype.upper()]
else: else:

View File

@ -132,6 +132,7 @@ class ColumnTypeParser:
"VARIANT": "JSON", "VARIANT": "JSON",
"XML": "BINARY", "XML": "BINARY",
"XMLTYPE": "BINARY", "XMLTYPE": "BINARY",
"UUID": "UUID",
} }
_COMPLEX_TYPE = re.compile("^(struct|map|array|uniontype)") _COMPLEX_TYPE = re.compile("^(struct|map|array|uniontype)")