Skip to content

Commit

Permalink
removed separate V8 tests I created cause, in hindsight, they serve l…
Browse files Browse the repository at this point in the history
…ittle to no purpose, the assumeV7 indicator is enough.
  • Loading branch information
pj-spoelders committed Mar 28, 2024
1 parent cd744f7 commit be2eae4
Showing 1 changed file with 3 additions and 313 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import java.util.Set;

import org.junit.jupiter.api.*;
import org.opentest4j.AssertionFailedError;
import org.opentest4j.MultipleFailuresError;
import org.testcontainers.containers.JdbcDatabaseContainer.NoDriverFoundException;

import com.exasol.adapter.properties.PropertyValidationException;
Expand Down Expand Up @@ -72,11 +70,11 @@ protected Map<String, String> getConnectionSpecificVirtualSchemaProperties() {
return Map.of("IMPORT_FROM_EXA", "true", EXASOL_CONNECTION_PROPERTY, this.exaConnection.getName());
}

// These tests were overridden and split up according to DB versions for the following reasons:
// Strict datatype checking that's enabled for Exasol V8 makes a number of these tests fail.
// These tests were overridden for the following reasons:
// Strict datatype checking which is by default enabled for Exasol V8 makes a number of these tests fail.
//
// The old tests that work for DB versions prior to strict datatype checking
// thus can only be run for earlier Exasol DB versions and have to be disabled for V8.
// thus can only be run for earlier Exasol DB versions and have to be skipped for V8.
//
// The tests using the newer GENERATE_JDBC_DATATYPE_MAPPING_FOR_EXA switch that fixes most of the issues with strict
// datatype checking on the pushed down queries
Expand Down Expand Up @@ -355,312 +353,4 @@ void testCaseGreaterThan() {
+ getVirtualTableName(this.virtualSchema, table), //
table().row("NO").row("YES").row("YES").matches());
}

// V8 tests start here
private void checkExceptionMessageForStrictDatatypeCheckFailures(final String message) {
assertThat(message, anyOf(//
containsString("Adapter generated invalid pushdown query for virtual table"), //
containsString("Data type mismatch in column"), //
containsString("Unable to run assertion query"), //
containsString("Unable to execute assertion query")));
}

private void assertThatStrictDatatypeCheckInCompilerFails(final Throwable exception) {
final String message = exception.getMessage();
checkExceptionMessageForStrictDatatypeCheckFailures(message);
}

@Test
void testNonDefaultGeometryV8() {
assumeExasol8OrHigher();
final MultipleFailuresError exception = assertThrows(MultipleFailuresError.class, () -> {
typeAssertionFor("GEOMETRY(4321)").withValue("POINT (2 5)") //
.expectTypeOf("GEOMETRY(4321)") //
.expectDescribeType("GEOMETRY(4321)") //
.expectResultSetType(expectDataType("GEOMETRY")) //
.runAssert();
});
assertThatStrictDatatypeCheckInCompilerFails(exception);
}

@Test
void testPasswordNotVisibleInImportFromExaV8() throws NoDriverFoundException, SQLException {
assumeExasol8OrHigher();
final SQLException exception = assertThrows(SQLException.class, () -> {
final Table table = this.sourceSchema.createTable("T1", "C1", "VARCHAR(20)").insert("Hello.");
this.virtualSchema = createVirtualSchema(this.sourceSchema);
final String sql = "SELECT * FROM " + this.virtualSchema.getFullyQualifiedName() + ".\"" + table.getName()
+ "\"";
assertThat(explainVirtual(sql), //
table().row( //
anything(), //
not(anyOf( //
containsString(this.user.getName()), //
containsString(this.user.getPassword()), //
containsString(EXASOL.getUsername()), //
containsString(EXASOL.getPassword()) //
)), //
anything(), //
anything() //
).matches());
});
assertThatStrictDatatypeCheckInCompilerFails(exception);
}

@Test
void testCharMappingAsciiV8() {
assumeExasol8OrHigher();
final AssertionFailedError exception = assertThrows(AssertionFailedError.class, () -> {
final Table table = createSingleColumnTable("CHAR(20) ASCII").insert("sun").insert("rain");
assertVirtualTableContents(table, table("VARCHAR").row(pad("sun", 20)).row(pad("rain", 20)).matches());
});
assertThatStrictDatatypeCheckInCompilerFails(exception);

}

@Test
void testCharMappingUtf8V8() {
assumeExasol8OrHigher();
final AssertionFailedError exception = assertThrows(AssertionFailedError.class, () -> {
verifyCharMappingUtf8("VARCHAR");
});
assertThatStrictDatatypeCheckInCompilerFails(exception);
}

@Test
void testCastVarcharToCharV8() {
assumeExasol8OrHigher();
final AssertionFailedError exception = assertThrows(AssertionFailedError.class, () -> {
castFrom("VARCHAR(20)").to("CHAR(40)").input("Hello.").accept("VARCHAR").verify(pad("Hello.", 40));
});
assertThatStrictDatatypeCheckInCompilerFails(exception);
}

@Test
void testHashTypeWithBitSizeV8() {
assumeExasol8OrHigher();
final MultipleFailuresError exception = assertThrows(MultipleFailuresError.class, () -> {
typeAssertionFor("HASHTYPE(16 BIT)").withValue("550e") //
.expectDescribeType("HASHTYPE(2 BYTE)") //
.expectTypeOf("HASHTYPE(2 BYTE)") //
.expectResultSetType(expectDataType("HASHTYPE")) //
.runAssert();
});
assertThatStrictDatatypeCheckInCompilerFails(exception);
}

@Test
void testDefaultIntervalYearToMonthV8() {
assumeExasol8OrHigher();
final MultipleFailuresError exception = assertThrows(MultipleFailuresError.class, () -> {
typeAssertionFor("INTERVAL YEAR TO MONTH").withValue("5-3") //
.expectTypeOf("INTERVAL YEAR(2) TO MONTH") //
.expectDescribeType("INTERVAL YEAR(2) TO MONTH") //
.expectResultSetType(expectDataType("INTERVAL YEAR TO MONTH")) //
.expectValue("+05-03") //
.runAssert();
});
assertThatStrictDatatypeCheckInCompilerFails(exception);
}

@Test
void testDefaultGeometryV8() {
assumeExasol8OrHigher();
final MultipleFailuresError exception = assertThrows(MultipleFailuresError.class, () -> {
typeAssertionFor("GEOMETRY").withValue("POINT (2 5)") //
.expectTypeOf("GEOMETRY") //
.expectDescribeType("GEOMETRY") //
.expectResultSetType(expectDataType("GEOMETRY")) //
.runAssert();
});
assertThatStrictDatatypeCheckInCompilerFails(exception);
}

@Test
void testDefaultIntervalDayToSecondV8() {
assumeExasol8OrHigher();
final MultipleFailuresError exception = assertThrows(MultipleFailuresError.class, () -> {
typeAssertionFor("INTERVAL DAY TO SECOND").withValue("2 12:50:10.123") //
// day: 2 digits, seconds: 3 digits after decimal point
.expectTypeOf("INTERVAL DAY(2) TO SECOND(3)") //
.expectDescribeType("INTERVAL DAY(2) TO SECOND(3)") //
.expectResultSetType(expectDataType("INTERVAL DAY TO SECOND")) //
.expectValue("+02 12:50:10.123") //
.runAssert();
});
assertThatStrictDatatypeCheckInCompilerFails(exception);
}

@Test
void testGeometryMappingV8() {
assumeExasol8OrHigher();
final AssertionFailedError exception = assertThrows(AssertionFailedError.class, () -> {
// Note that the JDBC driver reports the result as VARCHAR for Exasol database with major version < 8
final Table table = createSingleColumnTable("GEOMETRY").insert("POINT (2 3)");
assertVirtualTableContents(table, table(expectDataType("GEOMETRY")).row("POINT (2 3)").matches());
});
assertThatStrictDatatypeCheckInCompilerFails(exception);
}

@Test
void testNonDefaultIntervalYearToMonthV8() {
assumeExasol8OrHigher();
final MultipleFailuresError exception = assertThrows(MultipleFailuresError.class, () -> {
typeAssertionFor("INTERVAL YEAR(4) TO MONTH") // 4 digits for year
.withValue("5-3") // sample interval of 5 years and 3 months
.expectTypeOf("INTERVAL YEAR(4) TO MONTH") //
.expectDescribeType("INTERVAL YEAR(4) TO MONTH") //
.expectResultSetType(expectDataType("INTERVAL YEAR TO MONTH")) //
.expectValue("+0005-03") // 4 digits for year
.runAssert();
});
assertThatStrictDatatypeCheckInCompilerFails(exception);
}

@Test
void testNonDefaultIntervalDayToSecondV8() {
assumeExasol8OrHigher();
final MultipleFailuresError exception = assertThrows(MultipleFailuresError.class, () -> {
// day: 4 digits, seconds: 6 digits after decimal point
typeAssertionFor("INTERVAL DAY(4) TO SECOND(6)").withValue("2 12:50:10.123") //
.expectTypeOf("INTERVAL DAY(4) TO SECOND(6)") //
.expectDescribeType("INTERVAL DAY(4) TO SECOND(6)") //
.expectResultSetType(expectDataType("INTERVAL DAY TO SECOND")) //
.expectValue("+0002 12:50:10.123000") //
.runAssert();
});
assertThatStrictDatatypeCheckInCompilerFails(exception);
}

@Test
void testNonDefaultHashTypeV8() {
assumeExasol8OrHigher();
final MultipleFailuresError exception = assertThrows(MultipleFailuresError.class, () -> {
typeAssertionFor("HASHTYPE(4 BYTE)").withValue("550e8400") //
.expectDescribeType("HASHTYPE(4 BYTE)") //
.expectTypeOf("HASHTYPE(4 BYTE)") //
.expectResultSetType(expectDataType("HASHTYPE")) //
.runAssert();
});
assertThatStrictDatatypeCheckInCompilerFails(exception);
}

@Test
void testCastVarcharAsGeometryV8() {
assumeExasol8OrHigher();
final AssertionFailedError exception = assertThrows(AssertionFailedError.class, () -> {
castFrom("VARCHAR(20)").to("GEOMETRY(5)").input("POINT(2 5)").accept(expectDataType("GEOMETRY"))
.verify("POINT (2 5)");
});
assertThatStrictDatatypeCheckInCompilerFails(exception);
}

@Test
void testDefaultHashTypeV8() {
assumeExasol8OrHigher();
final MultipleFailuresError exception = assertThrows(MultipleFailuresError.class, () -> {
typeAssertionFor("HASHTYPE").withValue("550e8400-e29b-11d4-a716-446655440000")
.expectDescribeType("HASHTYPE(16 BYTE)") //
.expectTypeOf("HASHTYPE(16 BYTE)") //
.expectResultSetType(expectDataType("HASHTYPE")) //
.expectValue("550e8400e29b11d4a716446655440000") //
.runAssert();
});
assertThatStrictDatatypeCheckInCompilerFails(exception);
}

@Test
void testIntervalYearToMonthMappingV8() {
assumeExasol8OrHigher();
final AssertionFailedError exception = assertThrows(AssertionFailedError.class, () -> {
final Table table = createSingleColumnTable("INTERVAL YEAR (9) TO MONTH")//
.insert("-999999999-11") //
.insert("-1-1") //
.insert("0-0") //
.insert("1-1") //
.insert("999999999-11");
// why is precision 9 missing in expected data type?
assertVirtualTableContents(table, table(expectDataType("INTERVAL YEAR TO MONTH")) //
.row("-999999999-11") //
.row("-000000001-01") //
.row("+000000000-00") //
.row("+000000001-01") //
.row("+999999999-11") //
.matches());
});
assertThatStrictDatatypeCheckInCompilerFails(exception);
}

@Test
void testIntervalDayToSecondMappingV8() {
assumeExasol8OrHigher();
final AssertionFailedError exception = assertThrows(AssertionFailedError.class, () -> {
final Table table = createSingleColumnTable("INTERVAL DAY (9) TO SECOND") //
.insert("-999999999 23:59:59.999") //
.insert("-1 12:34:56.789") //
.insert("0 00:00:00.000") //
.insert("1 12:34:56.789") //
.insert("999999999 23:59:59.999");
// why is precision 9 missing in expected data type?
assertVirtualTableContents(table, table(expectDataType("INTERVAL DAY TO SECOND")) //
.row("-999999999 23:59:59.999") //
.row("-000000001 12:34:56.789") //
.row("+000000000 00:00:00.000") //
.row("+000000001 12:34:56.789") //
.row("+999999999 23:59:59.999") //
.matches());
});
assertThatStrictDatatypeCheckInCompilerFails(exception);
}

@Test
void testCastVarcharAsIntervalDayToSecondV8() {
assumeExasol8OrHigher();
final AssertionFailedError exception = assertThrows(AssertionFailedError.class, () -> {
// why is precision 5 and 2 missing in expected data type?
castFrom("VARCHAR(30)").to("INTERVAL DAY (5) TO SECOND (2)").input("+00003 12:50:10.12")
.accept(expectDataType("INTERVAL DAY TO SECOND")).verify("+00003 12:50:10.12");
});
assertThatStrictDatatypeCheckInCompilerFails(exception);
}

@Test
void testCastVarcharAsIntervalYearToMonthV8() {
assumeExasol8OrHigher();
final AssertionFailedError exception = assertThrows(AssertionFailedError.class, () -> {
// why is precision 5 missing in expectedDataType?
castFrom("VARCHAR(30)").to("INTERVAL YEAR (5) TO MONTH").input("+00004-06")
.accept(expectDataType("INTERVAL YEAR TO MONTH")).verify("+00004-06");
});
assertThatStrictDatatypeCheckInCompilerFails(exception);
}

@Test
void testCaseEqualV8() {
assumeExasol8OrHigher();
final AssertionFailedError exception = assertThrows(AssertionFailedError.class, () -> {
final Table table = createSingleColumnTable("INTEGER").insert(1).insert(2).insert(3);
this.virtualSchema = createVirtualSchema(this.sourceSchema);
assertVsQuery("SELECT CASE C1 WHEN 1 THEN 'YES' WHEN 2 THEN 'PERHAPS' ELSE 'NO' END FROM " //
+ getVirtualTableName(this.virtualSchema, table), //
table().row("YES").row("PERHAPS").row("NO").matches());
});
assertThatStrictDatatypeCheckInCompilerFails(exception);
}

@Test
void testCaseGreaterThanV8() {
assumeExasol8OrHigher();
final AssertionFailedError exception = assertThrows(AssertionFailedError.class, () -> {
final Table table = createSingleColumnTable("INTEGER").insert(1).insert(2).insert(3);
this.virtualSchema = createVirtualSchema(this.sourceSchema);
assertVsQuery("SELECT CASE WHEN C1 > 1 THEN 'YES' ELSE 'NO' END FROM " //
+ getVirtualTableName(this.virtualSchema, table), //
table().row("NO").row("YES").row("YES").matches());
});
assertThatStrictDatatypeCheckInCompilerFails(exception);
}

}

//

0 comments on commit be2eae4

Please sign in to comment.