Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/issue 381 update the ip trie dictionary key type #382

Merged

Conversation

lizhou1111
Copy link
Contributor

@lizhou1111 lizhou1111 commented Dec 5, 2023

this close #381
The clickhouse has 7 extended dictionary types:

  • flat
  • hased
  • range_hased
  • cache
  • complex_key_hased
  • complex_key_cache
  • ip_trie

The key type of previous ip_trie type dictionary is fixed string, So the third argument passed to dict_get('dict_name', attr_names, id_expr) should be fixed_string.After this update the argument type has been changed to ipv4(only ipv4 can work,clickhouse does the same).
For example:

drop stream if exists geoip_t;
CREATE stream if not exists geoip_t (
  cidr string,
  latitude float64,
  longitude float64,
  country_code string,
  state string,
  city string
) ENGINE = MergeTree ORDER BY cidr;
insert into geoip_t values ('188.166.84.125',52.3759,4.8975,'NL','North Holland','Amsterdam')

select * from geoip_t;

drop dictionary geoip;
-- ingest data from table, you can ingest data from csv(etc. source (FILE(path './test.csv' format 'CSVWithNames'))).
CREATE DICTIONARY geoip (
  cidr string,
  latitude float64,
  longitude float64,
  country_code string,
  state string,
  city string
) PRIMARY KEY cidr
SOURCE (ClickHouse (table 'geoip_t'))
LIFETIME (MIN 300 MAX 360)
LAYOUT (IP_TRIE());


select dict_get('geoip', 'latitude', to_ipv4('188.166.84.125')) as result;
┌──result─┐
│ 52.3759 │
└─────────┘

@lizhou1111 lizhou1111 self-assigned this Dec 6, 2023
@lizhou1111 lizhou1111 force-pushed the bugfix/issue-381-update-the-ip_trie-dictionary-key-type branch from 3ca12ea to b0de624 Compare December 6, 2023 01:43
@lizhou1111 lizhou1111 closed this Dec 6, 2023
@lizhou1111 lizhou1111 reopened this Dec 6, 2023
@lizhou1111 lizhou1111 force-pushed the bugfix/issue-381-update-the-ip_trie-dictionary-key-type branch from b0de624 to 5b51ee1 Compare December 6, 2023 01:44
@lizhou1111 lizhou1111 marked this pull request as ready for review December 6, 2023 01:44
@lizhou1111 lizhou1111 force-pushed the bugfix/issue-381-update-the-ip_trie-dictionary-key-type branch 2 times, most recently from 22da82c to e71a50d Compare December 6, 2023 03:46
@lizhou1111 lizhou1111 force-pushed the bugfix/issue-381-update-the-ip_trie-dictionary-key-type branch 3 times, most recently from fe04ada to eb46359 Compare December 7, 2023 05:03
@lizhou1111 lizhou1111 force-pushed the bugfix/issue-381-update-the-ip_trie-dictionary-key-type branch from eb46359 to b1e540d Compare December 7, 2023 05:54
@lizhou1111 lizhou1111 merged commit 8066de7 into develop Dec 7, 2023
21 checks passed
@lizhou1111 lizhou1111 deleted the bugfix/issue-381-update-the-ip_trie-dictionary-key-type branch December 7, 2023 08:27
@jovezhong jovezhong mentioned this pull request Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update the ip_trie dictionary key type .
2 participants