Skip to content

Snowflake: parse CREATE WAREHOUSE#2388

Open
sabir-akhadov-localstack wants to merge 2 commits into
apache:mainfrom
localstack:pr/03-create-warehouse
Open

Snowflake: parse CREATE WAREHOUSE#2388
sabir-akhadov-localstack wants to merge 2 commits into
apache:mainfrom
localstack:pr/03-create-warehouse

Conversation

@sabir-akhadov-localstack

Copy link
Copy Markdown
Contributor

Snowflake supports CREATE WAREHOUSE to provision a virtual warehouse, and DROP WAREHOUSE to remove one. Neither parsed before this change.

CREATE OR REPLACE WAREHOUSE my_wh WITH WAREHOUSE_SIZE = 'XSMALL' AUTO_SUSPEND = 60;
DROP WAREHOUSE my_wh;

This adds Statement::CreateWarehouse and ObjectType::Warehouse. The warehouse properties and parameters are captured as KeyValueOptions (the same representation used for CREATE FILE FORMAT and friends), so the statement round-trips losslessly rather than discarding everything after the name. The optional leading WITH and the spaces around = are normalized away on display.

See the Snowflake CREATE WAREHOUSE docs.

Add `Statement::CreateWarehouse` and `ObjectType::Warehouse` so the parser
accepts `CREATE [OR REPLACE] WAREHOUSE [IF NOT EXISTS] <name>` with optional
warehouse properties/parameters, plus `DROP WAREHOUSE`.

Warehouse options are captured as `KeyValueOptions` so the statement
round-trips losslessly instead of discarding everything after the name.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@sabir-akhadov-localstack sabir-akhadov-localstack marked this pull request as ready for review June 24, 2026 10:33
Comment thread src/ast/mod.rs Outdated
Comment on lines +4545 to +4554
CreateWarehouse {
/// `OR REPLACE` flag.
or_replace: bool,
/// `IF NOT EXISTS` flag.
if_not_exists: bool,
/// Warehouse name.
name: ObjectName,
/// Warehouse properties and parameters (e.g. `WAREHOUSE_SIZE = 'XSMALL'`).
options: KeyValueOptions,
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we change the representation to use a named struct? i.e. CreateWarehouse(CreateWarehouse)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 3fc58f5 — moved to a named CreateWarehouse struct following the CreateUser pattern (struct + Display + From<CreateWarehouse> for Statement).

Address review feedback: change the inline-field variant to
CreateWarehouse(CreateWarehouse), following the CreateUser pattern.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
sabir-akhadov-localstack added a commit to localstack/datafusion-sqlparser-rs that referenced this pull request Jul 14, 2026
Follow the upstream convention requested on apache#2388: Statement variants
wrap a named struct (CreateExternalVolume, AlterExternalVolume,
DescribeExternalVolume, ShowExternalVolumes) instead of inline fields.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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

Successfully merging this pull request may close these issues.

2 participants