Esempio n. 1
0
 def alive_function(conn: SnowflakeConnection) -> Any:
     logger.debug('Check Snowflake connection')
     if hasattr(conn, 'is_closed'):
         try:
             return not conn.is_closed()
         except Exception:
             raise TypeError('is_closed is not a function')
Esempio n. 2
0
    def report_operations(self, connection: SnowflakeConnection,
                          operations: List[SqlOperation]):
        if connection.is_closed():
            # already closed, cannot proceed (and probably already tracked)
            return
        # update the tables names
        operations = [op.evolve_table_name(connection) for op in operations]

        # looks for tables schemas
        tables = chain.from_iterable(op.tables for op in operations
                                     if not op.is_file)

        tables_schemas: Dict[str, DTypes] = {}
        for table in tables:
            table_schema = get_snowflake_table_schema(connection, table)
            if table_schema:
                tables_schemas[table] = table_schema

        operations: List[SqlOperation] = [
            op.evolve_schema(tables_schemas) for op in operations
        ]

        for op in operations:
            log_dataset_op(
                op_path=render_connection_path(connection, op, "snowflake"),
                op_type=op.op_type,
                success=op.success,
                data=op,
                with_schema=True,
                send_metrics=True,
            )