-
Notifications
You must be signed in to change notification settings - Fork 89
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
DruidJerseyClient error #89
Comments
Could you try sending query Object instead of parsing as a string and sending it? `DruidTimeSeriesQuery query = DruidTimeSeriesQuery.builder()
|
yes,I trying to parsing as a string and sending it like this
and it's work. but why this way did not work ?
|
@Lswks @GG-Zapr I've got the same problem when avoking client.query() method, and it threw a exception(500 Internal Server Error), could you please share your solution to this problem if you fixed it? My code is as follows: public class DruidSimpleQuery {
private DruidConfiguration druidConfiguration;
private DruidClient druidClient;
@Before
public void init() {
druidConfiguration = DruidConfiguration
.builder()
.protocol(DruidQueryProtocol.HTTP)
.host(DruidConfig.HOST)
.port(DruidConfig.PORT)
.endpoint("druid/v2/")
.concurrentConnectionsRequired(8)
.build();
druidClient = new DruidJerseyClient(druidConfiguration);
}
@Test
public void topNQuery() throws Exception {
DateTime startTime = new DateTime(2015, 9, 12, 0, 0, 0, DateTimeZone.UTC);
DateTime endTime = new DateTime(2015, 9, 13, 0, 0, 0, DateTimeZone.UTC);
Interval interval = new Interval(startTime, endTime);
Granularity granularity = new SimpleGranularity(PredefinedGranularity.ALL);
DruidAggregator aggregator1 = new CountAggregator("count");
DruidDimension dimension = new SimpleDimension("page");
TopNMetric metric = new SimpleMetric("count");
DruidTopNQuery query = DruidTopNQuery.builder()
.dataSource("wikipedia")
.dimension(dimension)
.threshold(10)
.topNMetric(metric)
.granularity(granularity)
.aggregators(Collections.singletonList(aggregator1))
.intervals(Collections.singletonList(interval))
.build();
ObjectMapper mapper = new ObjectMapper();
String requiredJson = mapper.writeValueAsString(query);
System.out.println("Json query: " + requiredJson);
try {
this.druidClient.connect();
String result = this.druidClient.query(query);
System.out.println("Query result: " + result);
} catch (ConnectionException e) {
e.printStackTrace();
} catch (QueryException e) {
e.printStackTrace();
} finally {
try {
this.druidClient.close();
} catch (ConnectionException e) {
e.printStackTrace();
}
}
}
} |
@ShawyerPeng Your code worked fine for me, not able to reproduce the issue. I used the latest release. @Lswks I also tried Timeseries Query, that also worked. Attaching screenshots for reference.
public class DruidSimpleQuery {
private DruidConfiguration druidConfiguration;
private DruidClient druidClient;
@BeforeClass
public void init() {
druidConfiguration = DruidConfiguration
.builder()
.protocol(DruidQueryProtocol.HTTP)
.host("localhost")
.port(8082)
.endpoint("druid/v2/")
.concurrentConnectionsRequired(8)
.build();
druidClient = new DruidJerseyClient(druidConfiguration);
}
@Test
public void topNQuery() throws Exception {
DateTime startTime = new DateTime(2015, 9, 12, 0, 0, 0, DateTimeZone.UTC);
DateTime endTime = new DateTime(2015, 9, 13, 0, 0, 0, DateTimeZone.UTC);
Interval interval = new Interval(startTime, endTime);
Granularity granularity = new SimpleGranularity(PredefinedGranularity.ALL);
DruidAggregator aggregator1 = new CountAggregator("count");
DruidDimension dimension = new SimpleDimension("page");
TopNMetric metric = new SimpleMetric("count");
DruidTopNQuery query = DruidTopNQuery.builder()
.dataSource("wikipedia")
.dimension(dimension)
.threshold(10)
.topNMetric(metric)
.granularity(granularity)
.aggregators(Collections.singletonList(aggregator1))
.intervals(Collections.singletonList(interval))
.build();
ObjectMapper mapper = new ObjectMapper();
String requiredJson = mapper.writeValueAsString(query);
System.out.println("Json query: " + requiredJson);
try {
this.druidClient.connect();
String result = this.druidClient.query(query);
System.out.println("Query result: " + result);
} catch (ConnectionException e) {
e.printStackTrace();
} catch (QueryException e) {
e.printStackTrace();
} finally {
try {
this.druidClient.close();
} catch (ConnectionException e) {
e.printStackTrace();
}
}
}
@Test
public void timeserisQuery() throws Exception {
DateTime startTime = new DateTime(2015, 9, 12, 0, 0, 0, DateTimeZone.UTC);
DateTime endTime = new DateTime(2015, 9, 13, 0, 0, 0, DateTimeZone.UTC);
Interval interval = new Interval(startTime, endTime);
Granularity granularity = new SimpleGranularity(PredefinedGranularity.ALL);
DruidAggregator aggregator1 = new CountAggregator("count");
DruidDimension dimension = new SimpleDimension("page");
TopNMetric metric = new SimpleMetric("count");
DruidTimeSeriesQuery query = DruidTimeSeriesQuery
.builder()
.dataSource("wikipedia")
.granularity(granularity)
.aggregators(Collections.singletonList(aggregator1))
.intervals(Collections.singletonList(interval))
.build();
ObjectMapper mapper = new ObjectMapper();
String requiredJson = mapper.writeValueAsString(query);
System.out.println("Json query: " + requiredJson);
try {
this.druidClient.connect();
String result = this.druidClient.query(query);
System.out.println("Query result: " + result);
} catch (ConnectionException e) {
e.printStackTrace();
} catch (QueryException e) {
e.printStackTrace();
} finally {
try {
this.druidClient.close();
} catch (ConnectionException e) {
e.printStackTrace();
}
}
}
} |
@abhi-zapr Thanks for replying, but I got the same error again. (By the way, I use the latest version 2.13) Request Body:
Error Message:
It seems that queryType property is case sensitive, "TIMESERIES" should be replaced by "timeseries". |
In latest release you can see here we are setting QueryType as Can you share code thorough which you generated Request Body in above comment ? Because as per my code in this comment, it generates correctly which you can verify in screenshots. |
I met the problem too and found it was because that
Use string in place of enum may be better to avoid the Json serialization problem of Enum. |
Nice catch. Pinning this issue for future references. |
Hi:
I use druidry like this:
and I get the follow error:
{"error":"Unknown exception","errorMessage":"Could not resolve type id 'TIMESERIES' into a subtype of [simple type, class org.apache.druid.query.Query]: known type ids = [Query, dataSourceMetadata, groupBy, scan, search, segmentMetadata, select, timeBoundary, timeseries, topN]\n at [Source: HttpInputOverHTTP@167674ce[c=1242,q=0,[0]=null,s=STREAM]; line: 1, column: 1217]","errorClass":"com.fasterxml.jackson.databind.JsonMappingException","host":null}
The text was updated successfully, but these errors were encountered: