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

Import into xxx from select xxx group by a with thread=x will report syntax error #58118

Open
Defined2014 opened this issue Dec 10, 2024 · 3 comments
Labels
component/import type/enhancement The issue or PR belongs to an enhancement.

Comments

@Defined2014
Copy link
Contributor

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

create table t(a int);
insert into t values (1);
create table t1(a int);
import into t1 from select sum(a) from t group by a with thread=1; -- syntax error
import into t1 from select sum(a) from t group by a with rollup with thread=1; -- no error

2. What did you expect to see? (Required)

no error

3. What did you see instead (Required)

report error

4. What is your TiDB version? (Required)

mysql> select tidb_version();
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()                                                                                                                                                                                                                                                           |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v8.5.0-alpha-296-g8c888234ff
Edition: Community
Git Commit Hash: 8c888234ff2a6c606593db3d1ebc929f0cd7f876
Git Branch: master
UTC Build Time: 2024-12-09 02:23:26
GoVersion: go1.23.4
Race Enabled: false
Check Table Before Drop: false
Store: unistore |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

A workaround way, create a view to instead of directly use group by sql.

@D3Hunter
Copy link
Contributor

import into t1 from select sum(a) from t group by a with thread=1; -- syntax error

yes, with import-options might conflict with with rollup, you can wrap the query inside parenthesis, like

mysql> import into t1 from (select sum(a) from t group by a) with thread=1;
Query OK, 0 rows affected (0.18 sec)
Records: 0, ID: 17c6e44c-26f2-43cc-ae14-89c8dc83389b

@D3Hunter D3Hunter removed type/bug The issue is confirmed as a bug. severity/moderate labels Dec 10, 2024
@D3Hunter
Copy link
Contributor

it's not a bug, will update doc about this behavior later

@lance6716 lance6716 added the type/enhancement The issue or PR belongs to an enhancement. label Dec 10, 2024
@lance6716
Copy link
Contributor

pingcap/docs-cn#19261

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/import type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

No branches or pull requests

3 participants