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

chore(ingest): fix mssql lint #6453

Merged
merged 1 commit into from
Nov 16, 2022
Merged
Changes from all commits
Commits
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
7 changes: 5 additions & 2 deletions metadata-ingestion/src/datahub/ingestion/source/sql/mssql.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,16 @@ def __init__(self, config: SQLServerConfig, ctx: PipelineContext):
@staticmethod
def _add_output_converters(conn: Connection) -> None:
def handle_sql_variant_as_string(value):
return value.decode('utf-16le')
return value.decode("utf-16le")

# see https://stackoverflow.com/questions/45677374/pandas-pyodbc-odbc-sql-type-150-is-not-yet-supported
# and https://stackoverflow.com/questions/11671170/adding-output-converter-to-pyodbc-connection-in-sqlalchemy
try:
conn.connection.add_output_converter(-150, handle_sql_variant_as_string)
except AttributeError as e:
logger.debug(f"Failed to mount output converter for MSSQL data type -150 due to {e}")
logger.debug(
f"Failed to mount output converter for MSSQL data type -150 due to {e}"
)

def _populate_table_descriptions(self, conn: Connection, db_name: str) -> None:
# see https://stackoverflow.com/questions/5953330/how-do-i-map-the-id-in-sys-extended-properties-to-an-object-name
Expand Down