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

Test sql formatting #2890

Open
achicoine-coveo opened this issue Jul 10, 2024 · 0 comments
Open

Test sql formatting #2890

achicoine-coveo opened this issue Jul 10, 2024 · 0 comments
Labels
Feature Adds new functionality Improvement Improves existing functionality

Comments

@achicoine-coveo
Copy link

I understand this is more of a stretch, but if sqlmesh format could format the sql included in tests it would be a killer feature.

For example you can define test data like this:

test_attributed_queries:
  model: staging.attributed_queries
  inputs:
    source.query_history:
      # Use sql entry, so we can parse_json the query_tags correctly. Have to put all columns in the right order.
      query: |
        -- no query tag
        SELECT 
        '123' as query_id,
        null as query_type,
        'svc_bob' as user_name,
        null as role_name,
        null as warehouse_id,
        'common' as warehouse_name,
        'X-Small' as warehouse_size,
        'STANDARD' as warehouse_type,
        null as cluster_number,
        null as query_tag,
        cast('2024-06-01 01:05:00 +0000' as timestamptz) as start_time,
        null as total_elapsed_time,
        null as compilation_time,
        5 as execution_time,
        null as credits_used_cloud_services 

It should be possible for the formatter to extract the sql from the test, format it, and put it back.

@georgesittas georgesittas added Improvement Improves existing functionality Feature Adds new functionality labels Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Adds new functionality Improvement Improves existing functionality
Projects
None yet
Development

No branches or pull requests

2 participants