enso/test/Snowflake_Tests
GregoryTravis 8260a9587f
Column-level lexically-scoped CTE expressions (#10826)
This implements `DB_Column.with`, which uses `WITH ... AS` SQL clauses to remove duplicates in the generated SQL.

After a discussion with @radeusgd, we concluded that we will probably want a more complete CTE implementation, so this one is useful for now to deal with big queries (like `round`).

# Important Notes
Still to do in this PR:

- [x] Rename `with` to `let` (or something similar)
- [x] tests
- [x] documentation
- [x] remove `State` hack by moving query generation into a class and using a `Ref` field for scoping

Results on `round_float`:

| --- | SQL length in characters (unprettified) | SQL length in lines (prettified) |
| --- | --- | --- |
| Without CTEs | 13193 | 851 |
| With CTEs | 3644 | 187 |

Compare the SQL:

[without-ctes.sql.txt](https://github.com/user-attachments/files/16629356/without-ctes.sql.txt)
[with-ctes.sql.txt](https://github.com/user-attachments/files/16629357/with-ctes.sql.txt)

Update, with name shortening:

| --- | SQL length in characters (unprettified) | SQL length in lines (prettified) |
| --- | --- | --- |
| Without CTEs | 13193 | 853 |
| With CTEs | 2427 | 176 |

[without-cte.txt](https://github.com/user-attachments/files/16694328/without-cte.txt)
[with-cte.txt](https://github.com/user-attachments/files/16694327/with-cte.txt)
2024-08-28 18:23:51 +00:00
..
src Column-level lexically-scoped CTE expressions (#10826) 2024-08-28 18:23:51 +00:00
package.yaml Initial separation of Snowflake_Dialect from Postgres_Dialect (#10266) 2024-06-13 16:12:20 +00:00
README.md Initial separation of Snowflake_Dialect from Postgres_Dialect (#10266) 2024-06-13 16:12:20 +00:00

This is a set of tests for the Snowflake integration for Enso.

Testing Snowflake

To run the tests, you need to prepare credentials for a Snowflake instance that can be used to run them on.

Please set the following environment variables:

  • ENSO_SNOWFLAKE_ACCOUNT - the account name for the Snowflake instance,
  • ENSO_SNOWFLAKE_USER - the username to use for the tests,
  • ENSO_SNOWFLAKE_PASSWORD - the password for the user, for security reasons this can be a plain text value or an Enso Secret. If using a secret, please provide it as path - enso://orgid/path/foo.secret,
  • ENSO_SNOWFLAKE_DATABASE - the name of the database to use for the tests,
  • ENSO_SNOWFLAKE_SCHEMA - the name of the schema to use for the tests, (optional, defaults to PUBLIC),
  • ENSO_SNOWFLAKE_WAREHOUSE - the name of the warehouse to use for the tests (optional, defaults to blank value).