Skip to content

ASTcolumn_type.toString() doesn't handle UUID type #238

@matsnow

Description

@matsnow

Description

Schemas containing UUID columns cause an IllegalArgumentException at runtime when generating diff output.

Steps to Reproduce

  1. Create an empty DDL file and a DDL file with a UUID column:
    -- empty.sql
    -- (empty)
    
    -- new.sql
    CREATE TABLE test (id UUID NOT NULL) PRIMARY KEY (id);
  2. Run:
    java -jar spanner-ddl-diff.jar --originalDdlFile empty.sql --newDdlFile new.sql --outputDdlFile diff.sql
    
  3. Exception thrown:
    Exception in thread "main" java.lang.IllegalArgumentException: Unknown column type UUID
         at com.google.cloud.solutions.spannerddl.parser.ASTcolumn_type.toString(ASTcolumn_type.java:75)
    

Root Cause

ASTcolumn_type.java:toString() has a switch statement that handles almost all types such as FLOAT32, INT64, BOOL, etc — but not UUID.

The parser correctly recognizes UUID in ddl_parser.jjt (line 393), so parsing succeeds, but the Java code that converts the AST back to DDL text fails at the switch statement's default branch.

Suggested Fix

Add case "UUID": to the switch in ASTcolumn_type.toString(), falling through to return typeName; (same pattern as other parameterless types like BOOL, DATE).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions