首页 > 解决方案 > 使用 Postman 查询 Apache Druid

问题描述

我部署了 Apache Druid 0.21 并提取了 Wikipedia 示例数据以使用 SQL 对其进行查询。当我尝试像这样使用 curl 查询它时,它工作正常并且我获得了行数:

curl -X 'POST' -H 'Content-Type:application/json' -d "{\"query\":\"select count(*) from wikipedia\"}" http://localhost:8888/druid/v2/sql

当我在 Postman (8.5.1) 上尝试相同的查询时,即使用以下主体作为“原始”JSON 数据执行 POST 请求:

{
    "query": "select count(*) from wikipedia"
}

我在 Druid 代理日志中出现 500 错误并显示以下错误消息:

WARN [qtp52477555-156] org.eclipse.jetty.server.HttpChannel - /druid/v2/sql
java.lang.NullPointerException: null
    at org.apache.druid.sql.http.SqlResource.doPost(SqlResource.java:92) ~[druid-sql-0.21.0.jar:0.21.0]
    at sun.reflect.GeneratedMethodAccessor24.invoke(Unknown Source) ~[?:?]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_221]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_221]
    at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60) ~[jersey-server-1.19.3.jar:1.19.3]
    at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205) ~[jersey-server-1.19.3.jar:1.19.3]
    at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75) ~[jersey-server-1.19.3.jar:1.19.3]

有趣的是,当我从 Postman 获取代码片段并在终端窗口中尝试时,它运行良好:

curl --location --request POST 'localhost:8888/druid/v2/sql' \
--header 'Content-Type: application/json' \
--data-raw '{
    "query": "select count(*) from wikipedia"
}'

我也尝试过使用 SOAP UI,它工作正常。

知道出了什么问题吗?是邮递员还是德鲁伊?

谢谢 - 克里斯蒂安

标签: postmandruid

解决方案


推荐阅读