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

Support CREATE TABLE table_name(...schema_fields) #4396

Closed
Tracked by #4460
mvanschellebeeck opened this issue Nov 27, 2022 · 3 comments · Fixed by #5026
Closed
Tracked by #4460

Support CREATE TABLE table_name(...schema_fields) #4396

mvanschellebeeck opened this issue Nov 27, 2022 · 3 comments · Fixed by #5026
Assignees
Labels
enhancement New feature or request sqllogictest SQL Logic Tests (.slt)

Comments

@mvanschellebeeck
Copy link
Contributor

mvanschellebeeck commented Nov 27, 2022

Describe the solution you'd like
Support the CREATE TABLE expression, e.g.
CREATE TABLE t1(a INTEGER, b INTEGER, c INTEGER, d INTEGER, e INTEGER);

Executing this with datafusion-cli shows:

DataFusion CLI v14.0.0
❯ CREATE TABLE t1(a INTEGER, b INTEGER, c INTEGER, d INTEGER, e INTEGER);
NotImplemented("Only `CREATE TABLE table_name AS SELECT ...` statement is supported")

Additional context
The ability to create a table with one statement and then insert values into it throughout a sessions forms the basis of a lot of sqllogictests we want to incorporate into testing. See #4248

@mvanschellebeeck mvanschellebeeck added the enhancement New feature or request label Nov 27, 2022
@mvanschellebeeck
Copy link
Contributor Author

mvanschellebeeck commented Nov 27, 2022

An example of a set of queries we'd like to execute are:

statement ok
CREATE TABLE t1(a INTEGER, b INTEGER, c INTEGER, d INTEGER, e INTEGER)

statement ok
INSERT INTO t1(e,c,b,d,a) VALUES(103,102,100,101,104)

statement ok
INSERT INTO t1(a,c,d,e,b) VALUES(107,106,108,109,105)

...

statement ok
INSERT INTO t1(e,c,a,d,b) VALUES(177,176,179,178,175)

statement ok
INSERT INTO t1(b,e,a,d,c) VALUES(181,180,182,183,184)

statement ok
INSERT INTO t1(c,a,b,e,d) VALUES(187,188,186,189,185)

statement ok
INSERT INTO

statement ok
INSERT INTO t1(e,c,b,a,d) VALUES(242,244,240,243,241)

statement ok
INSERT INTO t1(e,d,c,b,a) VALUES(246,248,247,249,245)

query I nosort
SELECT CASE WHEN c>(SELECT avg(c) FROM t1) THEN a*2 ELSE b*10 END
  FROM t1
 ORDER BY 1
----
30 values hashing to 3c13dee48d9356ae19af2515e05e6b54

see here for reference

Currently this is not possible since the CREATE TABLE expression is not supported.

@xudong963
Copy link
Member

I'll do it (maybe on the weekend)

@xudong963 xudong963 self-assigned this Dec 2, 2022
@xudong963 xudong963 added the sqllogictest SQL Logic Tests (.slt) label Dec 4, 2022
@melgenek
Copy link
Contributor

@xudong963 Hi! I see that the ticket is assigned to you, but I gave it a shot. I hope it's alright 🙂 . Here is the pr #5026.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request sqllogictest SQL Logic Tests (.slt)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants