[Bug] Table-model UDFs fail on TAG/ATTRIBUTE predicates, SHOW/COUNT DEVICES and UPDATE since 2.0.11
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 52/100
調査の方向性
Start with TableOperatorGenerator.IoTDBLocalFactory#createIoTDBLocal and UserDefineScalarFunctionTransformer, then trace the schema fragment setup in FragmentInstanceManager#execSchemaQueryFragmentInstance and the count path in DataNodeTableOperatorGenerator#visitTableDeviceQueryCount. Compare these with DriverTask.computeDeadlineTimeInMs and inspect the UPDATE path in SchemaRegionStateMachine#write, including SchemaRegionMemoryImpl#constructDevicePredicateUpdater. Reproduce the listed SQL cases on 2.0.11; done means UDFs behave as expected in predicates, device queries, and UPDATE.
索引モデルが issue の本文から書いたものです。
説明
Search before asking
- I searched in the issues and found nothing similar.
Version
The official apache/iotdb:2.0.11-standalone Docker image (2.0.11, build 7c0de06, linux/arm64), and master at d8800f1 built from source. The same steps work on apache/iotdb:2.0.10-standalone (build 3c26382).
Describe the bug and provide the minimal reproduce step
A user-defined table scalar function fails when it is used on a TAG or ATTRIBUTE column in WHERE, in SHOW DEVICES / COUNT DEVICES ... WHERE, or in UPDATE ... SET. The same function works in the SELECT list, and the built-in upper() works in all of these places.
The function only returns its argument:
package lazy;
import org.apache.iotdb.udf.api.customizer.analysis.ScalarFunctionAnalysis;
import org.apache.iotdb.udf.api.customizer.parameter.FunctionArguments;
import org.apache.iotdb.udf.api.relational.ScalarFunction;
import org.apache.iotdb.udf.api.relational.access.Record;
import org.apache.iotdb.udf.api.type.Type;
public class StrF implements ScalarFunction {
@Override
public ScalarFunctionAnalysis analyze(FunctionArguments arguments) {
return new ScalarFunctionAnalysis.Builder().outputDataType(Type.STRING).build();
}
@Override
public Object evaluate(Record input) {
return input.isNull(0) ? null : input.getBinary(0);
}
}
CREATE DATABASE db;
CREATE TABLE db.t (device_id STRING TAG, attr1 STRING ATTRIBUTE, v INT64 FIELD);
INSERT INTO db.t(time, device_id, attr1, v) VALUES (1,'d1','a',1),(2,'d1','a',2),(1,'d2','b',100);
CREATE FUNCTION str_f AS 'lazy.StrF' USING URI 'file:/tmp/lazyudf.jar';
SELECT time, device_id, str_f(device_id) FROM db.t ORDER BY device_id, time;
SELECT count(*) FROM db.t WHERE str_f(device_id) = 'd1';
SELECT count(*) FROM db.t WHERE str_f(attr1) = 'a';
SHOW DEVICES FROM db.t WHERE str_f(device_id) = 'd1';
COUNT DEVICES FROM db.t WHERE str_f(device_id) = 'd1';
UPDATE db.t SET attr1 = str_f(device_id) WHERE device_id = 'd2';
What did you expect to see?
What 2.0.10 returns: the first SELECT returns the three rows, both count(*) queries return 2, SHOW DEVICES returns d1 | a, COUNT DEVICES returns 1, and the UPDATE succeeds and sets attr1 of d2 to d2.
What did you see instead?
On 2.0.11 and master the first SELECT still works, but the rest fail:
SELECT count(*) ... WHERE str_f(device_id) = 'd1' 301: outerQueryDeadlineMs must be positive for UDF execution
SELECT count(*) ... WHERE str_f(attr1) = 'a' 301: outerQueryDeadlineMs must be positive for UDF execution
SHOW DEVICES ... WHERE str_f(device_id) = 'd1' 301: outerQueryDeadlineMs must be positive for UDF execution
COUNT DEVICES ... WHERE str_f(device_id) = 'd1' 301: IoTDBLocalFactory must not be null for UDF execution
UPDATE db.t SET attr1 = str_f(device_id) ... 305: null
For the UPDATE, the DataNode log shows IoTDBLocalFactory must not be null for UDF execution, thrown from SchemaRegionMemoryImpl#constructDevicePredicateUpdater under SchemaRegionStateMachine#write. On 2.0.11, the same statements with upper() in place of str_f all succeed.
Anything else?
The messages come from TableOperatorGenerator.IoTDBLocalFactory#createIoTDBLocal, added with IoTDBLocal in #18035. UserDefineScalarFunctionTransformer calls it in its constructor, so every user-defined scalar function needs a factory, a fragment instance id, a query id and a positive deadline, even when it never uses IoTDBLocal.
- For schema fragments,
FragmentInstanceManager#execSchemaQueryFragmentInstancecreates theFragmentInstanceContextwithout a deadline, so it stays at -1. The data path passesDriverTask.computeDeadlineTimeInMs(instance.getTimeOut()). COUNT DEVICESbuilds its transformer context inDataNodeTableOperatorGenerator#visitTableDeviceQueryCountwithout a factory.UPDATEbuilds its transformers insideSchemaRegionStateMachine#write, where there is no query.
The UPDATE case also came up in a review comment on #18889 (https://github.com/apache/iotdb/pull/18889#discussion_r4357924405), and I ran into the rest while testing #19107.
I can see two directions: give schema fragments the same deadline and factory as data fragments, and create IoTDBLocal only when a function actually uses it, with a clear error where there is no query, as in UPDATE. I'm happy to send a PR once it's clear which one is preferred.
Are you willing to submit a PR?
- I'm willing to submit a PR!
- 主要言語
- Java
- スター
- 6.4k
- フォーク
- 1.2k
- 平均マージ
- 1日 12時間
- マージ済み PR(30日)
- 284
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/iotdb のほかの issue
-
[Bug] Python NumpyTablet silently drops trailing zero bytes from BLOB values対応中かも @DaZuiZui が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
[Bug] sbin/replace-conf-from-env.sh word-splits the whole environment and corrupts iotdb-system.properties対応中かも @anishmehta24 が 69 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
apache/iotdb#18655 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
IoTDB Edge: stop-edge.sh does not stop its own process when IOTDB_HOME is set, and reports success対応中かも @PDGGK が 88 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
[Bug] findColumn throws NullPointerException instead of SQLException for an unknown column name対応中かも @PDGGK が 130 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
Android Bug Core Drape
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
organicmaps/organicmaps#14449 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
openhab/openhab-addons#22512 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
objectionary/lints#1871 ·
メンテナーはふだん 1 日以内に返信
-
help wanted maintenance
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
apache/maven-war-plugin#694 ·
メンテナーはふだん 1 日以内に返信
-
help wanted maintenance
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
apache/maven-resolver-ant-tasks#219 ·
メンテナーはふだん 1 日以内に返信