gsqlsep

package module
v0.0.0-...-29574a1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 31, 2023 License: Apache-2.0 Imports: 2 Imported by: 1

README

gsqlsep

A Go implementation of Google SQL(a.k.a. ZetaSQL) statement separator. Google SQL is the SQL dialect of Cloud Spanner, BigQuery, Apache Beam SQL ZetaSQL dialect, etc.

This is experimental and provided without warranty of any kind.

Features

  • Separate statements without syntax parsing.
  • Strip comments to support Cloud Spanner Admin API, which doesn't support comments in DDL.
    • (Experimental) Can preserve comments using SeparateInputPreserveComments, SeparateInputStringPreserveComments.
  • (Experimental) Alternative termination characters are customizable.
    • It is possible to support spanner-cli style command terminators \G.
      • Example: SELECT 1\G

Acknowledgements

The implementation of this package is almost a fork of spanner-cli which is derived from spansql.

References

Backgrounds

Statement separators tend to be reinvented because there are no reusable implementations.

Language Specifications

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SeparateInputString

func SeparateInputString(input string, customTerminators ...string) []string

SeparateInputString separates input for each statement and returns []string. This function strip all comments in input. By default, input will be separated by terminating semicolons `;`. In addition, customTerminators can be passed, and they will be treated as terminating semicolons.

func SeparateInputStringPreserveComments

func SeparateInputStringPreserveComments(input string, customTerminators ...string) []string

SeparateInputStringPreserveComments separates input for each statement and returns []string. This function preserve comments in input. By default, input will be separated by terminating semicolons `;`. In addition, customTerminators can be passed, and they will be treated as terminating semicolons.

Types

type InputStatement

type InputStatement struct {
	Statement  string
	Terminator string
}

func SeparateInput

func SeparateInput(input string, customTerminators ...string) []InputStatement

SeparateInput separates input for each statement and returns []InputStatement. This function strip all comments in input. By default, input will be separated by terminating semicolons `;`. In addition, customTerminators can be passed, and they will be treated as terminating semicolons.

func SeparateInputPreserveComments

func SeparateInputPreserveComments(input string, customTerminators ...string) []InputStatement

SeparateInputPreserveComments separates input for each statement and returns []InputStatement. This function preserve comments in input. By default, input will be separated by terminating semicolons `;`. In addition, customTerminators can be passed, and they will be treated as terminating semicolons.

func (*InputStatement) StripComments

func (stmt *InputStatement) StripComments() InputStatement

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL