Skip to content

Commit 80e17e5

Browse files
authored
Merge pull request #528 from cloudsufi/fem/cloud-postgresql
[PLUGIN-1831] Add CloudSQLPostgreSQLErrorDetailsProvider
2 parents 00c5e96 + 206d5c9 commit 80e17e5

File tree

4 files changed

+47
-0
lines changed

4 files changed

+47
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright © 2024 Cask Data, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+
* use this file except in compliance with the License. You may obtain a copy of
6+
* the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations under
14+
* the License.
15+
*/
16+
17+
package io.cdap.plugin.cloudsql.postgres;
18+
19+
import io.cdap.plugin.postgres.PostgresErrorDetailsProvider;
20+
import io.cdap.plugin.util.DBUtils;
21+
22+
/**
23+
* A custom ErrorDetailsProvider for CloudSQL PostgreSQL plugin.
24+
*/
25+
public class CloudSQLPostgreSQLErrorDetailsProvider extends PostgresErrorDetailsProvider {
26+
@Override
27+
protected String getExternalDocumentationLink() {
28+
return DBUtils.CLOUDSQLPOSTGRES_SUPPORTED_DOC_URL;
29+
}
30+
}

cloudsql-postgresql-plugin/src/main/java/io/cdap/plugin/cloudsql/postgres/CloudSQLPostgreSQLSink.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,11 @@ protected LineageRecorder getLineageRecorder(BatchSinkContext context) {
147147
return new LineageRecorder(context, assetBuilder.build());
148148
}
149149

150+
@Override
151+
protected String getErrorDetailsProviderClassName() {
152+
return CloudSQLPostgreSQLErrorDetailsProvider.class.getName();
153+
}
154+
150155
/** CloudSQL PostgreSQL sink config. */
151156
public static class CloudSQLPostgreSQLSinkConfig extends AbstractDBSpecificSinkConfig {
152157

cloudsql-postgresql-plugin/src/main/java/io/cdap/plugin/cloudsql/postgres/CloudSQLPostgreSQLSource.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,16 @@ protected Class<? extends DBWritable> getDBRecordType() {
8686
return PostgresDBRecord.class;
8787
}
8888

89+
@Override
90+
protected String getExternalDocumentationLink() {
91+
return DBUtils.CLOUDSQLPOSTGRES_SUPPORTED_DOC_URL;
92+
}
93+
94+
@Override
95+
protected String getErrorDetailsProviderClassName() {
96+
return CloudSQLPostgreSQLErrorDetailsProvider.class.getName();
97+
}
98+
8999
@Override
90100
protected String createConnectionString() {
91101
if (CloudSQLUtil.PRIVATE_INSTANCE.equalsIgnoreCase(

database-commons/src/main/java/io/cdap/plugin/util/DBUtils.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ public final class DBUtils {
6464
public static final String CLOUDSQLMYSQL_SUPPORTED_DOC_URL = "https://cloud.google.com/sql/docs/mysql/error-messages";
6565
public static final String POSTGRES_SUPPORTED_DOC_URL =
6666
"https://www.postgresql.org/docs/current/errcodes-appendix.html";
67+
public static final String CLOUDSQLPOSTGRES_SUPPORTED_DOC_URL =
68+
"https://cloud.google.com/sql/docs/postgres/error-messages";
6769

6870
// Java by default uses October 15, 1582 as a Gregorian cut over date.
6971
// Any timestamp created with time less than this cut over date is treated as Julian date.

0 commit comments

Comments
 (0)