org.eigenbase.test
Interface SqlValidatorTestCase.Tester

All Known Subinterfaces:
SqlAdvisorTest.Tester
All Known Implementing Classes:
SqlAdvisorTest.AdvisorTestImpl, SqlValidatorFeatureTest.FeatureTesterImpl, SqlValidatorTestCase.TesterImpl
Enclosing class:
SqlValidatorTestCase

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

parseQuery

SqlNode parseQuery(String sql)
                   throws SqlParseException
Throws:
SqlParseException

parseAndValidate

SqlNode parseAndValidate(SqlValidator validator,
                         String sql)

getValidator

SqlValidator getValidator()

assertExceptionIsThrown

void assertExceptionIsThrown(String sql,
                             String expectedMsgPattern)
Checks that a query is valid, or, if invalid, throws the right message at the right location.

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).

Parameters:
sql - SQL statement
expectedMsgPattern - 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 pattern

getColumnType

RelDataType getColumnType(String sql)
Returns the data type of the sole column of a SQL query.

For example, getResultType("VALUES (1") returns INTEGER.

Fails if query returns more than one column.

See Also:
getResultType(String)

getResultType

RelDataType getResultType(String sql)
Returns the data type of the row returned by a SQL query.

For example, getResultType("VALUES (1, 'foo')") returns RecordType(INTEGER EXPR$0, CHAR(3) EXPR#1).


checkCollation

void checkCollation(String sql,
                    String expectedCollationName,
                    SqlCollation.Coercibility expectedCoercibility)

checkCharset

void checkCharset(String sql,
                  Charset expectedCharset)

checkColumnType

void checkColumnType(String sql,
                     String expected)
Checks that a query returns one column of an expected type. For example, checkType("VALUES (1 + 2)", "INTEGER NOT NULL").


checkRewrite

void checkRewrite(SqlValidator validator,
                  String query,
                  String expectedRewrite)
Checks that a query gets rewritten to an expected form.

Parameters:
validator - validator to use; null for default
query - query to test
expectedRewrite - expected SQL text after rewrite and unparse

checkResultType

void checkResultType(String sql,
                     String expected)
Checks that a query returns one column of an expected type. For example, checkType("select empno, name from emp""{EMPNO INTEGER NOT NULL, NAME VARCHAR(10) NOT NULL}").


checkIntervalConv

void checkIntervalConv(String sql,
                       String expected)
Checks if the interval value conversion to milliseconds is valid. For example, checkIntervalConv(VALUES (INTERVAL '1' Minute), "60000").


getMonotonicity

SqlMonotonicity getMonotonicity(String sql)
Given a SQL query, returns the monotonicity of the first item in the SELECT clause.

Parameters:
sql - SQL query
Returns:
Monotonicity

getConformance

SqlConformance getConformance()