apache / apache/datafusion

change `extract` return types to decimal to align with postgres

Open
#3,996 3 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Rust
Stars
9.3k
Forks
2.4k
Avg merge
3d 7h
Merged PRs (30d)
344

Description

extract currently returns i32 which might loss some information

```bash
❯ select extract(second from timestamp '2000-01-01T00:00:00.1');
+--------------------------------------------------------+
| datepart(Utf8("SECOND"),Utf8("2000-01-01T00:00:00.1")) |
+--------------------------------------------------------+
| 0 |
+--------------------------------------------------------+
1 row in set. Query took 0.000 seconds.
```

while postgresql returns decimal

```bash
willy=# select extract(second from timestamp '2000-01-01T00:00:00.1');
extract
----------
0.100000
(1 row)
```

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

change it to decimal

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.

Contributor guide

Open the contributing guide

Research direction

Start by locating the SQL EXTRACT implementation and reproduce the supplied SECOND-from-timestamp query, comparing its current result with the PostgreSQL example. Trace where the i32 return type is established and inspect existing coverage; done means fractional seconds are preserved and the relevant tests pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, rust
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.