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

left/right/substring from mysql table reports error #6381

Closed
RangerWolf opened this issue Aug 7, 2019 · 2 comments · Fixed by #6676
Closed

left/right/substring from mysql table reports error #6381

RangerWolf opened this issue Aug 7, 2019 · 2 comments · Fixed by #6676
Assignees
Labels
bug Confirmed user-visible misbehaviour in official release

Comments

@RangerWolf
Copy link

RangerWolf commented Aug 7, 2019

Describe the bug
Could not use left or right or substring when selecting data from mysql directly

How to reproduce

  • Version: 19.11.2
  • SQL that could run with error
-- Exception msg for below sql : 
-- Code: 1000. DB::Exception: Received from clickhouse-server:9000. DB::Exception: mysqlxx::BadQuery: Operand should contain 1 column(s)
select 
            `id`
from mysql('host:port', 'database', 'tablename', 'username', 'password')
where 1=1 and left(stat_datetime, 10)='2019-08-07'  and advertiser_id = '12345'
  • SQL that runs OK
select 
	`id`
from mysql('host:port', 'database', 'tablename', 'username', 'password')
where 1=1 and advertiser_id = '12345'

Expected behavior
Both SQL should run OK

@RangerWolf RangerWolf added the bug Confirmed user-visible misbehaviour in official release label Aug 7, 2019
alexey-milovidov added a commit that referenced this issue Aug 7, 2019
@alexey-milovidov
Copy link
Member

@dimarub2000 Please try to reproduce this issue.

@dimarub2000
Copy link
Contributor

dimarub2000 commented Aug 23, 2019

Reproduced the issue, trying to find the problem.
when select * from mysql('localhost:3306', 'test', 'kek', 'dsrub', 'kek') where id=123 and 1=1;
mysql gets SELECT `s`, `id` FROM `test`.`kek` WHERE (`id` = 123) AND (1 = 1)

when select * from mysql('localhost:3306', 'test', 'kek', 'dsrub', 'kek') where left(s, 2) = 'ke'
mysql gets SELECT `s`, `id` FROM `test`.`kek`

when select * from mysql('localhost:3306', 'test', 'kek', 'dsrub', 'kek') where left(s, 2) = 'ke' and id=123 and 1=1;
mysql gets SELECT `s`, `id` FROM `test`.`kek` WHERE (`id` = 123, 1 = 1)

why substring() function is not sent to mysql but is processed localy?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed user-visible misbehaviour in official release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants