-
Notifications
You must be signed in to change notification settings - Fork 34
[CDAP-21093] Add ExternalDocumentationLink in abstract sink #533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -25,6 +25,10 @@ | |||||||||||||||
| import io.cdap.cdap.api.data.format.StructuredRecord; | ||||||||||||||||
| 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; | ||||||||||||||||
| import io.cdap.cdap.etl.api.Emitter; | ||||||||||||||||
| import io.cdap.cdap.etl.api.FailureCollector; | ||||||||||||||||
|
|
@@ -175,6 +179,16 @@ protected String getErrorDetailsProviderClassName() { | |||||||||||||||
| return DBErrorDetailsProvider.class.getName(); | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| /** | ||||||||||||||||
| * Returns the external documentation link. | ||||||||||||||||
| * Override this method to provide a custom external documentation link. | ||||||||||||||||
| * | ||||||||||||||||
| * @return external documentation link | ||||||||||||||||
| */ | ||||||||||||||||
| protected String getExternalDocumentationLink() { | ||||||||||||||||
| return null; | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| @Override | ||||||||||||||||
| public void prepareRun(BatchSinkContext context) { | ||||||||||||||||
| String connectionString = dbSinkConfig.getConnectionString(); | ||||||||||||||||
|
|
@@ -296,8 +310,21 @@ private Schema inferSchema(Class<? extends Driver> driverClass) { | |||||||||||||||
| inferredFields.addAll(getSchemaReader().getSchemaFields(rs)); | ||||||||||||||||
| } | ||||||||||||||||
| } catch (SQLException e) { | ||||||||||||||||
| throw new InvalidStageException("Error while reading table metadata", e); | ||||||||||||||||
|
|
||||||||||||||||
| // wrap exception to ensure SQLException-child instances not exposed to contexts w/o jdbc driver in classpath | ||||||||||||||||
| String errorMessageWithDetails = String.format("Error while reading table metadata." + | ||||||||||||||||
| "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, ErrorCodeType.SQLSTATE, | ||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why errorType
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is in abstract sink,
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. database-plugins/database-commons/src/main/java/io/cdap/plugin/db/source/AbstractDBSource.java Lines 214 to 220 in 0228f18
|
||||||||||||||||
| e.getSQLState(), externalDocumentationLink, new SQLException(e.getMessage(), | ||||||||||||||||
| e.getSQLState(), e.getErrorCode())); | ||||||||||||||||
itsankit-google marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||
| } | ||||||||||||||||
| } catch (IllegalAccessException | InstantiationException | SQLException e) { | ||||||||||||||||
| throw new InvalidStageException("JDBC Driver unavailable: " + dbSinkConfig.getJdbcPluginName(), e); | ||||||||||||||||
|
|
||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we also change this to
nullin both source & sink?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WIP Ref: #540
Looking into the E2E failures.