apache / apache/datafusion-comet

Native engine panics on all-scalar inputs for hour, minute, second, unix_timestamp

Open
#3,336 1 comment 0 reactions 1 assignee Claimed by @0lai0 View on GitHub
area:expressions bug crash priority:low
Dominant language
Scala
Stars
1.3k
Forks
373
Avg merge
2d 4h
Merged PRs (30d)
198

Description

## Description

When Spark's `ConstantFolding` optimizer rule is disabled, all-scalar (literal-only) expressions reach Comet's native engine instead of being folded at plan time. The native engine panics with messages like:

- `hour(scalar) should be fold in Spark JVM side.`
- `minute(scalar) should be fold in Spark JVM side.`
- `second(scalar) should be fold in Spark JVM side.`
- `unix_timestamp(scalar) should be fold in Spark JVM side.`

## How to Reproduce

Disable constant folding and run an all-literal datetime extraction query:

```sql
SET spark.sql.optimizer.excludedRules=org.apache.spark.sql.catalyst.optimizer.ConstantFolding;
SELECT hour(timestamp('2024-01-15 12:30:45'));
```

## Expected Behavior

The native engine should handle scalar inputs gracefully — either by computing the correct result or by falling back to Spark, not by panicking.

## Affected Expressions

- `hour()`
- `minute()`
- `second()`
- `unix_timestamp()`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.