sodadata / soda-sql

Soda SQL and Soda Spark have been deprecated and replaced by Soda Core. docs.soda.io/soda-core/overview.html
https://docs.soda.io/
Apache License 2.0
61 stars 16 forks source link

Soda SQL analyze looks for tables in different schemas #344

Open albinkjellin opened 2 years ago

albinkjellin commented 2 years ago

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: