File: create_table.test

package info (click to toggle)
duckdb 1.5.1-2
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 299,196 kB
  • sloc: cpp: 865,414; ansic: 57,292; python: 18,871; sql: 12,663; lisp: 11,751; yacc: 7,412; lex: 1,682; sh: 747; makefile: 558
file content (129 lines) | stat: -rw-r--r-- 2,998 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# name: test/sql/function/autocomplete/create_table.test
# description: Test sql_auto_complete
# group: [autocomplete]

require autocomplete

# CREATE
query II
SELECT suggestion, suggestion_start FROM sql_auto_complete('CR') LIMIT 1;
----
CREATE 	0

# match case
query II
SELECT suggestion, suggestion_start FROM sql_auto_complete('cr') LIMIT 1;
----
create 	0

query II
SELECT suggestion, suggestion_start FROM sql_auto_complete('CREATE TA') LIMIT 1;
----
TABLE 	7

query II
SELECT suggestion, suggestion_start FROM sql_auto_complete('CREATE T') LIMIT 1;
----
TABLE 	7

query II
SELECT suggestion, suggestion_start FROM sql_auto_complete('CREATE OR RE') LIMIT 1;
----
REPLACE 	10

query II
SELECT suggestion, suggestion_start FROM sql_auto_complete('create ta') LIMIT 1;
----
table 	7

# suggest a type
query II
SELECT suggestion, suggestion_start FROM sql_auto_complete('create table tbl(i INTE') LIMIT 1;
----
INTEGER	19

# suggest a type in a list
query II
SELECT suggestion, suggestion_start FROM sql_auto_complete('create table tbl(i INTEGER, j INTE') LIMIT 1;
----
INTEGER	30

# suggest a constraint
query II
SELECT suggestion, suggestion_start FROM sql_auto_complete('create table tbl(i INTEGER PRI') LIMIT 1;
----
PRIMARY 	27

query II
SELECT suggestion, suggestion_start FROM sql_auto_complete('create table tbl(i INTEGER PRIMARY KE') LIMIT 1;
----
KEY 	35

query II
SELECT suggestion, suggestion_start FROM sql_auto_complete('create table tbl(i INTEGER UNIQ') LIMIT 1;
----
UNIQUE 	27

query II
SELECT suggestion, suggestion_start FROM sql_auto_complete('create table tbl(i INTEGER UNIQUE NO') LIMIT 1;
----
NOT 	34

query II
SELECT suggestion, suggestion_start FROM sql_auto_complete('create table tbl(i INTEGER UNIQUE NOT N') LIMIT 1;
----
NULL 	38

# top-level constraints
query II
SELECT suggestion, suggestion_start FROM sql_auto_complete('create table tbl(i INTEGER, PRI') LIMIT 1;
----
PRIMARY 	28

statement ok
CREATE SCHEMA abcdefgh;

# suggest a schema name
query II
SELECT suggestion, suggestion_start FROM sql_auto_complete('CREATE TABLE abcd') LIMIT 1;
----
abcdefgh.	13

query II
SELECT suggestion, suggestion_start FROM sql_auto_complete('CREATE TABLE abcdefgh.') LIMIT 1;
----
.	21

# we suggest the original schema
query II
SELECT suggestion, suggestion_start FROM sql_auto_complete('CREATE TABLE ABCD') LIMIT 1;
----
abcdefgh.	13

# what if the schema is a keyword?
statement ok
CREATE SCHEMA "SCHEMA";

query II
SELECT suggestion, suggestion_start FROM sql_auto_complete('CREATE TABLE SC') LIMIT 1;
----
"SCHEMA".	13

# suggest a catalog
statement ok
ATTACH ':memory:' AS attached_in_memory;

query II
SELECT suggestion, suggestion_start FROM sql_auto_complete('CREATE TABLE attac') LIMIT 1;
----
attached_in_memory.	13

query II
SELECT suggestion, suggestion_start FROM sql_auto_complete('CREATE TABLE attached_in_memory.a') LIMIT 1;
----
abcdefgh.	32

statement error
FROM sql_auto_complete(NULL);
----
Binder Error: sql_auto_complete first parameter cannot be NULL