Skip to content

Conversation

iffyio
Copy link
Contributor

@iffyio iffyio commented Feb 24, 2025

Add support for scripting statements

CASE product_id
  WHEN 1 THEN SELECT 1;
  WHEN 2 THEN SELECT 2;
  ELSE SELECT 3;
END CASE;
IF EXISTS(SELECT 1) THEN SELECT 1;
  ELSEIF EXISTS(SELECT 2) THEN SELECT 2;
  ELSE SELECT 3;
END IF;

BigQuery CASE
BigQuery IF
Snowflake CASE
Snowflake IF

Add support for scripting statements
```sql
CASE product_id
  WHEN 1 THEN SELECT 1;
  WHEN 2 THEN SELECT 2;
  ELSE SELECT 3;
END CASE;
```

```sql
IF EXISTS(SELECT 1) THEN SELECT 1;
  ELSEIF EXISTS(SELECT 2) THEN SELECT 2;
  ELSE SELECT 3;
END IF;
```

[BigQuery CASE](https://cloud.google.com/bigquery/docs/reference/standard-sql/procedural-language#case)

[BigQuery IF](https://cloud.google.com/bigquery/docs/reference/standard-sql/procedural-language#if)

[Snowflake CASE](https://docs.snowflake.com/en/sql-reference/snowflake-scripting/case)
[Snowflake IF](https://docs.snowflake.com/en/sql-reference/snowflake-scripting/if)
@iffyio iffyio requested a review from alamb March 13, 2025 07:56
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you @iffyio -- I found this PR really easy to read and review as it was well documented and well tested ❤️

has_end_case: _,
} = self;

union_spans(
Copy link
Contributor

Choose a reason for hiding this comment

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

this is quite fancy 👌

@iffyio
Copy link
Contributor Author

iffyio commented Mar 14, 2025

Thanks for the reviews @alamb!

@iffyio iffyio merged commit 862e887 into apache:main Mar 14, 2025
9 checks passed
@iffyio iffyio deleted the bq-case-stmts branch March 14, 2025 06:49
ayman-sigma pushed a commit to sigmacomputing/sqlparser-rs that referenced this pull request Apr 10, 2025
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