Skip to content

Commit

Permalink
Merge pull request ClickHouse#51756 from ClickHouse/fix-ip-dict
Browse files Browse the repository at this point in the history
Support IPv4 and IPv6 as dictionary attributes
  • Loading branch information
yakov-olkhovskiy authored Jul 27, 2023
2 parents f7d8930 + 9a1c59a commit 9448d42
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Dictionaries/DictionaryStructure.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ enum class AttributeUnderlyingType : TypeIndexUnderlying
map_item(Decimal32), map_item(Decimal64), map_item(Decimal128), map_item(Decimal256),
map_item(DateTime64),

map_item(UUID), map_item(String), map_item(Array)
map_item(UUID), map_item(String), map_item(Array),

map_item(IPv4), map_item(IPv6)
};

#undef map_item
Expand Down
2 changes: 2 additions & 0 deletions tests/queries/0_stateless/02811_ip_dict_attribute.reference
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
('::2.2.2.2','2.2.2.2')
('::1.1.1.1','1.1.1.1')
13 changes: 13 additions & 0 deletions tests/queries/0_stateless/02811_ip_dict_attribute.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CREATE TABLE src ( id UInt64, ip4 IPv4, ip6 IPv6 ) Engine=Memory AS
SELECT * FROM VALUES( (1, '1.1.1.1', '::1.1.1.1'), (2, '2.2.2.2', '::2.2.2.2') );

CREATE DICTIONARY dict ( id UInt64, ip4 IPv4, ip6 IPv6 )
PRIMARY KEY id
LAYOUT(HASHED())
SOURCE (CLICKHOUSE ( table src))
lifetime ( 10);

SELECT dictGet('dict', ('ip6', 'ip4'), arrayJoin([2,1]));

DROP DICTIONARY dict;
DROP TABLE src;

0 comments on commit 9448d42

Please sign in to comment.