influxdata / influxdata/influxdb-java
Query with different time format does not work if database is not specified.
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.2k
- Forks
- 469
- PR merge metrics
- No merged PRs in 30d
Description
If you do not specify database in query (even thou you have specified database on the client level) method InfluxDBl#query(Query, TimeUnit) will not return any result because it will not send database information.
Steps to reproduce:
InfluxDB influxDB = InfluxDBFactory.connect(host + ":" + port);
influxDB.setDatabase(database);
// queryResult will be empty.
QueryResult queryResult = influxDB.query(new Query("..."), TimeUnit.NANOSECONDS)
Quick fix:
InfluxDB influxDB = InfluxDBFactory.connect(host + ":" + port);
influxDB.setDatabase(database);
// queryResult will be empty.
QueryResult queryResult = influxDB.query(new Query("...", "database"), TimeUnit.NANOSECONDS)
Permanent fix:
Change into "InfluxDBImpl#query(Query, TimeUnit)" into:
public QueryResult query(final Query query, final TimeUnit timeUnit) {
String db = query.getDatabase();
if (db == null) {
db = this.database;
}
Call<QueryResult> call = null;
if (query instanceof BoundParameterQuery) {
BoundParameterQuery boundParameterQuery = (BoundParameterQuery) query;
call = this.influxDBService.query(db,
TimeUtil.toTimePrecision(timeUnit), query.getCommandWithUrlEncoded(),
boundParameterQuery.getParameterJsonWithUrlEncoded());
} else {
call = this.influxDBService.query(db,
TimeUtil.toTimePrecision(timeUnit), query.getCommandWithUrlEncoded());
}
return executeQuery(call);
}
Here database information is taken from client level if not given in query object.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at InfluxDBImpl#query(Query, TimeUnit) and inspect how Query.getDatabase() and the client-level database are passed to influxDBService.query. Verify both regular Query and BoundParameterQuery behavior. Done means a query without its own database uses the database configured on the client and returns results with the requested time precision.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- database
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100