// TODO report source column name instead of ColumnHandle toString
@Test
    public void testPredicateTypeMismatch()
    {
        try (LocalQueryRunner queryRunner = createLocalQueryRunner(
                getMockApplyRedirectAfterPredicatePushdown(TYPE_MISMATCHED_REDIRECTION_MAPPING_BC, Optional.of(ImmutableSet.of(SOURCE_COLUMN_HANDLE_B))),
                Optional.of(this::mockApplyProjection),
                Optional.of(getMockApplyFilter(ImmutableSet.of(SOURCE_COLUMN_HANDLE_C))))) {
            // After 'source_col_c = 1' is pushed into source table scan, it's possible for 'source_col_c' table scan assignment to be pruned
            // Redirection results in Project('dest_col_b') -> Filter('dest_col_c = 1') -> TableScan for such case
            // but dest_col_a has mismatched type compared to source domain
            transaction(queryRunner.getTransactionManager(), queryRunner.getAccessControl())
                    .execute(MOCK_SESSION, session -> {
                        assertThatThrownBy(() -> queryRunner.createPlan(session, "SELECT source_col_b FROM test_table WHERE source_col_c = 'foo'", WarningCollector.NOOP))
                                .isInstanceOf(TrinoException.class)
                                // TODO report source column name instead of ColumnHandle toString
                                .hasMessageMatching("Redirected column mock_catalog.target_schema.target_table.destination_col_a has type integer, " +
                                        "different from source column mock_catalog.test_schema.test_table.MockConnectorColumnHandle.*source_col_c.* type: varchar");
                    });
        }
    }
assertThatThrownBy(() -> queryRunner.createPlan(session, "SELECT source_col_b FROM test_table WHERE source_col_c = 'foo'", WarningCollector.NOOP))
.isInstanceOf(TrinoException.class)
// TODO report source column name instead of ColumnHandle toString
.hasMessageMatching("Redirected column mock_catalog.target_schema.target_table.destination_col_a has type integer, " +
"different from source column mock_catalog.test_schema.test_table.MockConnectorColumnHandle.*source_col_c.* type: varchar");
getMockApplyRedirectAfterPredicatePushdown(TYPE_MISMATCHED_REDIRECTION_MAPPING_BC, Optional.of(ImmutableSet.of(SOURCE_COLUMN_HANDLE_B))),
Optional.of(this::mockApplyProjection),
Optional.of(getMockApplyFilter(ImmutableSet.of(SOURCE_COLUMN_HANDLE_C))))) {
// After 'source_col_c = 1' is pushed into source table scan, it's possible for 'source_col_c' table scan assignment to be pruned
// Redirection results in Project('dest_col_b') -> Filter('dest_col_c = 1') -> TableScan for such case
// but dest_col_a has mismatched type compared to source domain
transaction(queryRunner.getTransactionManager(), queryRunner.getAccessControl())
.execute(MOCK_SESSION, session -> {
assertThatThrownBy(() -> queryRunner.createPlan(session, "SELECT source_col_b FROM test_table WHERE source_col_c = 'foo'", WarningCollector.NOOP))
.isInstanceOf(TrinoException.class)
// TODO report source column name instead of ColumnHandle toString
.hasMessageMatching("Redirected column mock_catalog.target_schema.target_table.destination_col_a has type integer, " +
"different from source column mock_catalog.test_schema.test_table.MockConnectorColumnHandle.*source_col_c.* type: varchar");
});
}
}
@Test
public void testPredicateTypeMismatch()
{
try (LocalQueryRunner queryRunner = createLocalQueryRunner(
getMockApplyRedirectAfterPredicatePushdown(TYPE_MISMATCHED_REDIRECTION_MAPPING_BC, Optional.of(ImmutableSet.of(SOURCE_COLUMN_HANDLE_B))),
Optional.of(this::mockApplyProjection),
Optional.of(getMockApplyFilter(ImmutableSet.of(SOURCE_COLUMN_HANDLE_C))))) {
// After 'source_col_c = 1' is pushed into source table scan, it's possible for 'source_col_c' table scan assignment to be pruned
// Redirection results in Project('dest_col_b') -> Filter('dest_col_c = 1') -> TableScan for such case
// but dest_col_a has mismatched type compared to source domain
transaction(queryRunner.getTransactionManager(), queryRunner.getAccessControl())
.execute(MOCK_SESSION, session -> {
assertThatThrownBy(() -> queryRunner.createPlan(session, "SELECT source_col_b FROM test_table WHERE source_col_c = 'foo'", WarningCollector.NOOP))
.isInstanceOf(TrinoException.class)
// TODO report source column name instead of ColumnHandle toString
.hasMessageMatching("Redirected column mock_catalog.target_schema.target_table.destination_col_a has type integer, " +
"different from source column mock_catalog.test_schema.test_table.MockConnectorColumnHandle.*source_col_c.* type: varchar");
});
}
}