Skip to content
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

[PLUGIN-1837] Error management for Analytics plugin i.e. GroupByAggregate, Deduplicate, Distinct and Joiner #1903

Merged
merged 1 commit into from
Jan 15, 2025

Conversation

Amit-CloudSufi
Copy link
Contributor

@Amit-CloudSufi Amit-CloudSufi commented Jan 8, 2025

Jira : PLUGIN-1837

Test [ Distinct Aggregator ]

  • Test Case (Enter a field that does not exist in input schema)
Raw Logs
Caused by: io.cdap.cdap.api.exception.WrappedStageException: Stage 'Distinct' encountered : io.cdap.cdap.etl.api.validation.ValidationException: Errors were encountered during validation. Field age_fake does not exist in input schema.
  at io.cdap.cdap.etl.common.plugin.ExceptionWrappingCaller.call(ExceptionWrappingCaller.java:64)
  at io.cdap.cdap.etl.common.plugin.WrappedReduceAggregator.prepareRun(WrappedReduceAggregator.java:80)
  at io.cdap.cdap.etl.common.plugin.WrappedReduceAggregator.prepareRun(WrappedReduceAggregator.java:36)
  at io.cdap.cdap.etl.common.submit.SubmitterPlugin.lambda$prepareRun$2(SubmitterPlugin.java:74)
  at io.cdap.cdap.internal.app.runtime.AbstractContext.lambda$execute$5(AbstractContext.java:558)
  at io.cdap.cdap.data2.transaction.Transactions$CacheBasedTransactional.finishExecute(Transactions.java:234)
  ... 21 common frames omitted
Caused by: io.cdap.cdap.etl.api.validation.ValidationException: Errors were encountered during validation. Field age_fake does not exist in input schema.
  at io.cdap.cdap.etl.validation.DefaultFailureCollector.getOrThrowException(DefaultFailureCollector.java:78)
  at io.cdap.cdap.etl.validation.LoggingFailureCollector.getOrThrowException(LoggingFailureCollector.java:50)
  at io.cdap.plugin.batch.aggregator.DistinctAggregator.prepareRun(DistinctAggregator.java:114)
  at io.cdap.cdap.etl.common.plugin.WrappedReduceAggregator.lambda$prepareRun$3(WrappedReduceAggregator.java:81)
  at io.cdap.cdap.etl.common.plugin.Caller$1.call(Caller.java:30)
  at io.cdap.cdap.etl.common.plugin.ExceptionWrappingCaller.call(ExceptionWrappingCaller.java:62)
  ... 26 common frames omitted

POST v3/namespaces/{namespace-id}/apps/{app-id}/workflows/DataPipelineWorkflow/runs/{run-id}/classify
[
{
  "stageName": "Distinct",
  "errorCategory": "Plugin-'Validation'-'Distinct'",
  "errorReason": "Stage 'Distinct' encountered 1 validation failures.",
  "errorMessage": "Stage 'Distinct' encountered : io.cdap.cdap.etl.api.validation.ValidationException: Errors were encountered during validation. Field age_fake does not exist in input schema.",
  "errorType": "USER",
  "dependency": "false"
}
]

image
image

@psainics psainics added the build Trigger unit test build label Jan 8, 2025
@Amit-CloudSufi Amit-CloudSufi force-pushed the hydratorPluginErrorMang branch from c0f275e to 3b3b46f Compare January 8, 2025 12:28
@psainics psainics changed the title Error management for Analytics plugin i.e. GroupByAggregate, Deduplicate, Distinct and Joiner [PLUGIN-1837] Error management for Analytics plugin i.e. GroupByAggregate, Deduplicate, Distinct and Joiner Jan 8, 2025
@Amit-CloudSufi Amit-CloudSufi force-pushed the hydratorPluginErrorMang branch 2 times, most recently from 2cb74cb to 60c6dee Compare January 9, 2025 09:53
@psainics psainics marked this pull request as ready for review January 9, 2025 10:56
String error = String.format("Invalid filter operation. It should be of format " +
"'fieldName:functionName'. But got : %s", filterOperation);
throw ErrorUtils.getProgramFailureException(new ErrorCategory(ErrorCategory.ErrorCategoryEnum.PLUGIN),
error, error, ErrorType.USER, false, new IllegalArgumentException(error));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need of wrapping it in IllegalArgumentException, cause can just be null.

This comment applies to whole PR.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you decide when to wrap vs keeping cause null

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is no exception being propagated, we don't need to introduce a separation exception here, cause can just be null. In other cases, we are catching the exception and then wrapping it in ProgramFailureException, hence it should be added as a cause.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated !

@psainics psainics force-pushed the hydratorPluginErrorMang branch from ffefd24 to 8c11489 Compare January 13, 2025 10:24
throw new IllegalStateException("Unsupported condition type " + conditionType);
String error = String.format("Unsupported condition type %s.", conditionType);
throw ErrorUtils.getProgramFailureException(new ErrorCategory(ErrorCategory.ErrorCategoryEnum.PLUGIN),
error, error, ErrorType.SYSTEM, false, null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsupported condition can be USER error.

Comment on lines 415 to 421
String errorMessage = String.format(
"Invalid aggregate %s(%s): Field '%s' does not exist in input schema %s.",
functionInfo.getFunction(), functionInfo.getField(), functionInfo.getField(), inputSchema));
functionInfo.getFunction(), functionInfo.getField(), functionInfo.getField(), inputSchema);
String errorReason = String.format("Field '%s' does not exist in input schema %s.",
functionInfo.getField(), inputSchema);
throw ErrorUtils.getProgramFailureException(new ErrorCategory(ErrorCategory.ErrorCategoryEnum.PLUGIN),
errorReason, errorMessage, ErrorType.USER, false, null);
Copy link
Member

@itsankit-google itsankit-google Jan 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both errorMessage & errorReason are same:

String errorMessage = String.format("Field '%s' does not exist in input schema %s.", functionInfo.getField(), inputSchema);
throw ErrorUtils.getProgramFailureException(new ErrorCategory(ErrorCategory.ErrorCategoryEnum.PLUGIN), errorMessage, errorMessage, ErrorType.USER, false, null);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated for whole PR

Comment on lines 175 to 180
String errorReason = String.format("Field %s does not exist in input schema %s.",
fieldName, inputSchema);
String errorMessage = String.format("Failed to fetch record schema due to field %s does not exist in" +
" input schema %s.", fieldName, inputSchema);
throw ErrorUtils.getProgramFailureException(new ErrorCategory(ErrorCategory.ErrorCategoryEnum.PLUGIN),
errorReason, errorMessage, ErrorType.USER, false, null);
Copy link
Member

@itsankit-google itsankit-google Jan 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar comment here.

String errorMessage = String.format("Failed to fetch record schema due to field %s does not exist in" +
 " input schema %s.", fieldName, inputSchema);
throw ErrorUtils.getProgramFailureException(new ErrorCategory(ErrorCategory.ErrorCategoryEnum.PLUGIN),
errorMessage, errorMessage, ErrorType.USER, false, null);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Copy link
Member

@itsankit-google itsankit-google left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If errorReason & errorMessage both are small, we can keep both same.

This comment applies to whole PR.

Comment on lines 175 to 176
String errorMessage = String.format(
"Failed to fetch function due to invalid function '%s', must be one of %s with message: %s.",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

String errorMessage = String.format("Failed to fetch function due to invalid function '%s' with message: %s, must be one of %s.",

This comment applies to whole PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated at both places

@itsankit-google
Copy link
Member

Please squash commits before merge

@Amit-CloudSufi Amit-CloudSufi force-pushed the hydratorPluginErrorMang branch from 01473f2 to 11f1ecf Compare January 14, 2025 18:26
@psainics psainics merged commit 9eb3915 into cdapio:develop Jan 15, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Trigger unit test build
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants