Search in sources :

Example 1 with SqlTesterImpl

use of org.apache.calcite.sql.test.SqlTesterImpl in project calcite by apache.

the class SqlValidatorUtilTest method testCheckingDuplicatesWithCompoundIdentifiers.

@SuppressWarnings("resource")
@Test
public void testCheckingDuplicatesWithCompoundIdentifiers() {
    final List<SqlNode> newList = new ArrayList<>(2);
    newList.add(new SqlIdentifier(Arrays.asList("f0", "c0"), SqlParserPos.ZERO));
    newList.add(new SqlIdentifier(Arrays.asList("f0", "c0"), SqlParserPos.ZERO));
    final SqlTesterImpl tester = new SqlTesterImpl(DefaultSqlTestFactory.INSTANCE);
    final SqlValidatorImpl validator = (SqlValidatorImpl) tester.getValidator();
    try {
        SqlValidatorUtil.checkIdentifierListForDuplicates(newList, validator.getValidationErrorFunction());
        fail("expected exception");
    } catch (CalciteContextException e) {
    // ok
    }
    // should not throw
    newList.set(1, new SqlIdentifier(Arrays.asList("f0", "c1"), SqlParserPos.ZERO));
    SqlValidatorUtil.checkIdentifierListForDuplicates(newList, null);
}
Also used : CalciteContextException(org.apache.calcite.runtime.CalciteContextException) ArrayList(java.util.ArrayList) SqlTesterImpl(org.apache.calcite.sql.test.SqlTesterImpl) SqlIdentifier(org.apache.calcite.sql.SqlIdentifier) SqlNode(org.apache.calcite.sql.SqlNode) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 CalciteContextException (org.apache.calcite.runtime.CalciteContextException)1 SqlIdentifier (org.apache.calcite.sql.SqlIdentifier)1 SqlNode (org.apache.calcite.sql.SqlNode)1 SqlTesterImpl (org.apache.calcite.sql.test.SqlTesterImpl)1 Test (org.junit.Test)1