From 7e779e8daa91040456c9f0dfbb532eccc8c2db46 Mon Sep 17 00:00:00 2001 From: Pavel Makarichev Date: Wed, 25 Oct 2023 18:12:57 +0300 Subject: [PATCH] fix(snowflake): fix stage parsing error (#245) --- odd_collector/adapters/snowflake/adapter.py | 38 +++++++++++++-------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/odd_collector/adapters/snowflake/adapter.py b/odd_collector/adapters/snowflake/adapter.py index b537998f..1ae43cfb 100644 --- a/odd_collector/adapters/snowflake/adapter.py +++ b/odd_collector/adapters/snowflake/adapter.py @@ -9,6 +9,7 @@ from .client import SnowflakeClient, SnowflakeClientBase from .domain import Pipe, Table, View +from .logger import logger from .map import map_database, map_pipe, map_schemas, map_table, map_view @@ -33,22 +34,29 @@ def create_generator(self) -> Generator: ) def get_data_entity_list(self) -> DataEntityList: - raw_pipes = self._client.get_raw_pipes() - raw_stages = self._client.get_raw_stages() - pipes: List[Pipe] = [] - for raw_pipe in raw_pipes: - pipes.extend( - Pipe( - name=raw_pipe.pipe_name, - definition=raw_pipe.definition, - stage_url=raw_stage.stage_url, - stage_type=raw_stage.stage_type, - downstream=raw_pipe.downstream, + pipes_entities = [] + + # TODO: Create more user-friendly error messages and handle them + try: + raw_pipes = self._client.get_raw_pipes() + raw_stages = self._client.get_raw_stages() + pipes: list[Pipe] = [] + for raw_pipe in raw_pipes: + pipes.extend( + Pipe( + name=raw_pipe.pipe_name, + definition=raw_pipe.definition, + stage_url=raw_stage.stage_url, + stage_type=raw_stage.stage_type, + downstream=raw_pipe.downstream, + ) + for raw_stage in raw_stages + if raw_pipe.stage_full_name == raw_stage.stage_full_name ) - for raw_stage in raw_stages - if raw_pipe.stage_full_name == raw_stage.stage_full_name - ) - pipes_entities = [map_pipe(pipe, self.generator) for pipe in pipes] + pipes_entities = [map_pipe(pipe, self.generator) for pipe in pipes] + except Exception as e: + logger.warning(f"Can't get pipes and stages. {e}") + tables = self._client.get_tables() tables_with_data_entities: List[