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
|
# name: test/sql/binder/test_implicit_struct_pack.test
# description: Test implicit struct pack when selecting table alias
# group: [binder]
statement ok
pragma enable_verification
statement ok
create table test as select range i from range(3)
query T
select test from test
----
{'i': 0}
{'i': 1}
{'i': 2}
# equivalent
query T nosort q0
select test from main.test
query T nosort q0
select main.test from main.test
query T nosort q0
SELECT t FROM test AS t
query T nosort q0
select t from (SELECT * FROM test) AS t
# shouldn't work
statement error
select main.test from main.test t
----
statement error
select main.t from main.test t
----
# example query in feature request
query T
WITH data AS (
SELECT 1 as a, 2 as b, 3 as c
)
SELECT d FROM data d
----
{'a': 1, 'b': 2, 'c': 3}
# schema conflict
# create ambiguity: main.test can refer to column main.test, or to table main.test
statement ok
create table main as select 3 test
# selecting the column has precedence over selecting the implicit struct_pack
query T
select main.test from main, test
----
3
3
3
query T
select test from main, test
----
3
3
3
# struct conflict
# more ambiguity: main.test can now also refer to struct field "test" of struct "main"
# selecting the struct field has precedence over selecting the implicit struct_pack
statement ok
create table structs as select {test: 4} main
query T
select main.test from structs, test
----
4
4
4
|