cube2222 / octosql

OctoSQL is a query tool that allows you to join, analyse and transform data from multiple databases and file formats using SQL.
Mozilla Public License 2.0
4.76k stars 200 forks source link

mysql query error #197

Closed will2love closed 2 years ago

will2love commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

cube2222 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

cube2222 commented 4 years ago

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

will2love commented 4 years ago

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

will2love commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 :)