public class SqlValidatorFixture extends Object
It provides a fluent API so that you can write tests by chaining method calls.
It is immutable. If you have two test cases that require a similar set up (for example, the same SQL expression and parser configuration), it is safe to use the same fixture object as a starting point for both tests.
| 限定符和类型 | 字段和说明 |
|---|---|
boolean |
expression |
SqlTestFactory |
factory |
org.apache.calcite.sql.parser.StringAndPos |
sap |
SqlTester |
tester |
boolean |
whole |
| 限定符 | 构造器和说明 |
|---|---|
protected |
SqlValidatorFixture(SqlTester tester,
SqlTestFactory factory,
org.apache.calcite.sql.parser.StringAndPos sap,
boolean expression,
boolean whole)
Creates a SqlValidatorFixture.
|
| 限定符和类型 | 方法和说明 |
|---|---|
SqlValidatorFixture |
assertBindType(org.hamcrest.Matcher<String> matcher) |
void |
assertCharset(org.hamcrest.Matcher<Charset> charsetMatcher) |
void |
assertCollation(org.hamcrest.Matcher<String> collationMatcher,
org.hamcrest.Matcher<org.apache.calcite.sql.SqlCollation.Coercibility> coercibilityMatcher) |
SqlValidatorFixture |
assertFieldOrigin(org.hamcrest.Matcher<String> matcher)
Tests that the list of the origins of each result field of
the current query match expected.
|
void |
assertInterval(org.hamcrest.Matcher<Long> matcher)
Checks if the interval value conversion to milliseconds is valid.
|
SqlValidatorFixture |
assertMonotonicity(org.hamcrest.Matcher<org.apache.calcite.sql.validate.SqlMonotonicity> matcher)
Tests that the first column of the query has a given monotonicity.
|
SqlValidatorFixture |
columnType(String expectedType)
Checks that a query returns a single column, and that the column has the
expected type.
|
org.apache.calcite.sql.validate.SqlConformance |
conformance() |
SqlValidatorFixture |
fails(String expected)
Checks that a SQL expression gives a particular error.
|
SqlValidatorFixture |
failsIf(boolean b,
String expected)
Checks that a SQL expression fails, giving an
expected error,
if b is true, otherwise succeeds. |
SqlValidatorFixture |
isAggregate(org.hamcrest.Matcher<Boolean> matcher) |
SqlValidatorFixture |
ok() |
org.apache.calcite.sql.parser.SqlParser.Config |
parserConfig() |
SqlValidatorFixture |
rewritesTo(String expected) |
void |
setFor(org.apache.calcite.sql.SqlOperator operator) |
org.apache.calcite.sql.parser.StringAndPos |
toSql(boolean withCaret) |
SqlValidatorFixture |
type(String expectedType)
Checks that a query returns a row of the expected type.
|
SqlValidatorFixture |
withCaseSensitive(boolean caseSensitive) |
SqlValidatorFixture |
withCatalogReader(SqlTestFactory.CatalogReaderFactory catalogReaderFactory) |
SqlValidatorFixture |
withConformance(org.apache.calcite.sql.validate.SqlConformance conformance) |
SqlValidatorFixture |
withExpr(String sql) |
SqlValidatorFixture |
withExtendedCatalog() |
SqlValidatorFixture |
withFactory(UnaryOperator<SqlTestFactory> transform) |
SqlValidatorFixture |
withLenientOperatorLookup(boolean lenient)
Returns a tester that does not fail validation if it encounters an
unknown function.
|
SqlValidatorFixture |
withLex(org.apache.calcite.config.Lex lex) |
SqlValidatorFixture |
withOperatorTable(org.apache.calcite.sql.SqlOperatorTable operatorTable) |
SqlValidatorFixture |
withParserConfig(UnaryOperator<org.apache.calcite.sql.parser.SqlParser.Config> transform) |
SqlValidatorFixture |
withQuotedCasing(org.apache.calcite.avatica.util.Casing casing) |
SqlValidatorFixture |
withQuoting(org.apache.calcite.avatica.util.Quoting quoting) |
SqlValidatorFixture |
withSql(String sql) |
SqlValidatorFixture |
withTester(UnaryOperator<SqlTester> transform) |
SqlValidatorFixture |
withTypeCoercion(boolean typeCoercion) |
SqlValidatorFixture |
withUnquotedCasing(org.apache.calcite.avatica.util.Casing casing) |
SqlValidatorFixture |
withValidatorCallRewrite(boolean rewrite) |
SqlValidatorFixture |
withValidatorColumnReferenceExpansion(boolean expansion) |
SqlValidatorFixture |
withValidatorConfig(UnaryOperator<org.apache.calcite.sql.validate.SqlValidator.Config> transform) |
SqlValidatorFixture |
withValidatorIdentifierExpansion(boolean expansion) |
SqlValidatorFixture |
withWhole(boolean whole) |
public final SqlTester tester
public final SqlTestFactory factory
public final org.apache.calcite.sql.parser.StringAndPos sap
public final boolean expression
public final boolean whole
protected SqlValidatorFixture(SqlTester tester, SqlTestFactory factory, org.apache.calcite.sql.parser.StringAndPos sap, boolean expression, boolean whole)
tester - Testersap - SQL query or expressionexpression - True if sql is an expression,
false if it is a querywhole - Whether the failure location is the whole query or
expressionpublic SqlValidatorFixture withTester(UnaryOperator<SqlTester> transform)
public SqlValidatorFixture withFactory(UnaryOperator<SqlTestFactory> transform)
public SqlValidatorFixture withParserConfig(UnaryOperator<org.apache.calcite.sql.parser.SqlParser.Config> transform)
public org.apache.calcite.sql.parser.SqlParser.Config parserConfig()
public SqlValidatorFixture withSql(String sql)
public SqlValidatorFixture withExpr(String sql)
public org.apache.calcite.sql.parser.StringAndPos toSql(boolean withCaret)
public SqlValidatorFixture withExtendedCatalog()
public SqlValidatorFixture withCatalogReader(SqlTestFactory.CatalogReaderFactory catalogReaderFactory)
public SqlValidatorFixture withQuoting(org.apache.calcite.avatica.util.Quoting quoting)
public SqlValidatorFixture withLex(org.apache.calcite.config.Lex lex)
public SqlValidatorFixture withConformance(org.apache.calcite.sql.validate.SqlConformance conformance)
public org.apache.calcite.sql.validate.SqlConformance conformance()
public SqlValidatorFixture withTypeCoercion(boolean typeCoercion)
public SqlValidatorFixture withLenientOperatorLookup(boolean lenient)
public SqlValidatorFixture withWhole(boolean whole)
public SqlValidatorFixture ok()
public SqlValidatorFixture fails(String expected)
public SqlValidatorFixture failsIf(boolean b, String expected)
expected error,
if b is true, otherwise succeeds.public SqlValidatorFixture type(String expectedType)
sql("select empno, name from emp")
.type("{EMPNO INTEGER NOT NULL, NAME VARCHAR(10) NOT NULL}");
expectedType - Expected row typepublic SqlValidatorFixture columnType(String expectedType)
sql("SELECT empno FROM Emp").columnType("INTEGER NOT NULL");
expectedType - Expected type, including nullabilitypublic SqlValidatorFixture assertMonotonicity(org.hamcrest.Matcher<org.apache.calcite.sql.validate.SqlMonotonicity> matcher)
matcher - Expected monotonicitypublic SqlValidatorFixture assertBindType(org.hamcrest.Matcher<String> matcher)
public void assertCharset(org.hamcrest.Matcher<Charset> charsetMatcher)
public void assertCollation(org.hamcrest.Matcher<String> collationMatcher, org.hamcrest.Matcher<org.apache.calcite.sql.SqlCollation.Coercibility> coercibilityMatcher)
public void assertInterval(org.hamcrest.Matcher<Long> matcher)
sql("VALUES (INTERVAL '1' Minute)").intervalConv("60000");
public SqlValidatorFixture withCaseSensitive(boolean caseSensitive)
public SqlValidatorFixture withOperatorTable(org.apache.calcite.sql.SqlOperatorTable operatorTable)
public SqlValidatorFixture withQuotedCasing(org.apache.calcite.avatica.util.Casing casing)
public SqlValidatorFixture withUnquotedCasing(org.apache.calcite.avatica.util.Casing casing)
public SqlValidatorFixture withValidatorConfig(UnaryOperator<org.apache.calcite.sql.validate.SqlValidator.Config> transform)
public SqlValidatorFixture withValidatorIdentifierExpansion(boolean expansion)
public SqlValidatorFixture withValidatorCallRewrite(boolean rewrite)
public SqlValidatorFixture withValidatorColumnReferenceExpansion(boolean expansion)
public SqlValidatorFixture rewritesTo(String expected)
public SqlValidatorFixture isAggregate(org.hamcrest.Matcher<Boolean> matcher)
public SqlValidatorFixture assertFieldOrigin(org.hamcrest.Matcher<String> matcher)
The field origin list looks like this:
"{(CATALOG.SALES.EMP.EMPNO, null)}".
public void setFor(org.apache.calcite.sql.SqlOperator operator)
Copyright © 2012-2023 Apache Software Foundation. All Rights Reserved.