Skip to content

ARROW-14101: [C++] multiply(duration, integer) -> duration kernel#12215

Closed
rok wants to merge 2 commits into
apache:masterfrom
rok:ARROW-14101
Closed

ARROW-14101: [C++] multiply(duration, integer) -> duration kernel#12215
rok wants to merge 2 commits into
apache:masterfrom
rok:ARROW-14101

Conversation

@rok

@rok rok commented Jan 20, 2022

Copy link
Copy Markdown
Member

This is to resolve ARROW-14101 and ARROW-14102.

@rok rok changed the title ARROW-14101: [C++] multiply(interval, integer) -> interval kernel ARROW-14101: [C++] multiply(duration, integer) -> duration kernel Jan 20, 2022
@github-actions

Copy link
Copy Markdown

@jorisvandenbossche

Copy link
Copy Markdown
Member

For the mutiply_checked, should we add a test for a duration that would go out of bounds? Or is this already sufficiently covered by integer multiply_checked tests if that is using the same underlying implementation?

@rok

rok commented Jan 27, 2022

Copy link
Copy Markdown
Member Author

For the mutiply_checked, should we add a test for a duration that would go out of bounds? Or is this already sufficiently covered by integer multiply_checked tests if that is using the same underlying implementation?

Another test won't hurt :) I'll add it.

@rok rok force-pushed the ARROW-14101 branch 3 times, most recently from 1fd50f0 to 9f40218 Compare January 27, 2022 19:40
@rok

rok commented Jan 27, 2022

Copy link
Copy Markdown
Member Author

Added the test and removed divide checked (seemed redundant since we're only dividing with integers).

@rok rok force-pushed the ARROW-14101 branch 2 times, most recently from c27af81 to 6e4f4bd Compare February 2, 2022 17:55
@rok rok force-pushed the ARROW-14101 branch 3 times, most recently from 7ad426d to 33d1458 Compare February 9, 2022 19:23
@rok rok force-pushed the ARROW-14101 branch 2 times, most recently from d4fdb74 to 5c015d4 Compare February 17, 2022 17:35
@rok

rok commented Feb 18, 2022

Copy link
Copy Markdown
Member Author

@pitrou could you please take a look at this one? It covers multiply and divide (ARROW-14102).

I think the CI error is due to s3fs.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you have a case in this test where the division is not exact?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

Comment thread docs/source/cpp/compute.rst Outdated
@jorisvandenbossche

Copy link
Copy Markdown
Member

Added the test and removed divide checked (seemed redundant since we're only dividing with integers).

I would keep divide_checked. You could give the same argument for divide_checked being redundant for integer types, but we still allow you to use it. It could be annoying that, when using divide_checked, you need to switch to divide, only if your input type is duration.

@rok

rok commented Feb 22, 2022

Copy link
Copy Markdown
Member Author

Thanks for reviewing @jorisvandenbossche. Agreed on the divide_checked. Added.

Comment on lines 205 to 206

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks unexpected to me since int64 is not a temporal at all. @lidavidm What do you think?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine, but maybe we need a better name for what this function does.

That said, I don't think this change is needed for this function to work, anyways. There's only a single temporal argument so there isn't really a meaningful common resolution to cast to.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, the function doesn't seem to have changed :-). It's just the additional test that surprised me (but adding a test for existing behaviour is useful, thank you @rok ).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well duration has a unit and int64 is dimensionless. The goal of the function is to find the best common unit and I'd argue it still does.

Comment thread cpp/src/arrow/compute/kernels/scalar_arithmetic.cc Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth also supporting multiply(int64, duration) or would commutativity be handled at an upper level? @lidavidm

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I don't see why not. It could just use the same exec function.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you some negative value(s) into the mix?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also check that division by zero raises?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

@rok rok requested a review from pitrou February 23, 2022 11:07
@pitrou pitrou closed this in 2f8f1e8 Feb 23, 2022
@ursabot

ursabot commented Feb 23, 2022

Copy link
Copy Markdown

Benchmark runs are scheduled for baseline = 194ace5 and contender = 2f8f1e8. 2f8f1e8 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Finished ⬇️0.0% ⬆️0.0%] ec2-t3-xlarge-us-east-2
[Finished ⬇️0.25% ⬆️0.13%] test-mac-arm
[Failed ⬇️0.36% ⬆️0.0%] ursa-i9-9960x
[Finished ⬇️0.38% ⬆️0.21%] ursa-thinkcentre-m75q
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

@rok

rok commented Feb 23, 2022

Copy link
Copy Markdown
Member Author

Thanks all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants