JSqlParser icon indicating copy to clipboard operation
JSqlParser copied to clipboard

use arrayMap function when Mybatis-plus integrated clickhouse appear: optimize this sql to a count sql has exception net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "(" "("

Open it-learning-diary opened this issue 3 years ago • 4 comments

Describe the bug use clickhouse database arrayMap function

To Reproduce Steps to reproduce the behavior:

  1. Example SQL select card_type, origin_account, trade_account, // 异常情况在执行arrayMap处 arrayMap(x -> (toDecimal128(x,15) * toDecimal128(transfer_preference_amount,15)),prefer_path_ratio) as merge_line_ratio FROM t_xxx

  2. Exception // 1 optimize this sql to a count sql has exception,sql:" select card_type, origin_account, trade_account, arrayMap(x->(toDecimal128(x,15) * toDecimal128(transfer_preference_amount,15)),prefer_path_ratio) as merge_line_ratio FROM t_xxx"

// 2 exception: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "(" "(" at line 161, column 25.

Was expecting one of:

"&" ")" "," "::" "<<" ">>" "ACTION" "ANY" "AS" "BYTE" "CASCADE" "CAST" "CHANGE" "CHAR" "CHARACTER" "COLLATE" "COLUMN" "COLUMNS" "COMMENT" "COMMIT" "CONNECT" "CYCLE" "DESC" "DESCRIBE" "DISABLE" "DIV" "DO" "DUPLICATE" "ENABLE" "END" "EXCEPT" "EXCLUDE" "EXTRACT" "FALSE" "FIRST" "FN" "FOLLOWING" "FOR" "FORMAT" "FROM" "GROUP" "HAVING" "INDEX" "INSERT" "INTERSECT" "INTERVAL" "INTO" "ISNULL" "KEY" "LAST" "MATERIALIZED" "MINUS" "NEXTVAL" "NO" "NOLOCK" "NULLS" "OF" "OPEN" "ORDER" "OVER" "PARTITION" "PATH" "PERCENT" "PRECISION" "PRIMARY" "PRIOR" "RANGE" "READ" "REPLACE" "ROW" "ROWS" "SCHEMA" "SEPARATOR" "SEQUENCE" "SESSION" "SIBLINGS" "SIZE" "START" "TABLE" "TEMP" "TEMPORARY" "TO" "TOP" "TRUE" "TRUNCATE" "TYPE" "UNION" "UNSIGNED" "VALIDATE" "VALUE" "VALUES" "VIEW" "WHERE" "WINDOW" "XML" "ZONE" "[" "^" "|" <K_DATETIMELITERAL> <K_DATE_LITERAL> <S_CHAR_LITERAL> <S_IDENTIFIER> <S_QUOTED_IDENTIFIER>

Expected behavior Does not allow for warn log when Example this SQL

System

  • Database you are using:clickhouse
  • Java Version:JDK1.8
  • JSqlParser version:jsqlparser-4.0

it-learning-diary avatar Apr 18 '22 02:04 it-learning-diary

The clickhouse specific -> operator is not supported in the context of higher order functions and lambda functions. In JSQLParser, the -> operator is used for JSON.

manticore-projects avatar Apr 18 '22 05:04 manticore-projects

thanks ! so this problem is can't solve? it will be support this operator in new version?

it-learning-diary avatar Apr 18 '22 07:04 it-learning-diary

JSQLParser is open source software and you challenge can be solved, when there is enough interest in supporting the Clickhouse specific dialect.

You best option was to provide a Pull Request or to sponsor an implementation.

manticore-projects avatar Apr 18 '22 07:04 manticore-projects

JSQLParser is open source software and you challenge can be solved, when there is enough interest in supporting the Clickhouse specific dialect.

You best option was to provide a Pull Request or to sponsor an implementation.

Thanks! i get it!

it-learning-diary avatar Apr 18 '22 08:04 it-learning-diary

Closed, since no further question has been asked.

manticore-projects avatar Nov 12 '22 06:11 manticore-projects