Skip to content

Commit

Permalink
feat(spanner/spansql): add complete set of string functions (#3625)
Browse files Browse the repository at this point in the history
This doesn't implement them, but only declares them for accurate
parsing.

Fixes #3618.
  • Loading branch information
dsymonds committed Jan 28, 2021
1 parent 98637e0 commit 34027ad
Showing 1 changed file with 45 additions and 14 deletions.
59 changes: 45 additions & 14 deletions spanner/spansql/keywords.go
Expand Up @@ -127,25 +127,56 @@ var keywords = map[string]bool{

// funcs is the set of reserved keywords that are functions.
// https://cloud.google.com/spanner/docs/functions-and-operators
var funcs = map[string]bool{
var funcs = make(map[string]bool)

func init() {
for _, f := range allFuncs {
funcs[f] = true
}
}

var allFuncs = []string{
// TODO: many more

// Aggregate functions.
"ANY_VALUE": true,
"ARRAY_AGG": true,
"AVG": true,
"BIT_XOR": true,
"COUNT": true,
"MAX": true,
"MIN": true,
"SUM": true,
"ANY_VALUE",
"ARRAY_AGG",
"AVG",
"BIT_XOR",
"COUNT",
"MAX",
"MIN",
"SUM",

// Mathematical functions.
"ABS": true,
"ABS",

// Hash functions.
"SHA1": true,
"SHA1",

// String functions.
"CHAR_LENGTH": true,

// TODO: many more
"BYTE_LENGTH", "CHAR_LENGTH", "CHARACTER_LENGTH",
"CODE_POINTS_TO_BYTES", "CODE_POINTS_TO_STRING",
"CONCAT",
"ENDS_WITH",
"FORMAT",
"FROM_BASE32", "FROM_BASE64", "FROM_HEX",
"LENGTH",
"LOWER",
"LPAD",
"LTRIM",
"REGEXP_CONTAINS", "REGEXP_EXTRACT", "REGEXP_EXTRACT_ALL", "REGEXP_REPLACE",
"REPEAT",
"REPLACE",
"REVERSE",
"RPAD",
"RTRIM",
"SAFE_CONVERT_BYTES_TO_STRING",
"SPLIT",
"STARTS_WITH",
"STRPOS",
"SUBSTR",
"TO_BASE32", "TO_BASE64", "TO_CODE_POINTS", "TO_HEX",
"TRIM",
"UPPER",
}

0 comments on commit 34027ad

Please sign in to comment.