Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quotes in schema check #1184

Open
vijaykiran opened this issue Mar 28, 2022 · 1 comment
Open

Quotes in schema check #1184

vijaykiran opened this issue Mar 28, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@vijaykiran
Copy link
Contributor

Testing checks with quotes on table names and column names.

  • Test 001: I can successfully execute a scan for row_count check with quotes on table name.
  • Test 002: I can successfully execute a scan for schema check without quotes on table name.
  • Test 003: I cannot execute a scan for schema check with quotes on table name.

Set up:

  • using sodacl-workshop repo with latest version of soda-core
  • db is adventureworks running in docker container on the sodacl-workshop repo
  • connected to dev.sodadata.io account with API keys set in configuration.yml

Test 001 - row_count check with table name in quotes; works as expected
checks.yml:

checks for "dim_account":
  - row_count > 0

configuration.yml

data_source adventureworks:
  type: postgres
  connection:
    host: db
    username: postgres
    password: secret
  database: postgres
  schema: public

Scan input:
soda scan -d adventureworks -V -c configuration.yml checks.yml

Scan output:

Soda Core 0.0.1
Reading configuration file "configuration.yml"
Reading SodaCL file "checks.yml"
Scan execution starts
Query adventureworks."dim_account".aggregation[0]:
SELECT 
  COUNT(*) 
FROM "dim_account"
Scan summary:
1/1 query OK
  adventureworks."dim_account".aggregation[0] [OK] 0:00:00.034581
1/1 check PASSED: 
    "dim_account" in adventureworks
      row_count > 0 [PASSED]
        check_value: 99
All is good. No failures. No warnings. No errors.

Test 002 - schema check; works as expected
checks.yml:

checks for dim_account:
 - schema:
     warn:
       when required column missing: [sombrero]

configuration.yml
as above

Scan input:
soda scan -d adventureworks -V -c configuration.yml checks.yml

Scan output:

Soda Core 0.0.1
Reading configuration file "configuration.yml"
Reading SodaCL file "checks.yml"
Scan execution starts
Query adventureworks.dim_account.schema[dim_account]:
SELECT column_name, data_type, is_nullable 
FROM information_schema.columns 
WHERE lower(table_name) = 'dim_account' 
  AND lower(table_catalog) = 'postgres' 
  AND lower(table_schema) = 'public'
ORDER BY ORDINAL_POSITION
Scan summary:
1/1 query OK
  adventureworks.dim_account.schema[dim_account] [OK] 0:00:00.118499
1/1 check WARNED: 
    dim_account in adventureworks
      schema [WARNED]
        missing_column_names = [sombrero]
        schema_measured = [account_key integer, parent_account_key integer, account_code_alternate_key integer, parent_account_code_alternate_key integer, account_description character varying, account_type character varying, operator character varying, custom_members character varying, value_type character varying, custom_member_options character varying]
Only 1 warning. 0 failure. 0 errors. 0 pass.

Test 003 - schema check with table name in quotes; error
checks.yml:

checks for "dim_account":
 - schema:
     warn:
       when required column missing: [sombrero]

configuration.yml
as above

Scan input:
soda scan -d adventureworks -V -c configuration.yml checks.yml

Scan output:

Soda Core 0.0.1
Reading configuration file "configuration.yml"
Reading SodaCL file "checks.yml"
Scan execution starts
Query adventureworks."dim_account".schema["dim_account"]:
SELECT column_name, data_type, is_nullable 
FROM information_schema.columns 
WHERE lower(table_name) = '"dim_account"' 
  AND lower(table_catalog) = 'postgres' 
  AND lower(table_schema) = 'public'
ORDER BY ORDINAL_POSITION
Metrics schema were not computed for check schema
Scan summary:
1/1 query OK
  adventureworks."dim_account".schema["dim_account"] [OK] 0:00:00.097976
1/1 check NOT EVALUATED: 
    "dim_account" in adventureworks
      schema [NOT EVALUATED]
1 checks not evaluated.
1 errors.
Oops! 1 error. 0 failures. 0 warnings. 0 pass.
ERRORS:
Metrics schema were not computed for check schema
@tombaeyens
Copy link
Contributor

@vijaykiran Can you create skipped, failing unit tests and create a new issue for the failing ones?

@tombaeyens tombaeyens reopened this Mar 31, 2022
@tombaeyens tombaeyens changed the title Using quotes on table name with schema check doesn't work Quotes in schema check Mar 31, 2022
@tombaeyens tombaeyens added the bug Something isn't working label Mar 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants