Skip to content

Commit

Permalink
iotdb fix
Browse files Browse the repository at this point in the history
  • Loading branch information
liyuheng55555 committed Jan 3, 2024
1 parent 7af3e2d commit 6967a9b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -659,16 +659,8 @@ private String getValueRangeQuerySql(ValueRangeQuery valueRangeQuery) {

private String getValueFilterClause(List<DeviceSchema> deviceSchemas, int valueThreshold) {
StringBuilder builder = new StringBuilder();
for (DeviceSchema deviceSchema : deviceSchemas) {
for (Sensor sensor : deviceSchema.getSensors()) {
builder
.append(" AND ")
.append(getDevicePath(deviceSchema))
.append(".")
.append(sensor.getName())
.append(" > ")
.append(valueThreshold);
}
for (Sensor sensor : deviceSchemas.get(0).getSensors()) {
builder.append(" AND ").append(sensor.getName()).append(" > ").append(valueThreshold);
}
return builder.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,12 +508,15 @@ private static String addWhereClause(
return sql;
}
StringBuilder sqlBuilder = new StringBuilder(sql);

sqlBuilder.append(WHERE);

if (timeRangeQuery != null) {
String startTime = "" + timeRangeQuery.getStartTimestamp();
String endTime = "" + timeRangeQuery.getEndTimestamp();
sqlBuilder.append(" time >= ").append(startTime).append(" AND time <= ").append(endTime);
}

if (valueRangeFilter != null) {
if (!sqlBuilder.toString().endsWith(WHERE)) {
sqlBuilder.append(" AND ");
Expand All @@ -524,6 +527,7 @@ private static String addWhereClause(
}
sqlBuilder.delete(sqlBuilder.length() - 4, sqlBuilder.length());
}

if (!alignByDeviceTableNameFilter.isEmpty()) {
if (!sqlBuilder.toString().endsWith(WHERE)) {
sqlBuilder.append(" AND ");
Expand All @@ -535,6 +539,7 @@ private static String addWhereClause(
sqlBuilder.deleteCharAt(sqlBuilder.length() - 1);
sqlBuilder.append(')');
}

return sqlBuilder.toString();
}

Expand Down

0 comments on commit 6967a9b

Please sign in to comment.