Skip to content

Commit 2269c83

Browse files
authored
Merge pull request #3182 from dolthub/angela/create_table
[no-release-notes] Added test for create table from aggregate function
2 parents f980416 + 769a1d8 commit 2269c83

File tree

4 files changed

+27
-11
lines changed

4 files changed

+27
-11
lines changed

enginetest/queries/create_table_queries.go

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,7 @@ var CreateTableScriptTests = []ScriptTest{
837837
Query: "show create table t4;",
838838
Expected: []sql.Row{
839839
{"t4", "CREATE TABLE `t4` (\n" +
840-
" `(a.j + 1)` bigint\n" +
840+
" `j + 1` bigint\n" +
841841
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"},
842842
},
843843
},
@@ -985,6 +985,28 @@ var CreateTableScriptTests = []ScriptTest{
985985
},
986986
},
987987
},
988+
{
989+
Name: "create table columns from aggregate functions",
990+
SetUpScript: []string{
991+
"create table t1 (i int)",
992+
"insert into t1 values (1)",
993+
"create table t2 select sum(i), max(i), min(i), avg(i) from t1",
994+
},
995+
Assertions: []ScriptTestAssertion{
996+
{
997+
Query: "show create table t2;",
998+
// TODO: MySQL column types are different https://github.com/dolthub/dolt/issues/9754
999+
Expected: []sql.Row{
1000+
{"t2", "CREATE TABLE `t2` (\n" +
1001+
" `sum(i)` double NOT NULL,\n" +
1002+
" `max(i)` int NOT NULL,\n" +
1003+
" `min(i)` int NOT NULL,\n" +
1004+
" `avg(i)` double\n" +
1005+
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"},
1006+
},
1007+
},
1008+
},
1009+
},
9881010
}
9891011

9901012
var CreateTableInSubroutineTests = []ScriptTest{

enginetest/queries/script_queries.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4693,7 +4693,7 @@ CREATE TABLE tab3 (
46934693
{
46944694
Query: "select COLUMN_NAME, DATA_TYPE from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME='c';",
46954695
Expected: []sql.Row{
4696-
{"coalesce(NULL,1)", "int"},
4696+
{"coalesce(NULL, 1)", "int"},
46974697
},
46984698
},
46994699
},

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/dolthub/go-icu-regex v0.0.0-20250820171420-f2b78f56ce9f
77
github.com/dolthub/jsonpath v0.0.2-0.20240227200619-19675ab05c71
88
github.com/dolthub/sqllogictest/go v0.0.0-20201107003712-816f3ae12d81
9-
github.com/dolthub/vitess v0.0.0-20250828224346-f347481664da
9+
github.com/dolthub/vitess v0.0.0-20250829222523-5a45c06a7f3e
1010
github.com/go-sql-driver/mysql v1.7.2-0.20231213112541-0004702b931d
1111
github.com/gocraft/dbr/v2 v2.7.2
1212
github.com/google/uuid v1.3.0

go.sum

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,8 @@ github.com/dolthub/jsonpath v0.0.2-0.20240227200619-19675ab05c71 h1:bMGS25NWAGTE
1818
github.com/dolthub/jsonpath v0.0.2-0.20240227200619-19675ab05c71/go.mod h1:2/2zjLQ/JOOSbbSboojeg+cAwcRV0fDLzIiWch/lhqI=
1919
github.com/dolthub/sqllogictest/go v0.0.0-20201107003712-816f3ae12d81 h1:7/v8q9XGFa6q5Ap4Z/OhNkAMBaK5YeuEzwJt+NZdhiE=
2020
github.com/dolthub/sqllogictest/go v0.0.0-20201107003712-816f3ae12d81/go.mod h1:siLfyv2c92W1eN/R4QqG/+RjjX5W2+gCTRjZxBjI3TY=
21-
github.com/dolthub/vitess v0.0.0-20250730174048-497aebb8cea7 h1:l+mWO0xoh4eG1J9gMS87opL6N6WGAQitF36R/Lg4bWs=
22-
github.com/dolthub/vitess v0.0.0-20250730174048-497aebb8cea7/go.mod h1:1gQZs/byeHLMSul3Lvl3MzioMtOW1je79QYGyi2fd70=
23-
github.com/dolthub/vitess v0.0.0-20250813175212-45844169a751 h1:BBQKyvyODewdQxS+ICklMn1d/fFj2pVlkmMN1QFY4ms=
24-
github.com/dolthub/vitess v0.0.0-20250813175212-45844169a751/go.mod h1:1gQZs/byeHLMSul3Lvl3MzioMtOW1je79QYGyi2fd70=
25-
github.com/dolthub/vitess v0.0.0-20250814204310-c749d213f235 h1:uXrK+xn8rCwz/8jWDKaDyqZG1HbZI9F4V4HJ7zXFPMY=
26-
github.com/dolthub/vitess v0.0.0-20250814204310-c749d213f235/go.mod h1:1gQZs/byeHLMSul3Lvl3MzioMtOW1je79QYGyi2fd70=
27-
github.com/dolthub/vitess v0.0.0-20250828224346-f347481664da h1:8yD4o8bK8giyoJvjxYQ48mmNoBQ1WaBOUbIGhP3J0Ms=
28-
github.com/dolthub/vitess v0.0.0-20250828224346-f347481664da/go.mod h1:1gQZs/byeHLMSul3Lvl3MzioMtOW1je79QYGyi2fd70=
21+
github.com/dolthub/vitess v0.0.0-20250829222523-5a45c06a7f3e h1:foI0Zp8ydVabVyrJm30DbAxmHqjiA2rrQG+ZpahRQeU=
22+
github.com/dolthub/vitess v0.0.0-20250829222523-5a45c06a7f3e/go.mod h1:1gQZs/byeHLMSul3Lvl3MzioMtOW1je79QYGyi2fd70=
2923
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
3024
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
3125
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=

0 commit comments

Comments
 (0)