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

fix #2883 #2897

Merged
merged 1 commit into from
May 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -283,52 +283,54 @@ private void executeWorkflow() throws HopException {
// Optionally also send the result rows to a specified target transform...
//
boolean rowConsistencyChecked = false;
boolean consistencyPassed = true;

String missingFields = "";
String expectedTypes = "";
String currentTypes = "";

if (meta.getResultRowsTargetTransformMeta() != null && result.getRows() != null) {

for (RowMetaAndData row : result.getRows()) {

// .. but before, perform all the consistency checks just one time just in the first result
// row
if (!rowConsistencyChecked) {
for (int i = 0; i < meta.getResultRowsField().length; i++) {
IValueMeta valueMeta = row.getRowMeta().getValueMeta(i);
if (valueMeta == null) {
missingFields +=
(missingFields.length() > 0 ? missingFields = "," : "")
+ meta.getResultRowsField()[i];
consistencyPassed = false;
for (int i = 0; i < meta.getResultRowsField().length; i++) {
int idx = row.getRowMeta().indexOfValue(meta.getResultRowsField()[i]);

if (idx == -1) {
missingFields +=
(missingFields.length() > 0 ? "," : "")
+ meta.getResultRowsField()[i];
}

IValueMeta valueMeta = row.getRowMeta().getValueMeta(i);

if (valueMeta != null && valueMeta.getType() != meta.getResultRowsType()[i]) {
expectedTypes +=
(expectedTypes.length() > 0 ? "," : "")
+ ValueMetaFactory.getValueMetaName(meta.getResultRowsType()[i]);
currentTypes +=
(currentTypes.length() > 0 ? "," : "") + valueMeta.getTypeDesc();
}
}
rowConsistencyChecked = true;

if (valueMeta != null && valueMeta.getType() != meta.getResultRowsType()[i]) {
expectedTypes +=
(expectedTypes.length() > 0 ? expectedTypes = "," : "")
+ ValueMetaFactory.getValueMetaName(meta.getResultRowsType()[i]);
currentTypes +=
(currentTypes.length() > 0 ? currentTypes = "," : "") + valueMeta.getTypeDesc();
consistencyPassed = false;
}
}
rowConsistencyChecked = true;
}

if (!consistencyPassed) {
if (missingFields.length() > 0) {
logError("Unable to find required fields [" + missingFields + "] in result row!");
}

if (currentTypes.length() > 0) {
logError(
BaseMessages.getString(
PKG, "WorkflowExecutor.IncorrectDataTypePassed", currentTypes, expectedTypes));
BaseMessages.getString(
PKG,
"WorkflowExecutor.IncorrectDataTypePassed",
currentTypes,
expectedTypes));
throw new HopException(
"We got into troubles while performing a consistency check on incoming result rows!");
}

throw new HopException("We got into troubles while performing a consistency check on incoming result rows!");
}

Object[] targetRow = RowDataUtil.allocateRowData(data.resultRowsOutputRowMeta.size());

for (int i = 0; i < meta.getResultRowsField().length; i++) {
Expand Down