Skip to content

Commit

Permalink
Merge pull request #528 from cloudsufi/fem/cloud-postgresql
Browse files Browse the repository at this point in the history
[PLUGIN-1831] Add CloudSQLPostgreSQLErrorDetailsProvider
  • Loading branch information
psainics authored Dec 27, 2024
2 parents 00c5e96 + 206d5c9 commit 80e17e5
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright © 2024 Cask Data, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/

package io.cdap.plugin.cloudsql.postgres;

import io.cdap.plugin.postgres.PostgresErrorDetailsProvider;
import io.cdap.plugin.util.DBUtils;

/**
* A custom ErrorDetailsProvider for CloudSQL PostgreSQL plugin.
*/
public class CloudSQLPostgreSQLErrorDetailsProvider extends PostgresErrorDetailsProvider {
@Override
protected String getExternalDocumentationLink() {
return DBUtils.CLOUDSQLPOSTGRES_SUPPORTED_DOC_URL;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ protected LineageRecorder getLineageRecorder(BatchSinkContext context) {
return new LineageRecorder(context, assetBuilder.build());
}

@Override
protected String getErrorDetailsProviderClassName() {
return CloudSQLPostgreSQLErrorDetailsProvider.class.getName();
}

/** CloudSQL PostgreSQL sink config. */
public static class CloudSQLPostgreSQLSinkConfig extends AbstractDBSpecificSinkConfig {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@ protected Class<? extends DBWritable> getDBRecordType() {
return PostgresDBRecord.class;
}

@Override
protected String getExternalDocumentationLink() {
return DBUtils.CLOUDSQLPOSTGRES_SUPPORTED_DOC_URL;
}

@Override
protected String getErrorDetailsProviderClassName() {
return CloudSQLPostgreSQLErrorDetailsProvider.class.getName();
}

@Override
protected String createConnectionString() {
if (CloudSQLUtil.PRIVATE_INSTANCE.equalsIgnoreCase(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ public final class DBUtils {
public static final String CLOUDSQLMYSQL_SUPPORTED_DOC_URL = "https://cloud.google.com/sql/docs/mysql/error-messages";
public static final String POSTGRES_SUPPORTED_DOC_URL =
"https://www.postgresql.org/docs/current/errcodes-appendix.html";
public static final String CLOUDSQLPOSTGRES_SUPPORTED_DOC_URL =
"https://cloud.google.com/sql/docs/postgres/error-messages";

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

0 comments on commit 80e17e5

Please sign in to comment.