Skip to content
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

[FEAT] dec128 math #3143

Merged
merged 10 commits into from
Oct 30, 2024
Merged

[FEAT] dec128 math #3143

merged 10 commits into from
Oct 30, 2024

Conversation

samster25
Copy link
Member

@samster25 samster25 commented Oct 29, 2024

  • Removes Int128 Type
  • Refactor Decimal128 to be backed by a DataArray rather than a LogicalArray
  • Implements math operations for Decimal
  • Implements comparison operations for Decimal

@github-actions github-actions bot added the enhancement New feature or request label Oct 29, 2024
Copy link

codspeed-hq bot commented Oct 29, 2024

CodSpeed Performance Report

Merging #3143 will not alter performance

Comparing sammy/decimal128 (eb0bb91) with main (e84ed5b)

Summary

✅ 17 untouched benchmarks

impl Add for &Decimal128Array {
type Output = DaftResult<Decimal128Array>;
fn add(self, rhs: Self) -> Self::Output {
assert_eq!(self.data_type(), rhs.data_type());
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we instead return an error instead of panicking if the types dont match?

Copy link
Member Author

Choose a reason for hiding this comment

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

This should hopefully never happen since the series code should correctly match cast the types before this gets called.

Comment on lines +380 to +381
let l = unsafe { values.get_unchecked(a) };
let r = unsafe { values.get_unchecked(b) };
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add some SAFETY comments explaining why this won't go out of bounds.

Comment on lines +397 to +398
let l = unsafe { values.get_unchecked(a) };
let r = unsafe { values.get_unchecked(b) };
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here

Copy link
Member Author

Choose a reason for hiding this comment

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

done

src/daft-core/src/datatypes/mod.rs Outdated Show resolved Hide resolved
src/daft-dsl/src/lit.rs Outdated Show resolved Hide resolved
src/daft-dsl/src/lit.rs Outdated Show resolved Hide resolved
Copy link

codecov bot commented Oct 30, 2024

Codecov Report

Attention: Patch coverage is 63.19444% with 159 lines in your changes missing coverage. Please review.

Project coverage is 77.48%. Comparing base (e84ed5b) to head (eb0bb91).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
src/daft-core/src/array/ops/sort.rs 0.00% 79 Missing ⚠️
src/daft-core/src/datatypes/infer_datatype.rs 62.58% 52 Missing ⚠️
src/daft-dsl/src/lit.rs 55.55% 8 Missing ⚠️
src/daft-core/src/array/ops/arithmetic.rs 91.46% 7 Missing ⚠️
src/daft-core/src/array/ops/utf8.rs 44.44% 5 Missing ⚠️
src/daft-core/src/series/ops/agg.rs 50.00% 4 Missing ⚠️
src/daft-core/src/series/serdes.rs 71.42% 4 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3143      +/-   ##
==========================================
- Coverage   78.80%   77.48%   -1.33%     
==========================================
  Files         621      621              
  Lines       74809    76670    +1861     
==========================================
+ Hits        58954    59405     +451     
- Misses      15855    17265    +1410     
Files with missing lines Coverage Δ
src/daft-core/src/array/from_iter.rs 78.86% <100.00%> (+3.16%) ⬆️
src/daft-core/src/array/growable/arrow_growable.rs 100.00% <ø> (ø)
...c/daft-core/src/array/growable/logical_growable.rs 90.62% <ø> (ø)
src/daft-core/src/array/growable/mod.rs 100.00% <ø> (ø)
src/daft-core/src/array/ops/apply.rs 100.00% <100.00%> (ø)
src/daft-core/src/array/ops/as_arrow.rs 100.00% <ø> (ø)
src/daft-core/src/array/ops/cast.rs 87.78% <ø> (+0.04%) ⬆️
src/daft-core/src/array/ops/compare_agg.rs 66.01% <100.00%> (-0.50%) ⬇️
src/daft-core/src/array/ops/comparison.rs 76.16% <ø> (ø)
src/daft-core/src/array/ops/get.rs 78.57% <ø> (ø)
... and 27 more

... and 12 files with indirect coverage changes

@universalmind303
Copy link
Collaborator

@samster25 It looks like between is still broken for decimals

df = (
    daft.from_pydict({"floats": [328.00, 300.00, 299.00]})
    .select(col("floats").cast(daft.DataType.decimal128(5, 2)))
    .where(col('floats').between(300, 400))
    .collect()
)

@universalmind303
Copy link
Collaborator

@samster25 It looks like between is still broken for decimals

df = (
    daft.from_pydict({"floats": [328.00, 300.00, 299.00]})
    .select(col("floats").cast(daft.DataType.decimal128(5, 2)))
    .where(col('floats').between(300, 400))
    .collect()
)

so i think this is actually an issue with the decimal casting. Here's a tiny PR to fix the panic.

#3150

@samster25 samster25 merged commit c78fef4 into main Oct 30, 2024
42 of 44 checks passed
@samster25 samster25 deleted the sammy/decimal128 branch October 30, 2024 20:26
sagiahrac pushed a commit to sagiahrac/Daft that referenced this pull request Nov 4, 2024
* Removes Int128 Type
* Refactor Decimal128 to be backed by a DataArray rather than a
LogicalArray
* Implements math operations for Decimal
* Implements comparison operations for Decimal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants