Package org.apache.calcite.sql.parser
Class SqlParserTest
java.lang.Object
org.apache.calcite.sql.parser.SqlParserTest
A
SqlParserTest
is a unit-test for
the SQL parser
.
To reuse this test for an extension parser, override the
fixture()
method,
calling SqlParserFixture.withConfig(UnaryOperator)
and then SqlParser.Config.withParserFactory(SqlParserImplFactory)
.
- See Also:
-
SqlParserFixture
SqlParserListFixture
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static interface
Callback to control how test actions are performed.protected static class
Default implementation ofSqlParserTest.Tester
.static class
Implementation ofSqlParserTest.Tester
which makes sure that the results of unparsing a query are consistent with the original query. -
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic org.hamcrest.Matcher<SqlNode>
customMatches
(String description, Consumer<SqlNode> consumer) Returns aMatcher
that calls a consumer and then succeeds.protected SqlParserFixture
fixture()
Creates the test fixture that determines the behavior of tests.static org.hamcrest.Matcher<SqlNode>
isDdl()
Returns aMatcher
that succeeds if the givenSqlNode
is a DDL statement.protected boolean
isReserved
(String word) Returns whether a word is reserved in this parser.protected SqlParserFixture
protected static SqlParser
sqlParser
(Reader source, UnaryOperator<SqlParser.Config> transform) void
void
testCast()
protected void
TestsHoist
.void
TestsSqlLambda
.protected void
protected void
Tests that EXTRACT, FLOOR, CEIL, DATE_TRUNC functions accept abbreviations for time units (such as "Y" for "YEAR") when configured viaSqlParser.Config.timeUnitCodes()
.protected static String
-
Field Details
-
BIG_QUERY
-
-
Constructor Details
-
SqlParserTest
public SqlParserTest()
-
-
Method Details
-
fixture
Creates the test fixture that determines the behavior of tests. Sub-classes that, say, test different parser implementations should override. -
sql
-
expr
-
sqlParser
-
isDdl
Returns aMatcher
that succeeds if the givenSqlNode
is a DDL statement. -
customMatches
public static org.hamcrest.Matcher<SqlNode> customMatches(String description, Consumer<SqlNode> consumer) Returns aMatcher
that calls a consumer and then succeeds. The consumer should contain custom code, and should fail if it doesn't like what it sees. -
getReservedKeywords
-
isReserved
Returns whether a word is reserved in this parser. This method can be used to disable tests that behave differently with different collections of reserved words. -
keywords
-
testCast
@Test public void testCast() -
testCaseExpression
@Test public void testCaseExpression() -
testTimeUnitCodes
@Test protected void testTimeUnitCodes()Tests that EXTRACT, FLOOR, CEIL, DATE_TRUNC functions accept abbreviations for time units (such as "Y" for "YEAR") when configured viaSqlParser.Config.timeUnitCodes()
. -
testMetadata
@Test protected void testMetadata() -
testHoist
@Test protected void testHoist()TestsHoist
. -
testLambdaExpression
@Test public void testLambdaExpression()TestsSqlLambda
. -
varToStr
-