gsqlsep

package module
v0.0.0-...-432be37 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2024 License: Apache-2.0 Imports: 2 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 SeparateInputPreserveCommentsWithStatus

func SeparateInputPreserveCommentsWithStatus(input string, customTerminators ...string) ([]InputStatement, Status)

SeparateInputPreserveCommentsWithStatus separates input for each statement and returns []InputStatement and Status. 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 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

type Status

type Status struct {
	WaitingString string
}

Jump to

Keyboard shortcuts

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