ClickHouse/dbms/tests/queries/0_stateless/01037_polygon_dict.sql

71 lines
3.6 KiB
MySQL
Raw Normal View History

2019-12-25 12:05:37 +00:00
SET send_logs_level = 'none';
DROP DATABASE IF EXISTS test_01037;
CREATE DATABASE test_01037 Engine = Ordinary;
2019-12-25 12:39:49 +00:00
DROP DICTIONARY IF EXISTS test_01037.dict;
2019-12-25 12:05:37 +00:00
DROP TABLE IF EXISTS test_01037.polygons;
CREATE TABLE test_01037.polygons (key Array(Array(Array(Array(Float64)))), name String, value UInt64) ENGINE = Memory;
2019-12-25 12:39:49 +00:00
INSERT INTO test_01037.polygons VALUES ([[[[1, 3], [1, 1], [3, 1], [3, -1], [1, -1], [1, -3], [-1, -3], [-1, -1], [-3, -1], [-3, 1], [-1, 1], [-1, 3]]], [[[5, 5], [5, 1], [7, 1], [7, 7], [1, 7], [1, 5]]]], 'Click', 42);
INSERT INTO test_01037.polygons VALUES ([[[[5, 5], [5, -5], [-5, -5], [-5, 5]], [[1, 3], [1, 1], [3, 1], [3, -1], [1, -1], [1, -3], [-1, -3], [-1, -1], [-3, -1], [-3, 1], [-1, 1], [-1, 3]]]], 'House', 314159);
INSERT INTO test_01037.polygons VALUES ([[[[3, 1], [0, 1], [0, -1], [3, -1]]]], 'Click East', 421);
INSERT INTO test_01037.polygons VALUES ([[[[-1, 1], [1, 1], [1, 3], [-1, 3]]]], 'Click North', 422);
INSERT INTO test_01037.polygons VALUES ([[[[-3, 1], [-3, -1], [0, -1], [0, 1]]]], 'Click South', 423);
INSERT INTO test_01037.polygons VALUES ([[[[-1, -1], [1, -1], [1, -3], [-1, -3]]]], 'Click West', 424);
2019-12-25 12:05:37 +00:00
CREATE DICTIONARY test_01037.dict
(
2019-12-25 12:39:49 +00:00
key Array(Array(Array(Array(Float64)))),
2019-12-25 12:58:43 +00:00
name String DEFAULT 'qqq',
2019-12-25 12:41:17 +00:00
value UInt64 DEFAULT 101
2019-12-25 12:05:37 +00:00
)
2019-12-25 12:39:49 +00:00
PRIMARY KEY key
2019-12-25 12:05:37 +00:00
SOURCE(CLICKHOUSE(HOST 'localhost' PORT 9000 USER 'default' TABLE 'polygons' PASSWORD '' DB 'test_01037'))
LIFETIME(MIN 1 MAX 10)
2019-12-25 12:39:49 +00:00
LAYOUT(POLYGON());
DROP TABLE IF EXISTS test_01037.points;
2019-12-25 16:31:57 +00:00
CREATE TABLE test_01037.points (x Float64, y Float64, def_i UInt64, def_s String) ENGINE = Memory;
INSERT INTO test_01037.points VALUES (0.1, 0.0, 112, 'aax');
INSERT INTO test_01037.points VALUES (-0.1, 0.0, 113, 'aay');
INSERT INTO test_01037.points VALUES (0.0, 1.1, 114, 'aaz');
INSERT INTO test_01037.points VALUES (0.0, -1.1, 115, 'aat');
INSERT INTO test_01037.points VALUES (3.0, 3.0, 22, 'bb');
INSERT INTO test_01037.points VALUES (5.0, 6.0, 33, 'cc');
INSERT INTO test_01037.points VALUES (-100.0, -42.0, 44, 'dd');
INSERT INTO test_01037.points VALUES (7.01, 7.01, 55, 'ee')
INSERT INTO test_01037.points VALUES (0.99, 2.99, 66, 'ee');
INSERT INTO test_01037.points VALUES (1.0, 0.0, 771, 'ffa');
INSERT INTO test_01037.points VALUES (-1.0, 0.0, 772, 'ffb');
INSERT INTO test_01037.points VALUES (0.0, 2.0, 773, 'ffc');
INSERT INTO test_01037.points VALUES (0.0, -2.0, 774, 'ffd');
2019-12-25 12:05:37 +00:00
2019-12-25 12:39:49 +00:00
select 'dictGet', 'test_01037.dict' as dict_name, tuple(x, y) as key,
2019-12-24 18:22:20 +00:00
dictGet(dict_name, 'name', key),
2019-12-26 12:27:43 +00:00
dictGet(dict_name, 'value', key) from test_01037.points order by x, y;
2019-12-25 16:31:57 +00:00
select 'dictGetOrDefault', 'test_01037.dict' as dict_name, tuple(x, y) as key,
dictGetOrDefault(dict_name, 'name', key, 'www'),
2019-12-26 12:27:43 +00:00
dictGetOrDefault(dict_name, 'value', key, toUInt64(1234)) from test_01037.points order by x, y;
2019-12-25 16:31:57 +00:00
select 'dictGetOrDefault', 'test_01037.dict' as dict_name, tuple(x, y) as key,
dictGetOrDefault(dict_name, 'name', key, def_s),
2019-12-26 12:27:43 +00:00
dictGetOrDefault(dict_name, 'value', key, def_i) from test_01037.points order by x, y;
2019-12-25 12:05:37 +00:00
INSERT INTO test_01037.points VALUES (5.0, 5.0, 0, '');
INSERT INTO test_01037.points VALUES (5.0, 1.0, 0, '');
INSERT INTO test_01037.points VALUES (1.0, 3.0, 0, '');
INSERT INTO test_01037.points VALUES (0.0, 0.0, 0, '');
INSERT INTO test_01037.points VALUES (0.0, 1.0, 0, '');
INSERT INTO test_01037.points VALUES (0.0, -1.0, 0, '');
INSERT INTO test_01037.points VALUES (1.0, 1.0, 0, '');
select 'dictHas', 'test_01037.dict' as dict_name, tuple(x, y) as key,
2019-12-26 12:27:43 +00:00
dictHas(dict_name, key) from test_01037.points order by x, y;
2019-12-25 12:39:49 +00:00
DROP DICTIONARY test_01037.dict;
DROP TABLE test_01037.polygons;
DROP TABLE test_01037.points;
2019-12-26 08:19:03 +00:00
DROP DATABASE test_01037;