Skip to content

Commit

Permalink
Merge branch 'develop' into fem/postgresql
Browse files Browse the repository at this point in the history
  • Loading branch information
psainics committed Dec 18, 2024
2 parents 6373949 + 0ef198a commit 0249aec
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ protected Class<? extends DBWritable> getDBRecordType() {
return MysqlDBRecord.class;
}

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

@Override
protected String createConnectionString() {
if (CloudSQLUtil.PRIVATE_INSTANCE.equalsIgnoreCase(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import io.cdap.cdap.api.data.schema.Schema;
import io.cdap.cdap.api.dataset.lib.KeyValue;
import io.cdap.cdap.api.exception.ErrorCategory;
import io.cdap.cdap.api.exception.ErrorCodeType;
import io.cdap.cdap.api.exception.ErrorType;
import io.cdap.cdap.api.exception.ErrorUtils;
import io.cdap.cdap.api.plugin.PluginConfig;
Expand Down Expand Up @@ -202,8 +203,17 @@ private Schema loadSchemaFromDB(Class<? extends Driver> driverClass)
// wrap exception to ensure SQLException-child instances not exposed to contexts without jdbc driver in classpath
String errorMessageWithDetails = String.format("Error occurred while trying to get schema from database." +
"Error message: '%s'. Error code: '%s'. SQLState: '%s'", e.getMessage(), e.getErrorCode(), e.getSQLState());
String externalDocumentationLink = getExternalDocumentationLink();
if (!Strings.isNullOrEmpty(externalDocumentationLink)) {
if (!errorMessageWithDetails.endsWith(".")) {
errorMessageWithDetails = errorMessageWithDetails + ".";
}
errorMessageWithDetails = String.format("%s For more details, see %s", errorMessageWithDetails,
externalDocumentationLink);
}
throw ErrorUtils.getProgramFailureException(new ErrorCategory(ErrorCategory.ErrorCategoryEnum.PLUGIN),
e.getMessage(), errorMessageWithDetails, ErrorType.USER, false, new SQLException(e.getMessage(),
e.getMessage(), errorMessageWithDetails, ErrorType.USER, false, ErrorCodeType.SQLSTATE,
e.getSQLState(), externalDocumentationLink, new SQLException(e.getMessage(),
e.getSQLState(), e.getErrorCode()));
} finally {
driverCleanup.destroy();
Expand Down Expand Up @@ -363,6 +373,10 @@ protected Class<? extends DBWritable> getDBRecordType() {
return DBRecord.class;
}

protected String getExternalDocumentationLink() {
return null;
}

@Override
public void initialize(BatchRuntimeContext context) throws Exception {
super.initialize(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ protected Class<? extends DBWritable> getDBRecordType() {
return MysqlDBRecord.class;
}

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

@Override
protected LineageRecorder getLineageRecorder(BatchSourceContext context) {
String fqn = DBUtils.constructFQN("mysql",
Expand Down

0 comments on commit 0249aec

Please sign in to comment.