Search in sources :

Example 1 with SqlAbstractConformance

use of org.apache.calcite.sql.validate.SqlAbstractConformance in project calcite by apache.

the class SqlValidatorTest method testAbstractConformance.

@Test
public void testAbstractConformance() throws InvocationTargetException, IllegalAccessException {
    final SqlAbstractConformance c0 = new SqlAbstractConformance() {
    };
    final SqlConformance c1 = SqlConformanceEnum.DEFAULT;
    for (Method method : SqlConformance.class.getMethods()) {
        final Object o0 = method.invoke(c0);
        final Object o1 = method.invoke(c1);
        assertThat(method.toString(), Objects.equals(o0, o1), is(true));
    }
}
Also used : SqlAbstractConformance(org.apache.calcite.sql.validate.SqlAbstractConformance) SqlConformance(org.apache.calcite.sql.validate.SqlConformance) Method(java.lang.reflect.Method) Test(org.junit.Test)

Example 2 with SqlAbstractConformance

use of org.apache.calcite.sql.validate.SqlAbstractConformance in project calcite by apache.

the class SqlValidatorTest method testUserDefinedConformance.

@Test
public void testUserDefinedConformance() {
    final SqlAbstractConformance c = new SqlDelegatingConformance(SqlConformanceEnum.DEFAULT) {

        public boolean isBangEqualAllowed() {
            return true;
        }
    };
    // Our conformance behaves differently from ORACLE_10 for FROM-less query.
    final SqlTester customTester = tester.withConformance(c);
    final SqlTester defaultTester = tester.withConformance(SqlConformanceEnum.DEFAULT);
    final SqlTester oracleTester = tester.withConformance(SqlConformanceEnum.ORACLE_10);
    sql("^select 2+2^").tester(customTester).ok().tester(defaultTester).ok().tester(oracleTester).fails("SELECT must have a FROM clause");
    // Our conformance behaves like ORACLE_10 for "!=" operator.
    sql("select * from (values 1) where 1 != 2").tester(customTester).ok().tester(defaultTester).fails("Bang equal '!=' is not allowed under the current SQL conformance level").tester(oracleTester).ok();
    sql("select * from (values 1) where 1 != any (2, 3)").tester(customTester).ok().tester(defaultTester).fails("Bang equal '!=' is not allowed under the current SQL conformance level").tester(oracleTester).ok();
}
Also used : SqlAbstractConformance(org.apache.calcite.sql.validate.SqlAbstractConformance) SqlDelegatingConformance(org.apache.calcite.sql.validate.SqlDelegatingConformance) SqlTester(org.apache.calcite.sql.test.SqlTester) Test(org.junit.Test)

Aggregations

SqlAbstractConformance (org.apache.calcite.sql.validate.SqlAbstractConformance)2 Test (org.junit.Test)2 Method (java.lang.reflect.Method)1 SqlTester (org.apache.calcite.sql.test.SqlTester)1 SqlConformance (org.apache.calcite.sql.validate.SqlConformance)1 SqlDelegatingConformance (org.apache.calcite.sql.validate.SqlDelegatingConformance)1