Skip to content
This repository was archived by the owner on Nov 30, 2022. It is now read-only.
This repository was archived by the owner on Nov 30, 2022. It is now read-only.

Soda SQL analyze looks for tables in different schemas #344

@albinkjellin

Description

@albinkjellin

Describe the bug
When running analyze Soda SQL does seem to disregard the schema. When comparing the implementation of SQL Server with postgres it seems to be missing the schema part.

This is from postgres:

def sql_columns_metadata_query(self, table_name: str) -> str:
        sql = (f"SELECT column_name, data_type, is_nullable \n"
               f"FROM information_schema.columns \n"
               f"WHERE lower(table_name) = '{table_name}'")
        if self.database:
            sql += f" \n  AND table_catalog = '{self.database}'"
        if self.schema:
            sql += f" \n  AND table_schema = '{self.schema}'"
        return sql

Compared to SQL Server:

 def sql_columns_metadata_query(self, table_name: str) -> str:
        sql = (f"SELECT column_name, data_type, is_nullable \n"
               f"FROM INFORMATION_SCHEMA.COLUMNS \n"
               f"WHERE TABLE_NAME = '{table_name}'")
        return sql

This seems to explain the issue.

To Reproduce
Steps to reproduce the behavior:

  1. Create a new test in scan.yml
  2. Run soda scan ...
    3 ...

Context
Include your scan.yml or warehouse.yml when relevant

OS:
Python Version:
Soda SQL Version:
Warehouse Type:

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingsoda-sql

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions