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:
-
SqlParserFixtureSqlParserListFixture
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static interfaceCallback to control how test actions are performed.protected static classDefault implementation ofSqlParserTest.Tester.static classImplementation ofSqlParserTest.Testerwhich makes sure that the results of unparsing a query are consistent with the original query. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.hamcrest.Matcher<SqlNode>customMatches(String description, Consumer<SqlNode> consumer) Returns aMatcherthat calls a consumer and then succeeds.protected SqlParserFixturefixture()Creates the test fixture that determines the behavior of tests.static org.hamcrest.Matcher<SqlNode>isDdl()Returns aMatcherthat succeeds if the givenSqlNodeis a DDL statement.protected booleanisReserved(String word) Returns whether a word is reserved in this parser.protected SqlParserFixtureprotected static SqlParsersqlParser(Reader source, UnaryOperator<SqlParser.Config> transform) voidvoidtestCast()voidprotected voidTestsHoist.voidTestsSqlLambda.protected voidprotected voidTests 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 aMatcherthat succeeds if the givenSqlNodeis a DDL statement. -
customMatches
public static org.hamcrest.Matcher<SqlNode> customMatches(String description, Consumer<SqlNode> consumer) Returns aMatcherthat 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() -
testEmpty
@Test public void testEmpty() -
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
-