Skip to content

spanner/spansql: Cannot handle UUID base type #14506

@adamhicks

Description

@adamhicks

Client

Spanner

cloud.google.com/go/spanner/spansql

v1.91.0

Environment

go 1.26

Code and Dependencies

Playground

package main

import (
	"fmt"

	"cloud.google.com/go/spanner/spansql"
)

func processDDL(ddl string) *spansql.CreateTable {
	out, err := spansql.ParseDDL("", ddl)
	if err != nil {
		panic(err)
	}
	return out.List[0].(*spansql.CreateTable)
}

func main() {
	valid := `CREATE TABLE tname (id int64) PRIMARY KEY (id)`
	invalid := `CREATE TABLE tname (id UUID) PRIMARY KEY (id)`

	for _, s := range []string{valid, invalid} {
		stmt := processDDL(s)
		fmt.Println("Base type of column 1 is:", stmt.Columns[0].Type.Base.SQL())
		fmt.Println("--- Reconstructed SQL ---")
		fmt.Println(stmt.SQL())
		fmt.Println("---")
	}
}

Output

Base type of column 1 is: INT64
--- Reconstructed SQL ---
CREATE TABLE tname (
  id INT64,
) PRIMARY KEY(id)
---
Base type of column 1 is: PROTO
--- Reconstructed SQL ---
CREATE TABLE tname (
  id `UUID`,
) PRIMARY KEY(id)
---

Expected behavior

SQL is processed and UUID type is identified/handled such that it can be reproduced later on.

Actual behavior

UUID type is interpreted into a PROTO base type and results in an escaped column definition when we attempt to reproduce the SQL string.

Additional context

PR fix: #14117

Metadata

Metadata

Assignees

Labels

api: spannerIssues related to the Spanner API.triage meI really want to be triaged.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions