Skip to content

Commit 5186dde

Browse files
committed
[FSTORE-1246] Fix ValidationReport upload throws error when result field contains partial_unexpected_list (#1716)
1 parent 57b04ff commit 5186dde

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

hopsworks-common/src/main/java/io/hops/hopsworks/common/featurestore/datavalidationv2/results/ValidationResultController.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -198,15 +198,13 @@ public String validationResultShortenResultField(String result) {
198198
}
199199
}
200200

201-
202-
203201
if (resultJson.has(UNEXPECTED_COUNT_KEY) && resultJson.has(PARTIAL_UNEXPECTED_LIST_KEY)
204202
&& resultJson.has(UNEXPECTED_PERCENT_KEY) && resultJson.has(UNEXPECTED_PERCENT_NONMISSING_KEY)) {
205203

206204
shortResultJson.put(UNEXPECTED_COUNT_KEY, resultJson.getInt(UNEXPECTED_COUNT_KEY));
207205
shortResultJson.put(UNEXPECTED_PERCENT_KEY, resultJson.getFloat(UNEXPECTED_PERCENT_KEY));
208206
shortResultJson.put(UNEXPECTED_PERCENT_NONMISSING_KEY, resultJson.getFloat(UNEXPECTED_PERCENT_NONMISSING_KEY));
209-
shortResultJson.put(PARTIAL_UNEXPECTED_LIST_KEY, resultJson.getString(PARTIAL_UNEXPECTED_LIST_KEY));
207+
shortResultJson.put(PARTIAL_UNEXPECTED_LIST_KEY, resultJson.getJSONArray(PARTIAL_UNEXPECTED_LIST_KEY));
210208

211209
if (shortResultJson.toString().length() > MAX_CHARACTERS_IN_VALIDATION_RESULT_RESULT_FIELD) {
212210
shortResultJson.remove(PARTIAL_UNEXPECTED_LIST_KEY);

hopsworks-common/src/test/io/hops/hopsworks/common/featurestore/datavalidationv2/TestValidationResultController.java

+24
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,13 @@
2424
import io.hops.hopsworks.persistence.entity.featurestore.featuregroup.datavalidationv2.IngestionResult;
2525
import io.hops.hopsworks.persistence.entity.featurestore.featuregroup.datavalidationv2.ValidationReport;
2626

27+
import org.json.JSONArray;
28+
import org.json.JSONObject;
2729
import org.junit.Before;
2830
import org.junit.Test;
2931
import java.util.Date;
3032

33+
import static io.hops.hopsworks.common.featurestore.FeaturestoreConstants.PARTIAL_UNEXPECTED_LIST_KEY;
3134
import static org.junit.Assert.assertEquals;
3235
import static org.junit.Assert.assertThrows;
3336

@@ -161,4 +164,25 @@ public void testVerifyValidationResultResult() {
161164

162165
// Long input is silently caught and result is truncated for result field.
163166
}
167+
168+
@Test
169+
public void testValidationResultShortenResultField_HandlePartialUnexpectedList(){
170+
String result = "{" +
171+
" \"element_count\": 1,\n" +
172+
" \"missing_count\": 0,\n" +
173+
" \"missing_percent\": 0.0,\n" +
174+
" \"unexpected_count\": 1,\n" +
175+
" \"unexpected_percent\": 100.0,\n" +
176+
" \"unexpected_percent_total\": 100.0,\n" +
177+
" \"unexpected_percent_nonmissing\": 100.0,\n" +
178+
" \"partial_unexpected_list\": [\n" +
179+
" \"wrong string\"\n" +
180+
" ]}";
181+
String shortenResultField = validationResultController.validationResultShortenResultField(result);
182+
JSONObject resultFieldJSON = new JSONObject(shortenResultField);
183+
184+
JSONArray partialUnexpectedList = resultFieldJSON.getJSONArray(PARTIAL_UNEXPECTED_LIST_KEY);
185+
assertEquals("wrong string", partialUnexpectedList.get(0));
186+
}
187+
164188
}

0 commit comments

Comments
 (0)