Class SqlParserTest


public class SqlParserTest extends Object
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:
  • Field Details


      protected static final SqlDialect BIG_QUERY
  • Constructor Details

    • SqlParserTest

      public SqlParserTest()
  • Method Details

    • fixture

      public SqlParserFixture fixture()
      Creates the test fixture that determines the behavior of tests. Sub-classes that, say, test different parser implementations should override.
    • sql

      protected SqlParserFixture sql(String sql)
    • expr

      protected SqlParserFixture expr(String sql)
    • sqlParser

      protected static SqlParser sqlParser(Reader source, UnaryOperator<SqlParser.Config> transform)
    • isDdl

      public static org.hamcrest.Matcher<SqlNode> isDdl()
      Returns a Matcher that succeeds if the given SqlNode is a DDL statement.
    • getReservedKeywords

      protected SortedSet<String> getReservedKeywords()
    • isReserved

      protected boolean isReserved(String word)
      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

      protected static SortedSet<String> keywords(@Nullable String dialect)
    • 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 via SqlParser.Config.timeUnitCodes().
    • testMetadata

      @Test protected void testMetadata()
    • testHoist

      @Test protected void testHoist()
      Tests Hoist.
    • testLambdaExpression

      @Test public void testLambdaExpression()
      Tests SqlLambda.
    • varToStr

      protected static String varToStr(Hoist.Variable v)