Search in sources :

Example 1 with SqlDelegatingConformance

use of org.apache.calcite.sql.validate.SqlDelegatingConformance 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

SqlTester (org.apache.calcite.sql.test.SqlTester)1 SqlAbstractConformance (org.apache.calcite.sql.validate.SqlAbstractConformance)1 SqlDelegatingConformance (org.apache.calcite.sql.validate.SqlDelegatingConformance)1 Test (org.junit.Test)1