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

mysql query error #197

Closed
will2love opened this issue Mar 18, 2020 · 12 comments
Closed

mysql query error #197

will2love opened this issue Mar 18, 2020 · 12 comments

Comments

@will2love
Copy link

will2love commented Mar 18, 2020

CREATE TABLE test_config (
id bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增id',
test_config_id bigint(20) NOT NULL COMMENT '',
test_id varchar(64) NOT NULL COMMENT '实验id ',
test_name varchar(64) NOT NULL COMMENT ' ',
flow_id bigint(20) NOT NULL COMMENT ' ',
start_time datetime NOT NULL COMMENT '开始时间',
end_time datetime NOT NULL COMMENT '结束时间',
test_status bigint(20) NOT NULL DEFAULT '0' ',
creater varchar(16) NOT NULL COMMENT '创建人',
group_info varchar(1024) NOT NULL COMMENT '',
sys_ctime datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
sys_utime datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
is_del tinyint(4) DEFAULT '0' COMMENT '删除标志位 0:未删除 1:删除',
PRIMARY KEY (id),
UNIQUE KEY uniq_config_id (test_config_id),
UNIQUE KEY uniq_test_id (test_status,flow_id)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8 COMMENT='实验配置表';

sql:
select * from mysql_test t where t.creater='will'
sql2:
select * from mysql_test t where t.test_name='test'

when my query condition is a string , also get error:
couldn't get record stream from execution plan: couldn't query statement: sql: converting argument $1 type: unsupported type octosql.String, a string

but sql:
select * from mysql_test t where t.id=7
select * from mysql_test t where t.flow_id=1111

when my query condition is a int
can show successful result :
{"t.creater":"williehu","t.end_time":{},"t.flow_id":10003,"t.group_info":"test","t.id":7,"t.is_del":0,"t.start_time":{},"t.sys_ctime":{},"t.sys_utime":{},"t.test_config_id":121321,"t.test_id":"mongo","t.test_name":"test","t.test_status":0}

Have any config must to set ?

@cube2222
Copy link
Owner

Could you please try the current version from the master branch? I think this has already been fixed there:

GO111MODULE=on go get -u github.com/cube2222/octosql/cmd/octosql@6c111421de240b28f28edcb6a7d2272ea4630a92

@will2love
Copy link
Author

now I use the branch v0.2.0 . and I don't know which branch is the latest and most stable

@cube2222
Copy link
Owner

cube2222 commented Mar 18, 2020

I've sent you the bash command to install the latest version (master branch). I just want to know if the problem is still there or not. If not, there should be a new release soon based on the current master branch.

@will2love
Copy link
Author

Thanks
The above problems have been solved,but I use mysql test sub query have some issues.

sql:
select * from (select t.id from mysql_test t where t.test_name = 'test') d

result is successful .

sql2:
select * from (select * from mysql_test t where t.test_name = 'test') d
result is null. why?

@cube2222
Copy link
Owner

cube2222 commented Mar 18, 2020

It's a bug, thanks!

I just tested it and the optimizer incorrectly changes the alias of the datasource without changing the variables beneath.

The first query puts a map above the datasource so the optimizer can't push the new alias down.

image

PS: You can get a graph such as the above on the master branch using:

octosql 'select * from (select * from mysql_test t where t.test_name = "test") d' --describe | dot -Tpng > test.png

@will2love
Copy link
Author

ok, Is there any plan to fix this bug to master branch when next commit?

@cube2222
Copy link
Owner

We'll try to fix it in time for the next release, as it's a pretty severe bug.

@will2love
Copy link
Author

If this bug is fixed, please remind me and close this issue
thank you!

@will2love
Copy link
Author

when I query mysql datetime field ,but it return {}
all datetime field return {}

sql :
select t.start_time from mysql_test t where t.id = 7

result:
t.start_time":{}

this is a bug when query mysql datatime field?

@JasiekChomiak
Copy link
Collaborator

JasiekChomiak commented Mar 19, 2020

Hi - unfortunately I couldn't reproduce the problem you are having. Could you maybe create a small table, try to replicate the issue and then send the rows?

@JasiekChomiak
Copy link
Collaborator

Follow up:

  1. I created a MySQL TABLE:
    CREATE TABLE timers(id INT, str VARCHAR(10), t DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP)

  2. Inserted values:
    INSERT INTO timers (id, str) VALUES (1, 'a')
    INSERT INTO timers (id, str) VALUES (2, 'b')
    INSERT INTO timers (id, str) VALUES (3, 'c')

  3. Run SELECT t.t FROM timers t WHERE t.id = 2 and got the expected result

@JasiekChomiak
Copy link
Collaborator

As to your select * from (select * from mysql_test t where t.test_name = 'test') d problem, the fix was pushed onto the master branch and this query should now be working fine :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants