2017-08-16 110 views
1

我上週一直在使用德魯伊,並希望爲某些postAggregations啓用JavaScript。如何啓用德魯伊的Javascript

我想我遵循了概述步驟並更新了../con f/druid/_common/中的common.runtime.properties文件以包含druid.javascript.enabled=true。然後,我停止了當前進程和重新跑了快速啓動程序,但它仍然表示,已禁用JavaScript:

{ 
    "error" : "Unknown exception", 
    "errorMessage" : "Instantiation of [simple type, class io.druid.query.aggregation.post.JavaScriptPostAggregator] value failed: JavaScript is disabled. (through reference chain: java.util.ArrayList[0])", 
    "errorClass" : "com.fasterxml.jackson.databind.JsonMappingException", 
    "host" : null 
} 

我目前運行它在「快速入門」配置 - 單一的本地機器。任何指針?謝謝!

回答

0

JavaScript查詢德魯伊聚合。將該文件保存爲.body並點擊捲曲請求。 這是一個查詢平均值的示例。

捲曲-X POST 「http://localhost:8082/druid/v2/?pretty」 \ -H '內容類型:應用程序/ JSON' -d @ query.body

{ 
    "queryType":"groupBy", 
    "dataSource":"whirldata", 
    "granularity":"all", 
    "dimensions":[], 
    "aggregations":[{"name":"rows","type":"count","fieldName":"rows"}, 
{"name":"TargetDOS","type":"doubleSum","fieldName":"Target DOS"}],"postAggregations":[ 
{ 
    "type": "javascript", 
    "name": "Target DOS Average", 
    "fieldNames": ["TargetDOS", "rows"], 
    "function": "function(TargetDOS, rows) { return Math.abs(TargetDOS)/rows; }" 
}], "intervals":[ "2006-01-01T00:00:00.000Z/2020-01-01T00:00:00.000Z" ]} 
+0

首先你需要在所有的common.runtime.properties文件中啓用java腳本來包含druid.javascript.enabled = true –

+0

希望它會幫助.. –

0

你缺少的部分是可能的快速啓動從conf-quickstart讀取配置,而不是conf。所以請嘗試編輯conf-quickstart/druid/_common/common.runtime.properties