Skip to content

Query with SAFE_CAST couldn't be parsed #853

Closed
@sivaraam

Description

@sivaraam

Describe the bug
A query with SAFE_CAST function used in it could not be parsed.

To Reproduce
Steps to reproduce the behavior:

  1. Example query (reference
    SELECT SAFE_CAST("apple" AS INT64) AS not_a_number;
  2. Parsing using JSqlParser
        try {
            Statement safeCastSt =
                    CCJSqlParserUtil.parse("SELECT SAFE_CAST(\"apple\" AS INT64) AS not_a_number");
        } catch (JSQLParserException e) {
            e.printStackTrace();
        }
  3. Exception thrown
net.sf.jsqlparser.JSQLParserException
	at net.sf.jsqlparser.parser.CCJSqlParserUtil.parse(CCJSqlParserUtil.java:51)
    ...
    <snipped>
    ...
Caused by: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "(" "("
    at line 1, column 17.

Was expecting one of:

    "&"
    ","
    "::"
    ";"
    "<<"
    ">>"
    "ACTION"
    ...

Expected behavior
The query would parse successfully.

System

  • Java Version: 11.0.3
  • JSqlParser version: 3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions