diff --git a/great_expectations/expectations/metrics/util.py b/great_expectations/expectations/metrics/util.py index fb121471681a..65c0404ee3b0 100644 --- a/great_expectations/expectations/metrics/util.py +++ b/great_expectations/expectations/metrics/util.py @@ -19,11 +19,9 @@ overload, ) +import great_expectations.exceptions as gx_exceptions import numpy as np from dateutil.parser import parse -from packaging import version - -import great_expectations.exceptions as gx_exceptions from great_expectations.compatibility import aws, sqlalchemy, trino from great_expectations.compatibility.sqlalchemy import ( sqlalchemy as sa, @@ -40,6 +38,7 @@ GXSqlDialect, ) from great_expectations.execution_engine.util import check_sql_engine_dialect +from packaging import version try: import psycopg2 # noqa: F401 @@ -76,9 +75,10 @@ if TYPE_CHECKING: - import pandas as pd from typing_extensions import TypeAlias + import pandas as pd + try: import teradatasqlalchemy.dialect import teradatasqlalchemy.types as teradatatypes @@ -418,7 +418,10 @@ def get_sqlalchemy_column_metadata( # noqa: C901 # WARNING: Do not alter columns in place, as they are cached on the inspector columns_copy = [column.copy() for column in columns] for column in columns_copy: - column["type"] = column["type"].compile(dialect=execution_engine.dialect) + if column.get("type"): + # When using column_reflection_fallback, we might not be able to + # extract the column type, and only have the column name + column["type"] = column["type"].compile(dialect=execution_engine.dialect) if dialect_name == GXSqlDialect.SNOWFLAKE: return [ # TODO: SmartColumn should know the dialect and do lookups based on that