### Question:
SqlParser { public SqlAbstractParserImpl.Metadata getMetadata() { return parser.getMetadata(); } private  SqlParser(SqlAbstractParserImpl parser,
      Config config); static SqlParser create(String s); static SqlParser create(String sql, Config config); static SqlParser create(Reader reader, Config config); SqlNode parseExpression(); SqlNode parseQuery(); SqlNode parseQuery(String sql); SqlNode parseStmt(); SqlNodeList parseStmtList(); SqlAbstractParserImpl.Metadata getMetadata(); static ConfigBuilder configBuilder(); static ConfigBuilder configBuilder(Config config); static final int DEFAULT_IDENTIFIER_MAX_LENGTH; @Deprecated // to be removed before 2.0
  static final boolean DEFAULT_ALLOW_BANG_EQUAL; }### Answer:
@Test public void testMetadata() { SqlAbstractParserImpl.Metadata metadata = getSqlParser("").getMetadata(); assertThat(metadata.isReservedFunctionName("ABS"), is(true)); assertThat(metadata.isReservedFunctionName("FOO"), is(false)); assertThat(metadata.isContextVariableName("CURRENT_USER"), is(true)); assertThat(metadata.isContextVariableName("CURRENT_CATALOG"), is(true)); assertThat(metadata.isContextVariableName("CURRENT_SCHEMA"), is(true)); assertThat(metadata.isContextVariableName("ABS"), is(false)); assertThat(metadata.isContextVariableName("FOO"), is(false)); assertThat(metadata.isNonReservedKeyword("A"), is(true)); assertThat(metadata.isNonReservedKeyword("KEY"), is(true)); assertThat(metadata.isNonReservedKeyword("SELECT"), is(false)); assertThat(metadata.isNonReservedKeyword("FOO"), is(false)); assertThat(metadata.isNonReservedKeyword("ABS"), is(false)); assertThat(metadata.isKeyword("ABS"), is(true)); assertThat(metadata.isKeyword("CURRENT_USER"), is(true)); assertThat(metadata.isKeyword("CURRENT_CATALOG"), is(true)); assertThat(metadata.isKeyword("CURRENT_SCHEMA"), is(true)); assertThat(metadata.isKeyword("KEY"), is(true)); assertThat(metadata.isKeyword("SELECT"), is(true)); assertThat(metadata.isKeyword("HAVING"), is(true)); assertThat(metadata.isKeyword("A"), is(true)); assertThat(metadata.isKeyword("BAR"), is(false)); assertThat(metadata.isReservedWord("SELECT"), is(true)); assertThat(metadata.isReservedWord("CURRENT_CATALOG"), is(true)); assertThat(metadata.isReservedWord("CURRENT_SCHEMA"), is(true)); assertThat(metadata.isReservedWord("KEY"), is(false)); String jdbcKeywords = metadata.getJdbcKeywords(); assertThat(jdbcKeywords.contains(",COLLECT,"), is(true)); assertThat(!jdbcKeywords.contains(",SELECT,"), is(true)); }
@Test public void testNoUnintendedNewReservedKeywords() { assumeTrue("don't run this test for sub-classes", isNotSubclass()); final SqlAbstractParserImpl.Metadata metadata = getSqlParser("").getMetadata(); final SortedSet<String> reservedKeywords = new TreeSet<>(); final SortedSet<String> keywords92 = keywords("92"); for (String s : metadata.getTokens()) { if (metadata.isKeyword(s) && metadata.isReservedWord(s)) { reservedKeywords.add(s); } if (false) { assertThat(s, metadata.isSql92ReservedWord(s), is(keywords92.contains(s))); } } final String reason = "The parser has at least one new reserved keyword. " + "Are you sure it should be reserved? Difference:\n" + DiffTestCase.diffLines(ImmutableList.copyOf(getReservedKeywords()), ImmutableList.copyOf(reservedKeywords)); assertThat(reason, reservedKeywords, is(getReservedKeywords())); }