版本德鲁伊.10.1 我们正在使用druid-kafka索引器服务提取,将数据从kafka主题加载到druid中,在此期间,我们发现druid将具有0或0.0的度量值存储为null并通过超集或Druid api进行检索得到的响应为空。如果我们在这里缺少任何东西,则需要建议。
超集错误:
with cte as (
select max(case when a is not null then date end) as date_a
, max(case when b is not null then date end) as date_b
, max(case when c is not null then date end) as date_c
, max(case when d is not null then date end) as date_d
from t
)
select max(date) as date
, min(case when date = date_a then a end) as a
, min(case when date = date_b then b end) as b
, min(case when date = date_c then c end) as c
, min(case when date = date_d then d end) as d
from t
cross join cte
以下提取规范文件:
{"status": "failed", "error_type": "warning", "error": "unsupported operand type(s) for +: 'int' and 'NoneType'"}
使用了来自德鲁伊的其他api: http://host:port/druid/v2?pretty
正文:
{
"type": "kafka",
"dataSchema": {
"dataSource": "data-source",
"parser": {
"type": "string",
"parseSpec": {
"format": "json",
"timestampSpec": {
"column": "datetime",
"format": "YYYYMMdd_HHmmss"
},
"columns": [
"created_date",
"s_type",
"datetime",
"ds_ser",
"ven",
"cou_name",
"c_name",
"d_name",
"dv_name",
"p_name",
"redTime",
"wrTime",
"tRate",
"MTRate"
],
"dimensionsSpec": {
"dimensions": [
"created_date",
"s_type",
"datetime",
"ds_ser",
"ven",
"cou_name",
"c_name",
"d_name",
"dv_name",
"p_name",
]
}
}
},
"metricsSpec": [{
"name": "count",
"type": "count"
},
{
"type": "doubleMax",
"name": "redTime",
"fieldName": "redTime"
},
{
"type": "doubleMax",
"name": "wrTime",
"fieldName": "wrTime"
},
{
"type": "longMax",
"name": "tRate",
"fieldName": "tRate"
},
{
"type": "longMax",
"name": "MTRate",
"fieldName": "MTRate"
}
],
"granularitySpec": {
"type": "uniform",
"segmentGranularity": "HOUR",
"queryGranularity": "NONE"
}
},
"tuningConfig": {
"type": "kafka",
"maxRowsPerSegment": 5000000
},
"ioConfig": {
"topic": "ptopic",
"useEarliestOffset": "true",
"consumerProperties": {
"bootstrap.servers": "host:port"
},
"taskCount": 1,
"replicas": 1,
"taskDuration": "PT5M"
}
}
德鲁伊的回应:
{
"queryType": "groupBy",
"dataSource": "data-source",
"granularity": "all",
"dimensions": ["ds_ser"],
"aggregations": [
{"type": "doubleMax", "name": "redTime", "redTime": "writeresponsetime"},
{"type": "doubleMax", "name": "wrTime", "wrTime": "totalResponseTime"},
{"type": "longMax", "name": "tRate", "fieldName": "tRate"},
{"type": "longMax", "name": "MTRate", "MTRate": "MaxTransferRate"}
],
"intervals": ["2019-01-02T00:00/2019-01-02T23:59"]
}
卡夫卡中的数据:
[
{
"version": "v1",
"timestamp": "2019-01-02T00:00:00.000Z",
"event": {
"redTime": null,
"ds_ser": "240163",
"wrTime": null,
"tRate": null,
"MTRate": null
}
},
{
"version": "v1",
"timestamp": "2019-01-02T00:00:00.000Z",
"event": {
"redTime": null,
"ds_ser": "443548",
"wrTime": null,
"tRate": 0,
"MTRate": null
}
}
]
答案 0 :(得分:0)
好吧,我已经找到了自己的问题的答案。
在准备德鲁伊kafka inderex json时我做错了。我不知道该字段是否区分大小写。这里发布的json片段是一个组成部分,因此字段名称是匹配的,但是在我的实际生产代码和json文件中,这些字段不匹配,因此druid将这些字段假定为新字段,并在摄取它们时将其值分配为null。下面的示例:
Kafka Json:
{"created_date":"2019-02-03T18:35:59.514Z","s_type":"BLOCK","datetime":"20181121_070000","ds_ser":"443551","ven":"abc","cou_name":"USA","c_name":"Piscataway","d_name":"Piscataway","dv_name":"USPSCG","p_name":"443551-CK","redTime":0.0,"wrTime":0.0,"tRate":0,"MTRate":0}
德鲁伊索引器json列如下:
"columns": [ "created_date", "s_type", "datetime", "ds_ser", "ven", "cou_name", "c_name", "d_name", "dv_name", "p_name", "redTime", "wrtime", "trate", "MTRate" ],
如果我们在上面观察到,wrTime --> wrtime
和tRate --> trate
中存在不匹配。所以对我来说,这是根本原因,解决名称后,德鲁伊开始吸收适当的值。