Skip to content

Feature Request: export simple statement parser #461

Description

@apstndb

Is your feature request related to a problem? Please describe.

Based on my experience looking at Spanner-related OSS projects such as spanner-cli (and its my fork, spanner-mycli), wrench, yo, and golang-migrate, I've observed that many of them don't require a full-fledged SQL parser. Instead, they typically need a subset of functionalities, specifically:

  • Statement splitting that correctly handles (or isn't confused by) semicolons within comments and string literals.
  • Statement type identification (often, just the first token after skipping any hints is sufficient).
  • Query parameter detection (though this is less commonly required).

Describe the solution you'd like

The implementation in go-sql-spanner/statement_parser.go provides an adequate solution for this use case. Although I understand there might still be potential for breaking changes, would it be possible to export this implementation once it becomes stable?

Describe alternatives you've considered

While cloudspannerecosystem/memefish, which includes a GoogleSQL lexer/parser, could be used to implement these, an additional (or separate) implementation would be necessary if a Spanner-supporting OSS project also needs to support the PostgreSQL interface in addition to the GoogleSQL interface.

Additional context
Add any other context or screenshots about the feature request here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: p3Desirable enhancement or fix. May not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions