Support calendar-month/year (mo/y) intervals for Continuous Query EVERY and RANGE clauses
Mantenedores costumam responder em até 1 dia
Avaliação
Esta issue ainda não foi avaliada.
Descrição
Is your feature request related to a problem?
IoTDB's Continuous Query (CQ) does not support calendar-month (or calendar-year) alignment for the EVERY execution interval and the RANGE time offsets. This makes it impossible to schedule a CQ that fires exactly at month boundaries — e.g. "run at the end of every month and aggregate over the whole natural month" — which is a common downsampling requirement. Because months have 28/29/30/31 days, the window length must be handled dynamically, so a fixed-day interval is not an adequate substitute.
Current behavior
Documentation
The CQ documentation states that every_interval, start_time_offset, and end_time_offset support only the units ns, us, ms, s, m, h, d, w — mo (month) and y (year) are not listed:
<every_interval>specifies the query execution time interval. We currently support the units of ns, us, ms, s, m, h, d, w ...
Source: https://iotdb.apache.org/UserGuide/latest/User-Manual/Database-Programming.html
Implementation
However, the implementation does not reject mo/y in these clauses — it silently accepts them and converts them to a fixed duration (1 month → 30 days, 1 year → 365 days):
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/DataNodeDateTimeUtils.java— the single-argument overloadconvertDurationStrToLong(String)is called withcurrentTime = -1, so themo/monthbranch flattens to30 * 86_400_000ms andy/yearto365 * 86_400_000ms.- The CQ parser uses exactly this overload for
EVERY/RANGE:ASTVisitor.parseResampleClause(...)iniotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java. - The scheduler then treats the result as a plain
longand does pure integer arithmetic (executionTime += everyInterval,getFirstExecutionTime(...)) iniotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/cq/CQScheduleTask.java— there is no calendar logic at runtime.
As a result, EVERY 1mo does not mean "at the end of every calendar month"; it means "every fixed 30 days", which drifts relative to real month boundaries. This is arguably worse than a clean rejection, because the statement appears to be accepted but is silently mis-scheduled.
Note that GROUP BY(1mo) in the CQ body does work as a natural calendar month, because it goes through a different converter (constructTimeDuration, which keeps a separate monthDuration part and can be evaluated against the calendar). So within a single CQ the EVERY/RANGE cadence (fixed 30 days) and the GROUP BY window (natural month) can drift apart.
Desired behavior
Support mo/month and y/year as first-class units for the CQ EVERY interval and RANGE offsets, evaluated against the calendar (the way GROUP BY already handles months), so a CQ can be aligned to true month/year boundaries.
CREATE CONTINUOUS QUERY cq_monthly_spread
RESAMPLE EVERY 1mo RANGE 1mo
BEGIN
SELECT max_value(s), min_value(s)
INTO root.db.device(monthly_max, monthly_min)
FROM root.db.device
GROUP BY(1mo)
END
This should execute at each month boundary and aggregate over the just-finished natural month (correctly handling 28/29/30/31-day months).
Alternatives considered
- External scheduler (e.g. cron at month-end) running a one-shot query — works today, but moves scheduling logic outside IoTDB and loses CQ's built-in result-sink semantics.
- Daily CQ with
EVERY 1d RANGE 31d+GROUP BY(1mo)— partially works, but the monthly result is recomputed daily and only "finalizes" after month-end; andRANGE 31dis still a fixed window rather than a true calendar month.
Additional context
As a smaller, complementary fix (or interim step), the silent 30/365-day flattening of mo/y in EVERY/RANGE could be turned into an explicit error, so that the runtime behavior matches the documentation and users are not misled into thinking EVERY 1mo produces a calendar-month cadence.
/ccraised by a user who wants month-end downsampling (spread = max − min over a natural month).
- Linguagem predominante
- Java
- Estrelas
- 6.4k
- Forks
- 1.2k
- Merge médio
- 1d 18h
- PRs com merge (30d)
- 145
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de apache/iotdb
-
[Bug] sbin/replace-conf-from-env.sh word-splits the whole environment and corrupts iotdb-system.propertiesTalvez já em andamento @anishmehta24 assumiu há 20 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
apache/iotdb#18655 · 1 reação ·
Mantenedores costumam responder em até 1 dia
-
IoTDB Edge: stop-edge.sh does not stop its own process when IOTDB_HOME is set, and reports successTalvez já em andamento @PDGGK assumiu há 40 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
-
[Bug] findColumn throws NullPointerException instead of SQLException for an unknown column nameTalvez já em andamento @PDGGK assumiu há 82 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
-
[Bug] ResultSetMetaData.getCatalogName throws IndexOutOfBoundsException instead of SQLException for out-of-range columnsTalvez já em andamento @PDGGK assumiu há 83 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
Todas as issues de apache/iotdb
Issues semelhantes
-
`Processing lsp` never exits and leaves orphaned processesTalvez já em andamento @overcast302 assumiu hoje. Abertabug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
processing/processing4#1578 · 1 comentário ·
-
ASM is not up-to-dateAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 60/100
Mantenedores costumam responder em até 1 dia
-
[BUG] S3 CORS responses omit Access-Control-Allow-Credentials for matched originsTalvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
floci-io/floci#5369 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
securityHeaders replaces a route's own Content-Security-Policy (0.9.9; weakens embedders' pages)Abertabug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
sqlcipher/sqlcipher-android#97 · 1 comentário ·