Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The parameter data format cannot be changed when assembling SQL query parameters. When parameter variables are added to the create table name and used, the " signs" on both sides of the variables cannot be removed. #16344

Open
3 tasks done
kieryum opened this issue Jul 18, 2024 · 2 comments
Labels
bug Something isn't working good first issue good first issue

Comments

@kieryum
Copy link

kieryum commented Jul 18, 2024

Search before asking

  • I had searched in the issues and found no similar issues.

What happened

错误:
[INFO] 2024-07-18 03:25:56.962 -0400 - prepare statement replace sql : create table xxx_x_?
PRIMARY KEY keys
as select ?,? as keys, sql parameters : {1=Property{prop='table_name', direct=IN, type=VARCHAR, value='123'}, 2=Property{prop='var_1', direct=IN, type=VARCHAR, value='23'}, 3=Property{prop='var_2', direct=IN, type=VARCHAR, value='50'}}
[ERROR] 2024-07-18 03:25:56.987 -0400 - execute sql error: Code: 62. DB::Exception: Syntax error: failed at position 20 (''123'') (line 1, col 20): '123'
PRIMARY KEY keys
as select '23','50' as keys. Expected one of: token, Dot, UUID, ON, OpeningRoundBracket, storage definition, ENGINE, PARTITION BY, PRIMARY KEY, ORDER BY, SAMPLE BY, TTL, EMPTY AS, AS, COMMENT, INTO OUTFILE, FORMAT, SETTINGS, end of query. (SYNTAX_ERROR) (version 24.5.3.5 (official build))
, server ClickHouseNode [uri=http://10.10.60.26:8123/default]@-366638818
[ERROR] 2024-07-18 03:25:57.432 -0400 - sql task error
java.sql.BatchUpdateException: Code: 62. DB::Exception: Syntax error: failed at position 20 (''123'') (line 1, col 20): '123'
PRIMARY KEY keys
as select '23','50' as keys. Expected one of: token, Dot, UUID, ON, OpeningRoundBracket, storage definition, ENGINE, PARTITION BY, PRIMARY KEY, ORDER BY, SAMPLE BY, TTL, EMPTY AS, AS, COMMENT, INTO OUTFILE, FORMAT, SETTINGS, end of query. (SYNTAX_ERROR) (version 24.5.3.5 (official build))

我的目标:
在上游节点生成参数,在下游节点上通过上游的传参动态生成数据表。发现上游数据类型无论怎么变化,下游拿到的依然时字符串带双引号。
例如:我想生成脚本:create table xxxx_${table_name} as select xxxx ; 动态参数 ${table_name} 为 1001 或者 xx_01
实际生成了create table xxxx_'1001' as select xxxx ; 或者 create table xxxx_'xx_01' as select xxxx ;
无论上游的out 出的数据是 long 还是 interger 都无法改变现状

What you expected to happen

官方文档告诉这里是可用的。
当接收到上游的数据${table_name}=xx_001 值后 , 下游在使用时可以 create table xxx_${table_name} 可以生成 create table xx_001 ...
现实是生成了 create table 'xx_001' .

How to reproduce

目前只在sql 上出现,shell 中没有出现

Anything else

No response

Version

3.2.x

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

@kieryum kieryum added bug Something isn't working Waiting for reply Waiting for reply labels Jul 18, 2024
Copy link

Search before asking

  • I had searched in the issues and found no similar issues.

What happened

错误:
[INFO] 2024-07-18 03:25:56.962 -0400 - prepare statement replace sql : create table xxx_x_?
PRIMARY KEY keys
as select ?,? as keys, sql parameters : {1=Property{prop='table_name', direct=IN, type=VARCHAR, value='123'}, 2=Property{prop='var_1', direct=IN, type=VARCHAR, value='23'}, 3=Property{prop='var_2', direct=IN, type=VARCHAR, value='50'}}
[ERROR] 2024-07-18 03:25:56.987 -0400 - execute sql error: Code: 62. DB::Exception: Syntax error: failed at position 20 (''123'') (line 1, col 20): '123'
PRIMARY KEY keys
as select '23','50' as keys. Expected one of: token, Dot, UUID, ON, OpeningRoundBracket, storage definition, ENGINE, PARTITION BY, PRIMARY KEY, ORDER BY, SAMPLE BY, TTL, EMPTY AS, AS, COMMENT, INTO OUTFILE, FORMAT, SETTINGS, end of query. (SYNTAX_ERROR) (version 24.5.3.5 (official build))
, server ClickHouseNode [uri=http://10.10.60.26:8123/default]@-366638818
[ERROR] 2024-07-18 03:25:57.432 -0400 - sql task error
java.sql.BatchUpdateException: Code: 62. DB::Exception: Syntax error: failed at position 20 (''123'') (line 1, col 20): '123'
PRIMARY KEY keys
as select '23','50' as keys. Expected one of: token, Dot, UUID, ON, OpeningRoundBracket, storage definition, ENGINE, PARTITION BY, PRIMARY KEY, ORDER BY, SAMPLE BY, TTL, EMPTY AS, AS, COMMENT, INTO OUTFILE, FORMAT, SETTINGS, end of query. (SYNTAX_ERROR) (version 24.5.3.5 (official build))

我的目标:
在上游节点生成参数,在下游节点上通过上游的传参动态生成数据表。发现上游数据类型无论怎么变化,下游拿到的依然时字符串带双引号。
例如:我想生成脚本:create table xxxx_${table_name} as select xxxx ; 动态参数 ${table_name} 为 1001 或者 xx_01
实际生成了create table xxxx_'1001' as select xxxx ; 或者 create table xxxx_'xx_01' as select xxxx ;
无论上游的out 出的数据是 long 还是 interger 都无法改变现状

What you expected to happen

官方文档告诉这里是可用的。
当接收到上游的数据${table_name}=xx_001 值后 , 下游在使用时可以 create table xxx_${table_name} 可以生成 create table xx_001 ...
现实是生成了 create table 'xx_001' .

How to reproduce

目前只在sql 上出现,shell 中没有出现

Anything else

No response

Version

3.2.x

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

@github-actions github-actions bot changed the title 组装SQL查询参数时参数数据形式无法被改变,当参数变量添加在 create 表名上应用时,无法去掉 变量两边的“号。 The parameter data format cannot be changed when assembling SQL query parameters. When parameter variables are added to the create table name and used, the " signs" on both sides of the variables cannot be removed. Jul 18, 2024
@SbloodyS SbloodyS added good first issue good first issue and removed Waiting for reply Waiting for reply labels Jul 19, 2024
@kieryum
Copy link
Author

kieryum commented Jul 19, 2024

测试了 3.2.1 3.2.0 都不行。直到3.1.9 是可用的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue good first issue
Projects
None yet
Development

No branches or pull requests

2 participants