-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Cannot access named tuple element by its name using dot #18826
Copy link
Copy link
Closed
Labels
Description
Describe the bug
Consider a column a of type Tuple(s String, i Int64). Currently we can access certain field by using any of the following expressions:
tupleElement(a, 1)
a.1
tupleElement(a, 's')
but what seems to be the most convenient way for named tuples does not work:
a.s
It would be nice to support accessing tuple elements by their names.
Reproduction on current Arcadia version from revision r7736838 (which is similar to github master around Jan 7th):
max42-dev.sas.yp-c.yandex.net :) create table t(a Tuple(s String, i Int8)) engine = Log()
CREATE TABLE t
(
`a` Tuple(s String, i Int8)
)
ENGINE = Log
Query id: f9cbbcf2-0db4-4312-bd7c-ee3e901bfdd7
Ok.
0 rows in set. Elapsed: 0.004 sec.
max42-dev.sas.yp-c.yandex.net :) insert into t values (('x', 42))
INSERT INTO t VALUES
Query id: acd443b2-1daa-43c3-b201-8713b0a2250a
Ok.
1 rows in set. Elapsed: 0.008 sec.
max42-dev.sas.yp-c.yandex.net :) select a from t
SELECT a
FROM t
Query id: bb38d164-29b6-49f4-a35c-df9f5b0b7d42
┌─a────────┐
│ ('x',42) │
└──────────┘
1 rows in set. Elapsed: 0.005 sec.
max42-dev.sas.yp-c.yandex.net :) select a.s from t
SELECT a.s
FROM t
Query id: de107034-0831-409d-a7a3-81a60c81a360
Received exception from server (version 20.13.1):
Code: 47. DB::Exception: Received from localhost:9000. DB::Exception: Missing columns: 'a.s' while processing query: 'SELECT a.s FROM t', required columns: 'a.s', maybe you meant: .
0 rows in set. Elapsed: 0.003 sec.
max42-dev.sas.yp-c.yandex.net :) select tupleElement(a, 's') from t
SELECT tupleElement(a, 's')
FROM t
Query id: b5454a30-1c16-4b8f-a4e1-9d1fde5bdf9b
┌─tupleElement(a, 's')─┐
│ x │
└──────────────────────┘
1 rows in set. Elapsed: 0.006 sec.
max42-dev.sas.yp-c.yandex.net :) select a.1 from t
SELECT a.1
FROM t
Query id: 29442b78-4235-410e-bfb1-6b6c0f624fa5
┌─tupleElement(a, 1)─┐
│ x │
└────────────────────┘
1 rows in set. Elapsed: 0.006 sec.
Reactions are currently unavailable