File: duckdb_columns.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 (92 lines) | stat: -rw-r--r-- 2,150 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
# name: test/sql/table_function/duckdb_columns.test
# description: Test duckdb_columns function
# group: [table_function]

statement ok
set storage_compatibility_version='v0.10.2'

statement ok
PRAGMA enable_verification

statement ok nosort duckdb_col
SELECT * FROM duckdb_columns();

statement ok nosort duckdb_col
SELECT * FROM duckdb_columns;

statement ok
CREATE TABLE integers(i INTEGER)

statement ok
CREATE TABLE test(i INTEGER NOT NULL, j DECIMAL(18, 3), k VARCHAR DEFAULT 'hello')

query IIIIIIII
SELECT tables.table_name, column_name, data_type, column_default, is_nullable, numeric_precision, numeric_precision_radix, numeric_scale
FROM duckdb_columns cols JOIN duckdb_tables tables USING (table_oid) ORDER BY 1, 2, 3;
----
integers	i	INTEGER	NULL	True	32	2	0
test	i	INTEGER	NULL	False	32	2	0
test	j	DECIMAL(18,3)	NULL	True	18	10	3
test	k	VARCHAR	'hello'	True	NULL	NULL	NULL

query I
SELECT DISTINCT(cols.database_name) = current_database()
FROM duckdb_columns cols JOIN duckdb_tables tables USING (table_oid);
----
True

statement ok
create view v1 as select * from test

query II
select table_name, column_name from duckdb_columns where table_name = 'v1'
----
v1	i
v1	j
v1	k

statement ok
alter table test rename column j to renamed

# Rename of the base table is not reflected in the view's info
query II
select table_name, column_name from duckdb_columns where table_name = 'v1'
----
v1	i
v1	j
v1	k

statement ok
alter table test rename column renamed to j

statement ok
create or replace view v1 (a, b) as select * from test;

query II
select table_name, column_name from duckdb_columns where table_name = 'v1'
----
v1	a
v1	b
v1	k

statement ok
alter table test rename column j to renamed

# The rename of 'j' is not reflected in the view's info because it was aliased to 'b'
query II
select table_name, column_name from duckdb_columns where table_name = 'v1'
----
v1	a
v1	b
v1	k

statement ok
alter table test rename column k to not_k

# The rename of 'k' is also not reflected in the view's info even though it was not aliased
query II
select table_name, column_name from duckdb_columns where table_name = 'v1'
----
v1	a
v1	b
v1	k