apache / apache/gluten

NumberFormatException in WindowFunctionNode.setBound()

Open
#10,644 0 comments 0 reactions 0 assignees View on GitHub
bug triage
Dominant language
Scala
Stars
1.6k
Forks
657
Avg merge
2d 14h
Merged PRs (30d)
80

Description

#10645
### Bug description
As shown in the example below: In WindowFunctionNode.setBound(),If frameType == "ROW" and boundType is DoubleType,
the code:
https://github.com/apache/incubator-gluten/blob/main/gluten-substrait/src/main/java/org/apache/gluten/substrait/expression/WindowFunctionNode.java#L124
```
Long offset = Long.valueOf(boundType.eval(null).toString());
```

will have a java.lang.NumberFormatException in Long.valueOf();
### sql:
```
CREATE TEMPORARY VIEW t AS SELECT 1;
SELECT COUNT(*) OVER (PARTITION BY 1 ORDER BY cast(1 as double) DESC RANGE BETWEEN CURRENT ROW AND 1 FOLLOWING) FROM t;
```
### result:
```
java.lang.NumberFormatException: For input string: "1.0"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Long.parseLong(Long.java:589)
at java.lang.Long.valueOf(Long.java:803)
at org.apache.gluten.substrait.expression.WindowFunctionNode.setBound(WindowFunctionNode.java:124)
at org.apache.gluten.substrait.expression.WindowFunctionNode.toProtobuf(WindowFunctionNode.java:181)
at org.apache.gluten.substrait.rel.WindowRelNode.toProtobuf(WindowRelNode.java:77)
at org.apache.gluten.substrait.plan.PlanNode.toProtobuf(PlanNode.java:78)
```

### Gluten version

main branch, Gluten-1.4, Gluten-1.3

### Spark version

Spark-3.3.x

### Spark configurations

_No response_

### System information

_No response_

### Relevant logs

```bash

```

Contributor guide

Open the contributing guide

Research direction

Start at gluten-substrait/src/main/java/org/apache/gluten/substrait/expression/WindowFunctionNode.java:124 and reproduce the failure with the SQL query in the issue. Check how setBound handles ROW and RANGE bounds when the evaluated value is DoubleType; done means the query no longer raises NumberFormatException and window-bound conversion remains correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
databases
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.