|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public static interface SqlValidatorTestCase.Tester
Encapsulates differences between test environments, for example, which SQL parser or validator to use.
It contains a mock schema with EMP
and DEPT
tables, which can run without having to start up Farrago.
Method Summary | |
---|---|
void |
assertExceptionIsThrown(String sql,
String expectedMsgPattern)
Checks that a query is valid, or, if invalid, throws the right message at the right location. |
void |
checkCharset(String sql,
Charset expectedCharset)
|
void |
checkCollation(String sql,
String expectedCollationName,
SqlCollation.Coercibility expectedCoercibility)
|
void |
checkColumnType(String sql,
String expected)
Checks that a query returns one column of an expected type. |
void |
checkIntervalConv(String sql,
String expected)
Checks if the interval value conversion to milliseconds is valid. |
void |
checkResultType(String sql,
String expected)
Checks that a query returns one column of an expected type. |
void |
checkRewrite(SqlValidator validator,
String query,
String expectedRewrite)
Checks that a query gets rewritten to an expected form. |
RelDataType |
getColumnType(String sql)
Returns the data type of the sole column of a SQL query. |
SqlConformance |
getConformance()
|
SqlMonotonicity |
getMonotonicity(String sql)
Given a SQL query, returns the monotonicity of the first item in the SELECT clause. |
RelDataType |
getResultType(String sql)
Returns the data type of the row returned by a SQL query. |
SqlValidator |
getValidator()
|
SqlNode |
parseAndValidate(SqlValidator validator,
String sql)
|
SqlNode |
parseQuery(String sql)
|
Method Detail |
---|
SqlNode parseQuery(String sql) throws SqlParseException
SqlParseException
SqlNode parseAndValidate(SqlValidator validator, String sql)
SqlValidator getValidator()
void assertExceptionIsThrown(String sql, String expectedMsgPattern)
If expectedMsgPattern
is null, the query must
succeed.
If expectedMsgPattern
is not null, the query must
fail, and give an error location of (expectedLine, expectedColumn)
through (expectedEndLine, expectedEndColumn).
sql
- SQL statementexpectedMsgPattern
- If this parameter is null the query must be
valid for the test to pass; If this parameter is not null the query
must be malformed and the message given must match the patternRelDataType getColumnType(String sql)
For example, getResultType("VALUES (1")
returns
INTEGER
.
Fails if query returns more than one column.
getResultType(String)
RelDataType getResultType(String sql)
For example, getResultType("VALUES (1, 'foo')")
returns RecordType(INTEGER EXPR$0, CHAR(3) EXPR#1)
.
void checkCollation(String sql, String expectedCollationName, SqlCollation.Coercibility expectedCoercibility)
void checkCharset(String sql, Charset expectedCharset)
void checkColumnType(String sql, String expected)
checkType("VALUES (1 + 2)", "INTEGER NOT
NULL")
.
void checkRewrite(SqlValidator validator, String query, String expectedRewrite)
validator
- validator to use; null for defaultquery
- query to testexpectedRewrite
- expected SQL text after rewrite and unparsevoid checkResultType(String sql, String expected)
checkType("select empno, name from emp""{EMPNO INTEGER
NOT NULL, NAME VARCHAR(10) NOT NULL}")
.
void checkIntervalConv(String sql, String expected)
checkIntervalConv(VALUES (INTERVAL '1' Minute),
"60000")
.
SqlMonotonicity getMonotonicity(String sql)
sql
- SQL query
SqlConformance getConformance()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |