单词查询用字典查询
我从此处导入Ontime Airlines的数据库 https:https:// clickhouse。 com/doc/en/get-start/example-datasets/ontime/
然后,我创建了一个词典映射2个数字飞机代码到这样的公司名称:
id,code,company
1,UA,United Airlines
2,HA,Hawaiian Airlines
3,OO,SkyWest
4,B6,Jetblue Airway
5,QX,Horizon Air
6,YX,Republic Airway
7,G4,Allegiant Air
...
..
我使用此查询来生成它,并且似乎正在工作:
CREATE DICTIONARY airlinecompany
(
id UInt64,
code String,
company String
)
PRIMARY KEY id
SOURCE(FILE(path '/var/lib/clickhouse/user_files/airlinenames.csv' format 'CSVWithNames'))
LAYOUT(FLAT())
LIFETIME(3600)
在主数据库中(ONTAIRE)看起来像这样:
SELECT Reporting_Airline AS R_air
FROM ontime
GROUP BY R_air
LIMIT 4
┌─R_air─┐
│ UA │
│ HA │
│ OO │
│ B6 │
└───────┘
我想做的是使用R_AIR 2代码值的表,然后根据airlinecompany
doct of tode ot to创建映射IE,
R_Air Company
UA | United Airlines
HA | Hawaiian Airlines
00 | SkyWest
...
..
但我不能似乎正确地形成了此查询:
SELECT
Reporting_Airline AS R_Air,
dictGetString('airlinecompany', 'company', R_Air) AS company
FROM ontime
GROUP BY R_Air
Received exception from server (version 22.3.3):
Code: 6. DB::Exception: Received from localhost:9000. DB::Exception: Cannot parse string 'UA' as UInt64: syntax error at begin of string. Note: there are toUInt64OrZero and toUInt64OrNull functions, which returns zero/NULL instead of throwing exception.: while executing 'FUNCTION dictGetString('airlinecompany' :: 1, 'company' :: 2, Reporting_Airline :: 0) -> dictGetString('airlinecompany', 'company', Reporting_Airline) String : 4'. (CANNOT_PARSE_TEXT)
我缺少什么?我不知道为什么它认为ua是uint64
I imported the database of ontime airlines from here https://clickhouse.com/docs/en/getting-started/example-datasets/ontime/
Then I created a dictionary mapping the 2 digit airplane codes to company names like this:
id,code,company
1,UA,United Airlines
2,HA,Hawaiian Airlines
3,OO,SkyWest
4,B6,Jetblue Airway
5,QX,Horizon Air
6,YX,Republic Airway
7,G4,Allegiant Air
...
..
I used this query to generate it and it seems to be working:
CREATE DICTIONARY airlinecompany
(
id UInt64,
code String,
company String
)
PRIMARY KEY id
SOURCE(FILE(path '/var/lib/clickhouse/user_files/airlinenames.csv' format 'CSVWithNames'))
LAYOUT(FLAT())
LIFETIME(3600)
In the main database (ontime) Looks like this:
SELECT Reporting_Airline AS R_air
FROM ontime
GROUP BY R_air
LIMIT 4
┌─R_air─┐
│ UA │
│ HA │
│ OO │
│ B6 │
└───────┘
What I want to do is have a table that uses R_air's 2 code value and then checks it against the airlinecompany
dict to create a mapping ie
R_Air Company
UA | United Airlines
HA | Hawaiian Airlines
00 | SkyWest
...
..
But I cant seem to form this query correctly:
SELECT
Reporting_Airline AS R_Air,
dictGetString('airlinecompany', 'company', R_Air) AS company
FROM ontime
GROUP BY R_Air
Received exception from server (version 22.3.3):
Code: 6. DB::Exception: Received from localhost:9000. DB::Exception: Cannot parse string 'UA' as UInt64: syntax error at begin of string. Note: there are toUInt64OrZero and toUInt64OrNull functions, which returns zero/NULL instead of throwing exception.: while executing 'FUNCTION dictGetString('airlinecompany' :: 1, 'company' :: 2, Reporting_Airline :: 0) -> dictGetString('airlinecompany', 'company', Reporting_Airline) String : 4'. (CANNOT_PARSE_TEXT)
What am I missing? I dont know why it thinks UA is a UInt64
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
布局= complex_key_hashed
LAYOUT = COMPLEX_KEY_HASHED