Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Problem in Creating Spanner Graph other than Default Schema

Hi All, 

I am trying to create a graph on tables that is not in default schema. But I am not able to do so. Is this operation not supported or there is any other setting that I need to change?
Simplified DDL-

 

create schema TestSchema;
CREATE TABLE TestSchema.UsersTest (
    UserID INT64 NOT NULL,
    Name STRING(MAX))
    PRIMARY KEY (UserID);
CREATE TABLE TestSchema.ProductsTest (
    ProductID INT64 NOT NULL,
    ProductName STRING(MAX),)
    PRIMARY KEY (ProductID);
CREATE TABLE TestSchema.UserReviewsProductTest (
    ReviewID INT64 NOT NULL,
    UserID INT64 NOT NULL,
    ProductID INT64 NOT NULL,
    Rating INT64)
    PRIMARY KEY (ReviewID);
CREATE PROPERTY GRAPH `TestSchema`.`MyGraphTest`
NODE TABLES (
    TestSchema.UsersTest,
    TestSchema.ProductsTest
);

 

gives me following error-

Pr4sh4nt_0-1745226308445.png

Moreover, If I try to create graph in default schema, it does not recognise tables created in  other label. 

 

CREATE PROPERTY GRAPH `MyGraphTest`
NODE TABLES (
    TestSchema.UsersTest,
    TestSchema.ProductsTest
);

 

Pr4sh4nt_1-1745226468466.png

Can anyone please help me with this.

@mcbsalceda 

0 1 457
1 REPLY 1

The issue you're encountering stems from a current limitation in the Spanner Graph feature. While Spanner supports named schemas, the CREATE PROPERTY GRAPH statement in Spanner Graph does not support schema-qualified table names. This means that when defining a property graph, you must reference tables without their schema qualifiers.

Workaround:

To utilize the Spanner Graph feature effectively:

  1. Define your tables in the default schema (i.e., without specifying a schema name):

     
    CREATE TABLE UsersTest (
      UserID INT64 NOT NULL,
      Name STRING(MAX)
    ) PRIMARY KEY (UserID);
    
  2. Create the property graph without schema qualifiers:

     
    CREATE PROPERTY GRAPH MyGraphTest
      NODE TABLES (
        UsersTest
      );