use of com.facebook.presto.verifier.checksum.ArrayColumnChecksum in project presto by prestodb.
the class TestStructuredColumnMismatchResolver method testMixed.
@Test
public void testMixed() {
ColumnMatchResult<?> resolvable1 = createMismatchedColumn(new ArrayType(new ArrayType(DOUBLE)), new ArrayColumnChecksum(binary(0xa), binary(0xc), 1), new ArrayColumnChecksum(binary(0xb), binary(0xc), 1));
ColumnMatchResult<?> resolvable2 = createMismatchedColumn(mapType(REAL, DOUBLE), new MapColumnChecksum(binary(0x1), binary(0xa), binary(0xa), binary(0xc), 1), new MapColumnChecksum(binary(0x4), binary(0xb), binary(0xb), binary(0xc), 1));
ColumnMatchResult<?> nonResolvable = createMismatchedColumn(VARCHAR, new SimpleColumnChecksum(binary(0xa)), new SimpleColumnChecksum(binary(0xb)));
assertResolved(resolvable1, resolvable2);
assertNotResolved(resolvable1, nonResolvable);
assertNotResolved(nonResolvable, resolvable2);
assertNotResolved(resolvable1, nonResolvable, resolvable2);
}
use of com.facebook.presto.verifier.checksum.ArrayColumnChecksum in project presto by prestodb.
the class TestStructuredColumnMismatchResolver method testResolveArray.
@Test
public void testResolveArray() {
ArrayColumnChecksum checksum1 = new ArrayColumnChecksum(binary(0xa), binary(0xb), 1);
ArrayColumnChecksum checksum2 = new ArrayColumnChecksum(binary(0x1a), binary(0xb), 1);
ArrayColumnChecksum checksum3 = new ArrayColumnChecksum(binary(0xa), binary(0x1b), 1);
ArrayColumnChecksum checksum4 = new ArrayColumnChecksum(binary(0xa), binary(0xb), 2);
// resolved
assertResolved(createMismatchedColumn(new ArrayType(DOUBLE), checksum1, checksum2));
assertResolved(createMismatchedColumn(new ArrayType(REAL), checksum1, checksum2));
assertResolved(createMismatchedColumn(new ArrayType(new ArrayType(DOUBLE)), checksum1, checksum2));
// not resolved, contains no floating point types
assertNotResolved(createMismatchedColumn(new ArrayType(INTEGER), checksum1, checksum2));
assertNotResolved(createMismatchedColumn(new ArrayType(new ArrayType(INTEGER)), checksum1, checksum2));
// not resolved, cardinality mismatches
assertNotResolved(createMismatchedColumn(new ArrayType(DOUBLE), checksum1, checksum3));
assertNotResolved(createMismatchedColumn(new ArrayType(DOUBLE), checksum1, checksum4));
}
use of com.facebook.presto.verifier.checksum.ArrayColumnChecksum in project presto by prestodb.
the class StructuredColumnMismatchResolver method resolveResultMismatch.
@Override
public Optional<String> resolveResultMismatch(DataMatchResult matchResult, QueryBundle control) {
checkArgument(!matchResult.isMatched(), "Expect not matched");
if (matchResult.getMatchType() != COLUMN_MISMATCH) {
return Optional.empty();
}
for (ColumnMatchResult<?> mismatchedColumn : matchResult.getMismatchedColumns()) {
Type columnType = mismatchedColumn.getColumn().getType();
if (columnType instanceof ArrayType) {
ArrayColumnChecksum controlChecksum = (ArrayColumnChecksum) mismatchedColumn.getControlChecksum();
ArrayColumnChecksum testChecksum = (ArrayColumnChecksum) mismatchedColumn.getTestChecksum();
if (!containsFloatingPointType(((ArrayType) columnType).getElementType()) || !isCardinalityMatched(controlChecksum, testChecksum)) {
return Optional.empty();
}
} else if (columnType instanceof MapType) {
MapColumnChecksum controlChecksum = (MapColumnChecksum) mismatchedColumn.getControlChecksum();
MapColumnChecksum testChecksum = (MapColumnChecksum) mismatchedColumn.getTestChecksum();
if (!isCardinalityMatched(controlChecksum, testChecksum)) {
return Optional.empty();
}
boolean keyContainsFloatingPoint = containsFloatingPointType(((MapType) columnType).getKeyType());
boolean valueContainsFloatingPoint = containsFloatingPointType(((MapType) columnType).getValueType());
if (!keyContainsFloatingPoint && !valueContainsFloatingPoint) {
return Optional.empty();
}
if (!keyContainsFloatingPoint && !Objects.equals(controlChecksum.getKeysChecksum(), testChecksum.getKeysChecksum())) {
return Optional.empty();
}
if (!valueContainsFloatingPoint && !Objects.equals(controlChecksum.getValuesChecksum(), testChecksum.getValuesChecksum())) {
return Optional.empty();
}
} else {
return Optional.empty();
}
}
return Optional.of("Structured columns auto-resolved");
}
Aggregations