-
Notifications
You must be signed in to change notification settings - Fork 375
feat: support divide_dt_interval with codegen dispatch #4901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
peterxcli
wants to merge
14
commits into
apache:main
Choose a base branch
from
peterxcli:feat/divide_dt_interval
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
39addd2
feat: support divide_dt_interval
peterxcli 38c62b5
Merge branch 'main' into feat/divide_dt_interval
peterxcli f290f8d
Merge branch 'main' of https://github.com/apache/datafusion-comet int…
peterxcli 8a8fe44
revert accidently remove code
peterxcli ed5c9bf
Merge remote-tracking branch 'upstream/main' into feat/divide_dt_inte…
peterxcli cb05943
Merge branch 'main' into feat/divide_dt_interval
peterxcli a265bdc
Merge branch 'main' into feat/divide_dt_interval
peterxcli 10d3db7
Merge branch 'main' into feat/divide_dt_interval
peterxcli 76650c2
Merge branch 'main' into feat/divide_dt_interval
peterxcli 1a31ef0
Merge branch 'main' into feat/divide_dt_interval
peterxcli 8934ebe
address review: fix serde map ordering, add wide decimal divisor cove…
peterxcli c48eff6
Merge remote-tracking branch 'origin/feat/divide_dt_interval' into fe…
peterxcli abce02b
Merge remote-tracking branch 'upstream/main' into feat/divide_dt_inte…
peterxcli 14c609d
Merge branch 'main' into feat/divide_dt_interval
peterxcli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
spark/src/test/resources/sql-tests/expressions/datetime/divide_dt_interval.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| -- Licensed to the Apache Software Foundation (ASF) under one | ||
| -- or more contributor license agreements. See the NOTICE file | ||
| -- distributed with this work for additional information | ||
| -- regarding copyright ownership. The ASF licenses this file | ||
| -- to you under the Apache License, Version 2.0 (the | ||
| -- "License"); you may not use this file except in compliance | ||
| -- with the License. You may obtain a copy of the License at | ||
| -- | ||
| -- http://www.apache.org/licenses/LICENSE-2.0 | ||
| -- | ||
| -- Unless required by applicable law or agreed to in writing, | ||
| -- software distributed under the License is distributed on an | ||
| -- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| -- KIND, either express or implied. See the License for the | ||
| -- specific language governing permissions and limitations | ||
| -- under the License. | ||
|
|
||
| -- Routes divide_dt_interval through the codegen dispatcher; produces DayTimeIntervalType. | ||
| -- Config: spark.comet.exec.scalaUDF.codegen.enabled=true | ||
|
|
||
| statement | ||
| CREATE TABLE test_divide_dt_interval(days int, hours int, minutes int, seconds decimal(18,6), b tinyint, s smallint, i int, l long, f float, d double, dec decimal(10,2), dec_wide decimal(38,18), dec_big decimal(38,0)) USING parquet | ||
|
|
||
| statement | ||
| INSERT INTO test_divide_dt_interval VALUES | ||
| (1, 2, 3, 4.500000, CAST(2 AS TINYINT), CAST(3 AS SMALLINT), 2, CAST(3 AS BIGINT), CAST(1.5 AS FLOAT), CAST(2.5 AS DOUBLE), CAST(2.50 AS DECIMAL(10, 2)), CAST(2.5 AS DECIMAL(38, 18)), CAST(3 AS DECIMAL(38, 0))), | ||
| (-1, 0, 30, 15.250000, CAST(-2 AS TINYINT), CAST(-3 AS SMALLINT), -2, CAST(-3 AS BIGINT), CAST(-1.5 AS FLOAT), CAST(-2.5 AS DOUBLE), CAST(-2.50 AS DECIMAL(10, 2)), CAST(-2.5 AS DECIMAL(38, 18)), CAST(-3 AS DECIMAL(38, 0))), | ||
| (0, 0, 0, 0.000001, CAST(2 AS TINYINT), CAST(2 AS SMALLINT), 2, CAST(2 AS BIGINT), CAST(2.0 AS FLOAT), CAST(2.0 AS DOUBLE), CAST(2.00 AS DECIMAL(10, 2)), CAST(2.0 AS DECIMAL(38, 18)), CAST(2 AS DECIMAL(38, 0))), | ||
| (2, -6, 0, 0.000000, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) | ||
|
|
||
| query | ||
| SELECT | ||
| make_dt_interval(days, hours, minutes, seconds) / b, | ||
| make_dt_interval(days, hours, minutes, seconds) / s, | ||
| make_dt_interval(days, hours, minutes, seconds) / i, | ||
| make_dt_interval(days, hours, minutes, seconds) / l, | ||
| make_dt_interval(days, hours, minutes, seconds) / f, | ||
| make_dt_interval(days, hours, minutes, seconds) / d, | ||
| make_dt_interval(days, hours, minutes, seconds) / dec | ||
| FROM test_divide_dt_interval | ||
|
|
||
| -- Wide decimal divisors: DECIMAL(38, 18) reads through the DecimalVector slow path | ||
| -- (precision > 18 does not fit an unscaled long) and DECIMAL(38, 0) covers scale 0. | ||
| query | ||
| SELECT | ||
| make_dt_interval(days, hours, minutes, seconds) / dec_wide, | ||
| make_dt_interval(days, hours, minutes, seconds) / dec_big | ||
| FROM test_divide_dt_interval | ||
|
|
||
| -- literal interval input | ||
| query | ||
| SELECT INTERVAL '1 02:03:04.500000' DAY TO SECOND / i FROM test_divide_dt_interval | ||
|
|
||
| -- literal divisors, including half-up rounding to the nearest microsecond. | ||
| query | ||
| SELECT | ||
| make_dt_interval(1, 2, 3, 4.5) / 2, | ||
| INTERVAL '0.000001' SECOND / 2, | ||
| INTERVAL '0.000001' SECOND / CAST(2.00 AS DECIMAL(10, 2)), | ||
| INTERVAL '1 02:03:04.500000' DAY TO SECOND / CAST(2.5 AS DECIMAL(38, 18)), | ||
| INTERVAL '1 02:03:04.500000' DAY TO SECOND / CAST(3 AS DECIMAL(38, 0)), | ||
| make_dt_interval(-1, 0, 30, 15.25) / 1.5D | ||
|
|
||
| -- null interval input | ||
| query | ||
| SELECT make_dt_interval(NULL, hours, minutes, seconds) / 2 | ||
| FROM test_divide_dt_interval | ||
|
|
||
| -- Division by zero fails regardless of ANSI mode. | ||
| query expect_error(zero) | ||
| SELECT make_dt_interval(1) / 0 | ||
|
|
||
| -- This interval is Long.MinValue microseconds, which cannot be divided by -1. | ||
| query expect_error(overflow) | ||
| SELECT make_dt_interval(-106751991, -4, 0, -54.775808) / -1 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a before/after benchmark for a projection using this expression? That would show whether avoiding fallback offsets the dispatcher and Arrow conversion costs. Please verify the fallback/dispatch plans and consume the interval result.