Skip to content

IF(boolean, 0, 1) Function parse ERROR #1284

Closed
@ghost

Description

Describe the bug
parse IF function error when first param(boolean) include logical operation
OK: sum(if(column1 in('value1', 'value2'), 1, 0)) as tcp_logs
ERROR: sum(if(column1 in ('value1', 'value2') and column2 = 'value3', 1, 0))

To Reproduce
Steps to reproduce the behavior:

  1. Example SQL
    select
    sum(if(column1 in('value1', 'value2'), 1, 0)) as tcp_logs,
    sum(if(column1 in ('value1', 'value2') and column2 = 'value3', 1, 0)) as base_tcp_logs
    from
    table1
    where
    recv_time >= toDateTime('2021-07-20 00:00:00')
    and recv_time < toDateTime('2021-07-21 00:00:00')
  2. Parsing this SQL using JSqlParser with this statements
    CCJSqlParserUtil.parse(sql)
  3. Exception
    net.sf.jsqlparser.JSQLParserException: Encountered unexpected token: "(" "("

System

  • JSqlParser version 4.1

Thanks!

Metadata

Metadata

Labels

P1high prioritybug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions