4paradigm / 4paradigm/OpenMLDB

batch: bug in handle key if is null

Open
#1,903 2 comments 0 reactions 1 assignee Claimed by @tobegit3hub View on GitHub
batch-engine bug call-for-contributions
Dominant language
C++
Stars
1.7k
Forks
331
Avg merge
12d 12h
Merged PRs (30d)
1

Description

https://github.com/4paradigm/OpenMLDB/blob/908e9edbe05a86dccdbf8d1579bad88454480d59/java/openmldb-batch/src/main/scala/com/_4paradigm/openmldb/batch/nodes/WindowAggPlan.scala#L424-L425

We get key by `extractKey`, and then check it by `isValidOrder`.
After #1408 fixed, `isValidOrder` arg is java Long, it may be null or a long.

But `extractKey` returns scala Long, which can't be null, ref
https://github.com/4paradigm/OpenMLDB/blob/8a20b4849c52dfee7dacd02f04a6adede05673c2/java/openmldb-batch/src/main/scala/com/_4paradigm/openmldb/batch/window/WindowComputer.scala#L225-L227
The function `getLongFromIndex` called by `extractKey`, returns java Long.
https://github.com/4paradigm/OpenMLDB/blob/2e7fb76aca6a41a96c43b46b1be2194281c2166f/java/openmldb-batch/src/main/scala/com/_4paradigm/openmldb/batch/utils/SparkRowUtil.scala#L66

We miss null in `extractKey`.
And after I temporarily make `extractKey` return java Long, some batch tests failed. e.g. https://github.com/4paradigm/OpenMLDB/blob/836b34119249ff9b667130b125c88395ef18ee4f/java/openmldb-batch/src/test/scala/com/_4paradigm/openmldb/batch/nulldata/TestWindowWithNullData.scala#L28

reproduce:
1. make `extractKey` return java Long
2. run TestWindowWithNullData

Contributor guide

Open the contributing guide

Research direction

The bug is in WindowAggPlan.scala line 424-425 where extractKey returns a Scala Long (non-nullable) but isValidOrder expects a Java Long (nullable). Examine extractKey in WindowComputer.scala and getLongFromIndex in SparkRowUtil.scala. Run TestWindowWithNullData to reproduce the failure after modifying extractKey to return java.lang.Long. The fix must handle nulls correctly without breaking existing batch tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, scala
Domain
databases, machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.