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

[ADAP-733] [Bug] Test suite sql runner does not support multi-line statements #710

Closed
2 tasks done
mikealfare opened this issue Jul 27, 2023 · 1 comment
Closed
2 tasks done

Comments

@mikealfare
Copy link
Contributor

Is this a new bug in dbt-snowflake?

  • I believe this is a new bug in dbt-snowflake
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

The following method raises an exception:

def query_target_lag(project, dynamic_table: SnowflakeRelation) -> Optional[str]:
    sql = f"""
        show dynamic tables
            like '{ dynamic_table.identifier }'
            in schema { dynamic_table.schema }
        ;
        select "target_lag"
        from table(result_scan(last_query_id()))
    """
    return project.run_sql(sql, fetch="one")

The exception indicates that the API was expecting 1 statement but it received two.

Expected Behavior

The method above returns the target lag for the table.

Steps To Reproduce

This only happens in the test environment, the adapter itself can execute multi-line statements.

  1. Create a sql command as a multi-line statement
  2. Pass the sql command into project.run_sql()

Relevant log output

No response

Environment

- OS: MacOS
- Python: py38
- dbt-core: 1.6+
- dbt-snowflake: 1.6+

Additional Context

No response

@mikealfare mikealfare added type:bug Something isn't working triage:product labels Jul 27, 2023
@github-actions github-actions bot changed the title [Bug] Test suite sql runner does not support multi-line statements [ADAP-733] [Bug] Test suite sql runner does not support multi-line statements Jul 27, 2023
@mikealfare
Copy link
Contributor Author

This has a reasonable workaround. While the project fixture does not allow multi-line commands, it's possible to create a macro that performs the same task, which can then be called via adapter.execute_macro().

@mikealfare mikealfare removed the type:bug Something isn't working label Dec 6, 2023
@mikealfare mikealfare closed this as not planned Won't fix, can't repro, duplicate, stale Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants