Skip to content

[jdbc-v2] Antlr4 parser throws org.antlr.v4.runtime.NoViableAltException for string intervals #2429

@Gerrit-K

Description

@Gerrit-K

Description

The Antlr4 parser throws a org.antlr.v4.runtime.NoViableAltException on the following valid ClickHouse query:

SqlParser parser = new SqlParser();
ParsedStatement stmt = parser.parsedStatement("SELECT INTERVAL '1 day'");
assertTrue(stmt.isHasErrors());

Without the string quotes, it parses the interval correctly:

SqlParser parser = new SqlParser();
ParsedStatement stmt = parser.parsedStatement("SELECT INTERVAL 1 day");
assertFalse(stmt.isHasErrors());

When debugging this in the test, you can see that inside parsedStatement() the parseTree.children.get(0).exception is org.antlr.v4.runtime.NoViableAltException.


While debugging this, I was also wondering: are the tests in SqlParserTest (and potentially all non-integration tests) even picked up in CI? I noticed that they are neither run in mvn verify nor in mvn test 🤔 (unless my local env is not setup correctly or I'm doing something wrong)
Edit: I think I found the cause for that and opened #2430

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions