Skip to content

Commit

Permalink
feat(spanner/spansql): support NUMERIC data type (#3411)
Browse files Browse the repository at this point in the history
This adds support for NUMERIC as a column data type in CREATE TABLE and
similar constructions. Its support in spannertest remains a TODO.

Fixes #3395.
  • Loading branch information
dsymonds committed Dec 8, 2020
1 parent d1c03da commit 1bc65d9
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions spanner/spannertest/README.md
Expand Up @@ -18,6 +18,7 @@ Here's a list of features that are missing or incomplete. It is roughly ordered
by ascending esotericism:

- expression functions
- NUMERIC
- more aggregation functions
- SELECT HAVING
- case insensitivity
Expand Down
3 changes: 2 additions & 1 deletion spanner/spansql/parser.go
Expand Up @@ -1650,6 +1650,7 @@ var baseTypes = map[string]TypeBase{
"BOOL": Bool,
"INT64": Int64,
"FLOAT64": Float64,
"NUMERIC": Numeric,
"STRING": String,
"BYTES": Bytes,
"DATE": Date,
Expand All @@ -1664,7 +1665,7 @@ func (p *parser) parseType() (Type, *parseError) {
ARRAY< scalar_type >
scalar_type:
{ BOOL | INT64 | FLOAT64 | STRING( length ) | BYTES( length ) | DATE | TIMESTAMP }
{ BOOL | INT64 | FLOAT64 | NUMERIC | STRING( length ) | BYTES( length ) | DATE | TIMESTAMP }
length:
{ int64_value | MAX }
*/
Expand Down
2 changes: 2 additions & 0 deletions spanner/spansql/sql.go
Expand Up @@ -234,6 +234,8 @@ func (tb TypeBase) SQL() string {
return "INT64"
case Float64:
return "FLOAT64"
case Numeric:
return "NUMERIC"
case String:
return "STRING"
case Bytes:
Expand Down
3 changes: 2 additions & 1 deletion spanner/spansql/types.go
Expand Up @@ -293,7 +293,7 @@ func (Check) isConstraint() {}
// Type represents a column type.
type Type struct {
Array bool
Base TypeBase // Bool, Int64, Float64, String, Bytes, Date, Timestamp
Base TypeBase // Bool, Int64, Float64, Numeric, String, Bytes, Date, Timestamp
Len int64 // if Base is String or Bytes; may be MaxLen
}

Expand All @@ -306,6 +306,7 @@ const (
Bool TypeBase = iota
Int64
Float64
Numeric
String
Bytes
Date
Expand Down

0 comments on commit 1bc65d9

Please sign in to comment.