/** * Per {@link java.io.Serializable} API, provides a replacement object to be * written during serialization. * * <p>SqlParseException is serializable but is not available on the client. * This implementation converts this SqlParseException into a vanilla {@link * RuntimeException} with the same message. */ private Object writeReplace() { return new RuntimeException( getClass().getName() + ": " + getMessage()); } }
/** * Per {@link java.io.Serializable} API, provides a replacement object to be * written during serialization. * * <p>SqlParseException is serializable but is not available on the client. * This implementation converts this SqlParseException into a vanilla {@link * RuntimeException} with the same message. */ private Object writeReplace() { return new RuntimeException( getClass().getName() + ": " + getMessage()); } }
/** * Attempts to parse a SQL statement and adds to the errorList if any syntax * error is found. This implementation uses {@link SqlParser}. Subclass can * re-implement this with a different parser implementation * * @param sql A user-input sql statement to be parsed * @param errorList A {@link List} of error to be added to * * @return {@link SqlNode } that is root of the parse tree, null if the sql * is not valid */ protected SqlNode collectParserError( String sql, List<ValidateErrorInfo> errorList) { try { return parseQuery(sql); } catch (SqlParseException e) { ValidateErrorInfo errInfo = new ValidateErrorInfo( e.getPos(), e.getMessage()); // parser only returns 1 exception now errorList.add(errInfo); return null; } }
/** * Attempts to parse a SQL statement and adds to the errorList if any syntax * error is found. This implementation uses {@link SqlParser}. Subclass can * re-implement this with a different parser implementation * * @param sql A user-input sql statement to be parsed * @param errorList A {@link List} of error to be added to * @return {@link SqlNode } that is root of the parse tree, null if the sql * is not valid */ protected SqlNode collectParserError( String sql, List<ValidateErrorInfo> errorList) { try { return parseQuery(sql); } catch (SqlParseException e) { ValidateErrorInfo errInfo = new ValidateErrorInfo( e.getPos(), e.getMessage()); // parser only returns 1 exception now errorList.add(errInfo); return null; } }
@Test public void testParseFails() throws SqlParseException { Planner planner = getPlanner(null); try { SqlNode parse = planner.parse("select * * from \"emps\""); fail("expected error, got " + parse); } catch (SqlParseException e) { assertThat(e.getMessage(), containsString("Encountered \"*\" at line 1, column 10.")); } }
validator = getValidator(); } catch (SqlParseException e) { String errMessage = e.getMessage(); if (expectedMsgPattern == null) { e.printStackTrace();
validator = getValidator(); } catch (SqlParseException e) { String errMessage = e.getMessage(); if (expectedMsgPattern == null) { e.printStackTrace();
} catch (SqlParseException e) { throw new RuntimeException( "parse failed: " + e.getMessage(), e);