Skip to content

Commit 2f4baed

Browse files
Merge pull request #1388 from data-integrations/spanner_fixes
[🍒][PLUGIN-1761][PLUGIN-1748] Add information about no primary key table and improve error logging
2 parents 0df4712 + 887620b commit 2f4baed

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

docs/Spanner-batchsink.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ Each record is composed of columns (also called fields).
4242
Every table is defined by a schema that describes the column names, data types, and other information.
4343
If the table does not exist, it will get created.
4444

45+
**Note**: A table with no primary key columns can have only one row.
46+
Only GoogleSQL-dialect databases can have tables without a primary key.
47+
Please click [here](https://cloud.google.com/spanner/docs/schema-and-data-model) for more details.
48+
4549
**Primary Key**: If the table does not exist, a primary key must be provided in order to auto-create the table.
4650
The key can be a composite key of multiple fields in the schema. This is not required if the table already exists.
4751

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
<groupId>io.cdap.plugin</groupId>
2222
<artifactId>google-cloud</artifactId>
23-
<version>0.22.7</version>
23+
<version>0.22.8-SNAPSHOT</version>
2424
<name>Google Cloud Plugins</name>
2525
<packaging>jar</packaging>
2626
<description>Plugins for Google Big Query</description>

src/main/java/io/cdap/plugin/gcp/spanner/sink/SpannerSinkConfig.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ public class SpannerSinkConfig extends PluginConfig {
5757
private static final String NAME_CMEK_KEY = "cmekKey";
5858

5959
@Name(NAME_TABLE)
60-
@Description("Cloud Spanner table id. Uniquely identifies your table within the Cloud Spanner database")
60+
@Description("Cloud Spanner table id. Uniquely identifies your table within the Cloud Spanner database."
61+
+ " Note: A table with no primary key columns can have only one row."
62+
+ " Only GoogleSQL-dialect databases can have tables without a primary key."
63+
+ " Please refer to https://cloud.google.com/spanner/docs/schema-and-data-model for more details.")
6164
@Macro
6265
private String table;
6366

src/main/java/io/cdap/plugin/gcp/spanner/source/SpannerSource.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,11 @@ public void configurePipeline(PipelineConfigurer pipelineConfigurer) {
129129
} catch (SpannerException e) {
130130
// this is because spanner exception error message is not very user friendly. It contains class names and new
131131
// lines in the error message.
132-
collector.addFailure("Unable to connect to spanner instance.",
133-
"Verify spanner configurations such as instance, database, table, project, etc.")
134-
.withStacktrace(e.getStackTrace());
132+
collector.addFailure(String.format(
133+
"Unable to connect to spanner instance with error code: %s and error message: %s",
134+
e.getErrorCode().name(), e.getMessage()),
135+
"Verify spanner configurations such as instance, database, table, project, etc.")
136+
.withStacktrace(e.getStackTrace());
135137
}
136138
}
137139

0 commit comments

Comments
 (0)