Skip to content

SPIKE(snowflake): begin of some whitespace preservation - #1

Open
cchepelov wants to merge 1 commit into
chore/migrate-to-peggyjsfrom
feat/preserve-whitespace-experiment
Open

SPIKE(snowflake): begin of some whitespace preservation#1
cchepelov wants to merge 1 commit into
chore/migrate-to-peggyjsfrom
feat/preserve-whitespace-experiment

Conversation

@cchepelov

Copy link
Copy Markdown
Owner

a time-boxed discovery experiment of what it would take to support preservation of whitespace.

I've concentrated on snowflake, and appear to have broken about everything else...

  • every use of __ and ___ would need to be bound to a return variable and consumed at the right time during the conversion of AST back to SQL.
  • when whitespace preservation isn't requested, every use of __ and ___ should instead be returned to '' or ' ' as currently... but in a "smart" way
  • expressions such as from_clause that currently return a list would become inconvenient; as we would need to:
    1. make them return a struct with the contents and the labelled whitespace containers
    2. wherever these clauses are used, we should unpack the struct back into the list on one hand, the whitespace containers on the other (in order to preserve the existing API)
    3. all of this has to be done in an identical manner in all 12 SQL parsers simultaneously

it's not unfeasible, but it is, unfortunately, a far more complex exercise than what I can commit at this moment.

I hope this is helpful!

@cchepelov
cchepelov force-pushed the feat/preserve-whitespace-experiment branch from 53afd3a to ccb7607 Compare March 12, 2024 06:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant