Search in sources :

Example 1 with UnsupportedSQLQueryException

use of org.apache.druid.sql.calcite.planner.UnsupportedSQLQueryException in project druid by druid-io.

the class SqlResourceTest method testCannotConvert_UnsupportedSQLQueryException.

/**
 * This test is for {@link UnsupportedSQLQueryException} exceptions that are thrown by druid rules during query
 * planning. e.g. doing max aggregation on string type. The test checks that the API returns correct error messages
 * for such planning errors.
 */
@Test
public void testCannotConvert_UnsupportedSQLQueryException() throws Exception {
    // max(string) unsupported
    final QueryException exception = doPost(createSimpleQueryWithId("id", "SELECT max(dim1) FROM druid.foo")).lhs;
    Assert.assertNotNull(exception);
    Assert.assertEquals(PlanningError.UNSUPPORTED_SQL_ERROR.getErrorCode(), exception.getErrorCode());
    Assert.assertEquals(PlanningError.UNSUPPORTED_SQL_ERROR.getErrorClass(), exception.getErrorClass());
    Assert.assertTrue(exception.getMessage().contains("Cannot build plan for query: SELECT max(dim1) FROM druid.foo. " + "Possible error: Max aggregation is not supported for 'STRING' type"));
    checkSqlRequestLog(false);
    Assert.assertTrue(lifecycleManager.getAll("id").isEmpty());
}
Also used : UnsupportedSQLQueryException(org.apache.druid.sql.calcite.planner.UnsupportedSQLQueryException) QueryException(org.apache.druid.query.QueryException) Test(org.junit.Test)

Aggregations

QueryException (org.apache.druid.query.QueryException)1 UnsupportedSQLQueryException (org.apache.druid.sql.calcite.planner.UnsupportedSQLQueryException)1 Test (org.junit.Test)1