protected void assertInvalidFunction(String projection, ErrorCodeSupplier expectedErrorCode) { try { evaluateInvalid(projection); fail(format("Expected to throw %s exception", expectedErrorCode.toErrorCode())); } catch (PrestoException e) { assertEquals(e.getErrorCode(), expectedErrorCode.toErrorCode()); } }
private void assertFails(@Language("SQL") String sql, ErrorCodeSupplier supplier) { try { runner.execute(sql); fail("expected exception"); } catch (PrestoException e) { assertEquals(e.getErrorCode(), supplier.toErrorCode()); } }
public static <A, B extends A> B checkType(A value, Class<B> target, ErrorCodeSupplier errorCode, String name) { if (value == null) { throw new NullPointerException(format("%s is null", name)); } if (!target.isInstance(value)) { throw new PrestoException(errorCode, format( "%s must be of type %s, not %s", name, target.getName(), value.getClass().getName())); } return target.cast(value); }
public static void checkCondition(boolean condition, ErrorCodeSupplier errorCode, String formatString, Object... args) { if (!condition) { throw new PrestoException(errorCode, format(formatString, args)); } }