From ec6184d2dad4c17df950d7a9632afddddba5f709 Mon Sep 17 00:00:00 2001 From: Ayush Shah Date: Tue, 7 Nov 2023 12:10:59 +0530 Subject: [PATCH] Fix Trino Dialect Import issue (#13869) --- .../interface/sqlalchemy/sqa_test_suite_interface.py | 5 ++++- .../metadata/profiler/interface/pandas/profiler_interface.py | 5 ++++- .../interface/sqlalchemy/bigquery/profiler_interface.py | 5 ++++- .../profiler/interface/sqlalchemy/profiler_interface.py | 5 ++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/ingestion/src/metadata/data_quality/interface/sqlalchemy/sqa_test_suite_interface.py b/ingestion/src/metadata/data_quality/interface/sqlalchemy/sqa_test_suite_interface.py index 3d0c58863eb..0939d7c9e7c 100644 --- a/ingestion/src/metadata/data_quality/interface/sqlalchemy/sqa_test_suite_interface.py +++ b/ingestion/src/metadata/data_quality/interface/sqlalchemy/sqa_test_suite_interface.py @@ -32,7 +32,6 @@ from metadata.ingestion.ometa.ometa_api import OpenMetadata from metadata.ingestion.source.connections import get_connection from metadata.mixins.sqalchemy.sqa_mixin import SQAInterfaceMixin from metadata.profiler.processor.runner import QueryRunner -from metadata.profiler.processor.sampler.sampler_factory import sampler_factory_ from metadata.profiler.processor.sampler.sqlalchemy.sampler import SQASampler from metadata.utils.constants import TEN_MIN from metadata.utils.importer import import_test_case_class @@ -119,6 +118,10 @@ class SQATestSuiteInterface(SQAInterfaceMixin, TestSuiteInterface): def _create_sampler(self) -> SQASampler: """Create sampler instance""" + from metadata.profiler.processor.sampler.sampler_factory import ( # pylint: disable=import-outside-toplevel + sampler_factory_, + ) + return sampler_factory_.create( self.service_connection_config.__class__.__name__, client=self.session, diff --git a/ingestion/src/metadata/profiler/interface/pandas/profiler_interface.py b/ingestion/src/metadata/profiler/interface/pandas/profiler_interface.py index 8f879cbcdbc..064c00b5363 100644 --- a/ingestion/src/metadata/profiler/interface/pandas/profiler_interface.py +++ b/ingestion/src/metadata/profiler/interface/pandas/profiler_interface.py @@ -30,7 +30,6 @@ from metadata.mixins.pandas.pandas_mixin import PandasInterfaceMixin from metadata.profiler.interface.profiler_interface import ProfilerInterface from metadata.profiler.metrics.core import MetricTypes from metadata.profiler.metrics.registry import Metrics -from metadata.profiler.processor.sampler.sampler_factory import sampler_factory_ from metadata.readers.dataframe.models import DatalakeTableSchemaWrapper from metadata.utils.constants import COMPLEX_COLUMN_SEPARATOR from metadata.utils.datalake.datalake_utils import fetch_col_types, fetch_dataframe @@ -103,6 +102,10 @@ class PandasProfilerInterface(ProfilerInterface, PandasInterfaceMixin): def _get_sampler(self): """Get dataframe sampler from config""" + from metadata.profiler.processor.sampler.sampler_factory import ( # pylint: disable=import-outside-toplevel + sampler_factory_, + ) + return sampler_factory_.create( DatalakeConnection.__name__, client=self.client, diff --git a/ingestion/src/metadata/profiler/interface/sqlalchemy/bigquery/profiler_interface.py b/ingestion/src/metadata/profiler/interface/sqlalchemy/bigquery/profiler_interface.py index 6cd5b4e302f..338ad0ff03e 100644 --- a/ingestion/src/metadata/profiler/interface/sqlalchemy/bigquery/profiler_interface.py +++ b/ingestion/src/metadata/profiler/interface/sqlalchemy/bigquery/profiler_interface.py @@ -18,7 +18,6 @@ from sqlalchemy import Column, inspect from metadata.profiler.interface.sqlalchemy.profiler_interface import ( SQAProfilerInterface, ) -from metadata.profiler.processor.sampler.sampler_factory import sampler_factory_ class BigQueryProfilerInterface(SQAProfilerInterface): @@ -43,6 +42,10 @@ class BigQueryProfilerInterface(SQAProfilerInterface): def _get_sampler(self, **kwargs): """get sampler object""" + from metadata.profiler.processor.sampler.sampler_factory import ( # pylint: disable=import-outside-toplevel + sampler_factory_, + ) + session = kwargs.get("session") table = kwargs["table"] diff --git a/ingestion/src/metadata/profiler/interface/sqlalchemy/profiler_interface.py b/ingestion/src/metadata/profiler/interface/sqlalchemy/profiler_interface.py index 7a02eb806da..176c52f7ae1 100644 --- a/ingestion/src/metadata/profiler/interface/sqlalchemy/profiler_interface.py +++ b/ingestion/src/metadata/profiler/interface/sqlalchemy/profiler_interface.py @@ -40,7 +40,6 @@ from metadata.profiler.orm.functions.table_metric_construct import ( ) from metadata.profiler.orm.registry import Dialects from metadata.profiler.processor.runner import QueryRunner -from metadata.profiler.processor.sampler.sampler_factory import sampler_factory_ from metadata.utils.custom_thread_pool import CustomThreadPoolExecutor from metadata.utils.logger import profiler_interface_registry_logger @@ -108,6 +107,10 @@ class SQAProfilerInterface(ProfilerInterface, SQAInterfaceMixin): def _get_sampler(self, **kwargs): """get sampler object""" + from metadata.profiler.processor.sampler.sampler_factory import ( # pylint: disable=import-outside-toplevel + sampler_factory_, + ) + session = kwargs.get("session") table = kwargs["table"]