GoogleCloudPlatform / GoogleCloudPlatform/spring-cloud-gcp

Spanner - Error while having the Interleaved table having only one primary key which is same as the parent table

Open
#1,646 6 comments 1 reaction 0 assignees View on GitHub
priority: p3 spanner type: enhancement
Dominant language
Java
Stars
551
Forks
349
Avg merge
1d 13h
Merged PRs (30d)
14

Description

**Describe the bug**
com.google.cloud.spring.data.spanner.core.mapping.SpannerDataException: A child table (tablename) must contain the primary key columns of its parent (tablename) in the same order starting the first column with additional key columns after.

If you have Interleave table that has only the same primary key as the Parent and doesnt have any additional key, then getting this Exception

Note: I have business reason to logically have another table to store separate information from ParentTable

Sample

```
public class Parent {

@PrimaryKey(keyOrder = 1)
@Column(name = "ParentId", nullable = false)
private String ParentId;

@Column(name = "details", nullable = false)
private String details

@Interleaved
private List parentLogical;

}

public class ParentLogical {

@PrimaryKey(keyOrder = 1)
@Column(name = "ParentId", nullable = false)
private String ParentId;

@Column(name = "associatedlogicalName", nullable = false)
private String associatedlogicalName

```
}

Contributor guide

Open the contributing guide

Research direction

No source files or tests are named. Start by locating the Spanner mapping validation that raises this exception and reproduce it with the Parent and ParentLogical entities from the issue; done means an interleaved child whose primary key contains only the parent's key is accepted, with regression coverage for that case.

Written by the indexing model from the issue text.

Assessment

Tech stack
gcp, java, spring
Domain
backend, cloud, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.