Skip to content

Does it has anything to do with desc field? #1053

@wat1r

Description

@wat1r

Background

using the jsqlparser to process the sql , and integrate it to the data processing ,the following case is using the PRESTO engine

Describe the bug

ERROR-1

{"state":"ERROR","msg":"Query failed (#20200925_023246_00132_7hun5): line 1:183: mismatched input '200'. Expecting: '%', '*', '+', '-', '.', '/', 'AT', '[', '||', <expression>"}

when entering the function ,this happens when processing with field a.desc

image

the SQL-1

select
  a.data_date,
  a.id,
  a.mallkey,
  a.icon,
  a.adicon,
  a.name,
  a.desc,
  a.content,
  a.pricetype,
  a.originalprice,
  a.pricecount,
  a.limitbuytype,
  a.limitbuycount
from
  temp_dev.test_table a
where
  a.part_date = '2020-09-24'
limit
  200

when process with SQL-1 it will be ERROR-1


when we remove a.desc , it can pass and process ok , like SQL-2:

select
  a.data_date,
  a.id,
  a.mallkey,
  a.icon,
  a.adicon,
  a.name,
  a.content,
  a.pricetype,
  a.originalprice,
  a.pricecount,
  a.limitbuytype,
  a.limitbuycount
from
  temp_dev.test_table a
where
  a.part_date = '2020-09-24'
limit
  200

also when we remove two other fields like SQL-3:

select
  a.data_date,
  a.id,
  a.mallkey,
  a.icon,
  a.adicon,
  a.name,
  a.desc,
  a.content,
  a.pricetype,
  a.originalprice,
  a.pricecount
from
  temp_dev.test_table a
where
  a.part_date = '2020-09-24'
limit
  200

it can pass and process ok


while when we remove one other fields like SQL-4:

select
  a.data_date,
  a.id,
  a.mallkey,
  a.icon,
  a.adicon,
  a.name,
  a.desc,
  a.content,
  a.pricetype,
  a.originalprice,
  a.pricecount,
  a.limitbuytype
from
  temp_dev.test_table a
where
  a.part_date = '2020-09-24'
limit
  200

when process with SQL-4 it will be ERROR-1

System

  • Database you are using
  • Java Version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
  • JSqlParser version
        <dependency>
            <groupId>com.github.jsqlparser</groupId>
            <artifactId>jsqlparser</artifactId>
            <version>3.1</version>
        </dependency>

this is the code:

    private List<String> parseByJsqlParser(String originSql) throws JSQLParserException {
        List<String> sqlList = Lists.newArrayList();
        if (Strings.isNullOrEmpty(originSql)) {
            return sqlList;
        }
        Statements statements = CCJSqlParserUtil.parseStatements(originSql);//  the error happens when entering this function 
        List<Statement> statementList = statements.getStatements();
        statementList.forEach((Statement statement) -> {
            sqlList.add(statement.toString());
        });
        return sqlList;
    }

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