[#17939] Implement FFT table function for table model#18006
Conversation
dc535ca to
2faa54b
Compare
|
Updated this PR for the latest review comments:
Tests run locally with JDK 21:
|
|
Follow-up update:
Pushed as a normal follow-up commit (no force push). Tests run locally with JDK 21:
|
EnglishThe PR branch has been updated with the following main changes: The Maven dependency of iotdb-core/node-commons on JTransforms has been removed to avoid adding third-party dependencies to the core module. A new in-package implementation of DoubleFft1d has been added, and FFTTableFunction now directly uses this built-in implementation. DoubleFft1d retains the double complex forward FFT capability required by DoubleFFT_1D#complexForward(double[]): lengths raised to powers of 2 follow radix-2, and lengths not raised to powers of 2 follow Bluestein, thus not narrowing the behavior of N. The JTransforms/BSD-2-Clause source description has been added to the LICENSE. Unit test coverage for non-powers of 2 when N = 3 has been added. Verification: ./mvnw spotless:apply -pl iotdb-core/node-commons ./mvnw test -pl iotdb-core/node-commons -am -Dtest=FFTTableFunctionTest -Dsurefire.failIfNoSpecifiedTests=false -DfailIfNoTests=false -DskipITs Additionally, I used a local JTransforms 3.1 jar to verify the length of multiple sets of outputs, and the results were consistent. Chinese已更新 PR 分支,主要改动如下:
验证:
|
|
Added commit 039c240 to replace the vendored FFT implementation with JTransforms, route FLOAT inputs through FloatFFT_1D and other numeric inputs through DoubleFFT_1D, and add focused coverage plus binary license entries. |
|
已更新 PR 分支,主要改动如下:
验证:
|
|
Correction on the time column contract for FFT V1: we should support Reason: the table model supports custom TIME column names, for example The intended contract should be:
So the previous wording in the PR description that says |
|
Follow-up update for custom FFT time columns:
|
|
自定义 FFT 时间列的后续更新: 为 FFT 添加了可选的 TIMECOL 支持,默认值为 time,因此具有自定义 TIME 列名(例如 event_time TIMESTAMP TIME)的表可以直接使用 FFT。 验证现在要求 DATA ... ORDER BY 引用 TIMECOL 选择的列,并且 FFT 会将该选定的时间列从值列中排除。 将 TIMECOL 移至 FFT 参数规范(DATA、SAMPLE_INTERVAL、N、NORM、TIMECOL)的末尾,以保留现有的位置参数语义。按预期支持命名用法,例如 TIMECOL => 'event_time'。 添加了自定义时间列用法的单元/规划器/IT 覆盖率,以及规划器覆盖率,其中位置参数(例如 FFT(TABLE(table1) ORDER BY time, 1s, 4, 'ortho'))仍然将 1s 绑定到 SAMPLE_INTERVAL。 |
|
Follow-up update after the sampling-interval clarification:
Verification: ./mvnw spotless:apply -pl iotdb-core/node-commons,integration-test -P with-integration-tests
./mvnw test -pl iotdb-core/node-commons -am -Dtest=FFTTableFunctionTest -DfailIfNoTests=false -Dsurefire.failIfNoSpecifiedTests=false -DskipITs
./mvnw verify -DskipUTs -Dit.test=IoTDBFFTTableFunctionIT -DfailIfNoTests=false -Dfailsafe.failIfNoSpecifiedTests=false -pl integration-test -am -PTableSimpleIT -P with-integration-tests |
Description
FFT table-valued function
This PR implements the v1 built-in
FFT/ffttable-valued function for the table model.The function accepts a required
DATAtable argument with set semantics andORDER BY <TIMECOL>(TIMECOLdefaults totime), plus optionalSAMPLE_INTERVAL,N,NORM, andTIMECOLarguments. It emits the full complex spectrum for each eligible numeric transform column and returnsfrequency_index,frequency, and<column>_real/<column>_imagcolumns. When partition columns exist, they are kept at the front of the output schema.The FFT implementation uses JTransforms
DoubleFFT_1D/FloatFFT_1D.Nsupports default partition length, truncation, and zero padding.NORMsupportsbackward,forward, andortho.SAMPLE_INTERVALcan be supplied as a duration literal; otherwise the interval is inferred from the partition time range as(last_time - first_time) / (row_count - 1). Input gaps are not validated against either the inferred interval or an explicitly suppliedSAMPLE_INTERVAL.Analyzer, planner, and validation
The function is registered as a built-in table function and gets analyzer/planner handling similar to
M4where needed so the output column order matches the table-function contract.Validation covers:
DATAmust haveORDER BY <TIMECOL>in ascending order (TIMECOLdefaults totime).SAMPLE_INTERVAL, if provided, must be positive.N, if provided, must be positive.NORMmust be one ofbackward,forward, orortho.TIMECOL, defaulttime) and partition columns, at least one numeric transform column is required.SAMPLE_INTERVALis omitted, at least two rows are required to infer it.Tests
This PR adds focused unit coverage for the FFT processor, analyzer/planner coverage for built-in table-function recognition and schema handling, and a table-model IT covering normal execution and failure cases.
Tested locally with:
./mvnw spotless:apply -pl iotdb-core/node-commons,integration-test -P with-integration-tests ./mvnw test -pl iotdb-core/node-commons -am -Dtest=FFTTableFunctionTest -DfailIfNoTests=false -Dsurefire.failIfNoSpecifiedTests=false -DskipITs ./mvnw verify -DskipUTs -Dit.test=IoTDBFFTTableFunctionIT -DfailIfNoTests=false -Dfailsafe.failIfNoSpecifiedTests=false -pl integration-test -am -PTableSimpleIT -P with-integration-testsThis PR has:
Key changed/added classes (or packages if there are too many classes) in this PR
org.apache.iotdb.commons.udf.builtin.relational.tvf.FFTTableFunctionorg.apache.iotdb.commons.queryengine.plan.relational.function.TableBuiltinTableFunctionorg.apache.iotdb.db.queryengine.plan.relational.analyzer.StatementAnalyzerorg.apache.iotdb.db.queryengine.plan.relational.planner.RelationPlannerorg.apache.iotdb.commons.udf.builtin.relational.tvf.FFTTableFunctionTestorg.apache.iotdb.db.queryengine.plan.relational.analyzer.TableFunctionTestorg.apache.iotdb.relational.it.db.it.IoTDBFFTTableFunctionITRelated to #17939.