Can't execute query with column of type Array(Tuple(Float64, Float64)) as result.
DROP TABLE IF EXISTS test_polygon;
CREATE TABLE test_polygon
(
id Int64,
polygon Nested(
lat Float64,
lon Float64
)
)
ENGINE = Log();
INSERT INTO test_polygon VALUES
(1111, [0., 8., 7., 0.], [0., 7., 8., 0.]),
(2222, [5., 5., 4., 3., 5.], [10., 12., 11., 10., 10.]);
SELECT
id,
arrayMap((x, y) -> (x, y), polygon.lat, polygon.lon) AS polygon
FROM test_polygon
┌───id─┬─polygon──────────────────────────────┐
│ 1111 │ [(0,0),(8,7),(7,8),(0,0)] │
│ 2222 │ [(5,10),(5,12),(4,11),(3,10),(5,10)] │
└──────┴──────────────────────────────────────┘
2 rows in set. Elapsed: 0.003 sec.
KeyError Traceback (most recent call last)
~/.pyenv/versions/jupyter3.6.4/lib/python3.6/site-packages/clickhouse_driver/columns/service.py in get_column_by_spec(spec, column_options)
57 try:
---> 58 cls = column_by_type[spec]
59 return cls(**column_options)
KeyError: 'Tuple(Float64, Float64)'
During handling of the above exception, another exception occurred:
UnknownTypeError Traceback (most recent call last)
<ipython-input-51-1fc000cc1814> in <module>()
----> 1 print(client.execute('SELECT id, arrayMap((x, y)-> tuple(x, y), polygon_lat, polygon_lon) AS polygon FROM test_db.test_polygon'))
~/.pyenv/versions/jupyter3.6.4/lib/python3.6/site-packages/clickhouse_driver/client.py in execute(self, query, params, with_column_types, external_tables, query_id, settings, types_check, columnar)
187 external_tables=external_tables,
188 query_id=query_id, settings=query_settings,
--> 189 types_check=types_check, columnar=columnar
190 )
191
~/.pyenv/versions/jupyter3.6.4/lib/python3.6/site-packages/clickhouse_driver/client.py in process_ordinary_query(self, query, params, with_column_types, external_tables, query_id, settings, types_check, columnar)
244 types_check=types_check)
245 return self.receive_result(with_column_types=with_column_types,
--> 246 columnar=columnar)
247
248 def process_insert_query(self, query_without_data, data,
~/.pyenv/versions/jupyter3.6.4/lib/python3.6/site-packages/clickhouse_driver/client.py in receive_result(self, with_column_types, progress, columnar)
80
81 else:
---> 82 self.receive_no_progress_result(result, columnar)
83 return result.get_result()
84
~/.pyenv/versions/jupyter3.6.4/lib/python3.6/site-packages/clickhouse_driver/client.py in receive_no_progress_result(self, result, columnar)
107 def receive_no_progress_result(self, result, columnar=False):
108 while True:
--> 109 packet = self.receive_packet()
110 if not packet:
111 break
~/.pyenv/versions/jupyter3.6.4/lib/python3.6/site-packages/clickhouse_driver/client.py in receive_packet(self)
138
139 def receive_packet(self):
--> 140 packet = self.connection.receive_packet()
141
142 if packet.type == ServerPacketTypes.EXCEPTION:
~/.pyenv/versions/jupyter3.6.4/lib/python3.6/site-packages/clickhouse_driver/connection.py in receive_packet(self)
332
333 if packet_type == ServerPacketTypes.DATA:
--> 334 packet.block = self.receive_data()
335
336 elif packet_type == ServerPacketTypes.EXCEPTION:
~/.pyenv/versions/jupyter3.6.4/lib/python3.6/site-packages/clickhouse_driver/connection.py in receive_data(self)
391 read_binary_str(self.fin)
392
--> 393 block = self.block_in.read()
394 self.block_in.reset()
395 return block
~/.pyenv/versions/jupyter3.6.4/lib/python3.6/site-packages/clickhouse_driver/streams/native.py in read(self)
78 if n_rows:
79 column = read_column(self.context, column_type, n_rows,
---> 80 self.fin)
81 data.append(column)
82
~/.pyenv/versions/jupyter3.6.4/lib/python3.6/site-packages/clickhouse_driver/columns/service.py in read_column(context, column_spec, n_items, buf)
65 def read_column(context, column_spec, n_items, buf):
66 column_options = {'context': context}
---> 67 column = get_column_by_spec(column_spec, column_options=column_options)
68 return column.read_data(n_items, buf)
69
~/.pyenv/versions/jupyter3.6.4/lib/python3.6/site-packages/clickhouse_driver/columns/service.py in get_column_by_spec(spec, column_options)
49
50 elif spec.startswith('Array'):
---> 51 return create_array_column(spec, create_column_with_options)
52
53 elif spec.startswith('Nullable'):
~/.pyenv/versions/jupyter3.6.4/lib/python3.6/site-packages/clickhouse_driver/columns/arraycolumn.py in create_array_column(spec, column_by_spec_getter)
186 def create_array_column(spec, column_by_spec_getter):
187 inner = spec[6:-1]
--> 188 return ArrayColumn(column_by_spec_getter(inner))
~/.pyenv/versions/jupyter3.6.4/lib/python3.6/site-packages/clickhouse_driver/columns/service.py in create_column_with_options(x)
37
38 def create_column_with_options(x):
---> 39 return get_column_by_spec(x, column_options)
40
41 if spec.startswith('FixedString'):
~/.pyenv/versions/jupyter3.6.4/lib/python3.6/site-packages/clickhouse_driver/columns/service.py in get_column_by_spec(spec, column_options)
60
61 except KeyError as e:
---> 62 raise errors.UnknownTypeError('Unknown type {}'.format(e.args[0]))
63
64
UnknownTypeError: Code: 50. Unknown type Tuple(Float64, Float64)