可以将新的 table 交织到二级索引 table 中吗?

Possible to interleave a new table into a secondary index table?

我猜 没有 ,但是二级索引看起来很像 tables,因为你可以直接从它们 select [=14] =] 甚至 JOIN 在他们身上:

JOIN MyTable@{FORCE_INDEX=anIndexToUseFromMyTable} AS myTable

那么也许您可以创建一个新的 table 交错到索引中?

例子

CREATE TABLE Foo (
    primaryId STRING(64) NOT NULL,
    secondaryId STRING(64) NOT NULL,
    modifiedAt TIMESTAMP NOT NULL OPTIONS (allow_commit_timestamp=true),
) PRIMARY KEY (primaryId);

-- Index we would like to interleave into for another table
CREATE INDEX FooSecondaryIdIndex ON Foo(secondaryId);

-- interleave this table into the index above
-- and support DELETE CASCADE
CREATE TABLE Bar (
    secondaryId STRING(64) NOT NULL,
    extraData STRING(64) NOT NULL,
    modifiedAt TIMESTAMP NOT NULL OPTIONS (allow_commit_timestamp=true),
) PRIMARY KEY (secondaryId),
INTERLEAVE IN PARENT Foo@{FORCE_INDEX=FooSecondaryIdIndex} ON DELETE CASCADE;

嗯……好像不支持:

Error parsing Spanner DDL statement: CREATE TABLE Bar ( secondaryId STRING(64) NOT NULL, extraData STRING(64) NOT NULL, modifiedAt TIMESTAMP NOT NULL OPTIONS (allow_commit_timestamp=true), ) PRIMARY KEY (secondaryId), INTERLEAVE IN PARENT Foo@{FORCE_INDEX=FooSecondaryIdIndex} ON DELETE CASCADE : Syntax error on line 6, column 25: Expecting 'EOF' but found '@'