dble
dble copied to clipboard
"select *, select 3 from table_a" expect syntax error, but get resultset
- dble version: 5.6.29-dble-9.9.9.9-287a2f4-20180921052651
-
preconditions :
no - configs:
schema.xml
<table name="table_a" primaryKey="id" rule="hash-four" dataNode="dn1,dn2,dn3,dn4"></table>
-
steps:
step1. with dble and compare mysql execute sqls to prepare env:
create table table_a(id int, name varchar(20));
insert into table_a values(1,'a'),(2,'b');
step2.exeucte queries with mysql
mysql> select *, select 3 from table_a limit 1;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select 3 from table_a limit 1' at line 1
step3.execute queries with dble
mysql> select *, select 3 from table_a limit 1;
+------------------+
| autoalias_scalar |
+------------------+
| 3 |
+------------------+
1 row in set (0.02 sec)
mysql> explain select *, select 3 from table_a limit 1;
+--------------------+-----------------------+----------------------------------+
| DATA_NODE | TYPE | SQL/REF |
+--------------------+-----------------------+----------------------------------+
| dn1_0 | BASE SQL | select 1 from `table_a` LIMIT 1 |
| dn2_0 | BASE SQL | select 1 from `table_a` LIMIT 1 |
| dn3_0 | BASE SQL | select 1 from `table_a` LIMIT 1 |
| dn4_0 | BASE SQL | select 1 from `table_a` LIMIT 1 |
| merge_1 | MERGE | dn1_0; dn2_0; dn3_0; dn4_0 |
| limit_1 | LIMIT | merge_1 |
| shuffle_field_1 | SHUFFLE_FIELD | limit_1 |
| scalar_sub_query_1 | SCALAR_SUB_QUERY | shuffle_field_1 |
| dn1_1 | BASE SQL(May No Need) | scalar_sub_query_1; select 1 |
| merge_2 | MERGE | dn1_1 |
| shuffle_field_2 | SHUFFLE_FIELD | merge_2 |
+--------------------+-----------------------+----------------------------------+
11 rows in set (0.00 sec)
-
expect result:
1.step3 get similar result with step2 -
real result:
1.dble with subquery without parenthesis between select and from get success -
supplements:
- dble's query plan seems a little strange.
- my real meant is to execute "select *, (select 3) from table_a limit 1;"
/label ~BUG
druid parser parse the sql as select *,(select 3 from table_a limit 1) ,the parse result is wrong.