Skip to content

test: add tests for more primitive types#5173

Merged
wjones127 merged 5 commits intolance-format:mainfrom
wjones127:primitive-tests
Dec 17, 2025
Merged

test: add tests for more primitive types#5173
wjones127 merged 5 commits intolance-format:mainfrom
wjones127:primitive-tests

Conversation

@wjones127
Copy link
Copy Markdown
Contributor

@wjones127 wjones127 commented Nov 6, 2025

Covers floats, strings, binary, decimals, dates, and timestamps.

Closes #4933

@github-actions github-actions Bot added the chore label Nov 6, 2025
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Nov 6, 2025

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
rust/lance-datafusion/src/expr.rs 0.00% 1 Missing ⚠️
rust/lance-datagen/src/generator.rs 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@wjones127
Copy link
Copy Markdown
Contributor Author

This is stacked on #4745. To review, just look at the last three commits, which are mostly in one file.

@wjones127 wjones127 marked this pull request as ready for review November 6, 2025 23:18
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread rust/lance-datafusion/src/expr.rs Outdated
Comment on lines +120 to +138
// Convert integer to decimal by multiplying by 10^scale
DataType::Decimal128(precision, scale) => val.map(|v| {
let scaled_value = (v as i128) * 10_i128.pow(*scale as u32);
ScalarValue::Decimal128(Some(scaled_value), *precision, *scale)
}),
DataType::Decimal256(precision, scale) => val.and_then(|v| {
// Convert i64 to i256 and scale
// First compute the scale factor as i128, then build i256
let scale_factor = 10_i128.pow(*scale as u32);
// Convert the integer value to i256 and multiply by scale factor
let v_i256 = i256::from(v);
// Convert i128 to i256 by converting to/from bytes
let scale_bytes = scale_factor.to_le_bytes();
let mut i256_bytes = [0u8; 32];
// Copy the i128 bytes into the lower 16 bytes of i256
i256_bytes[..16].copy_from_slice(&scale_bytes);
// Sign extend if negative
if scale_factor < 0 {
i256_bytes[16..].fill(0xFF);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Coercing integers to Decimal256 overflows for high scale

The new Decimal256 branch in safe_coerce_scalar builds its scale multiplier with let scale_factor = 10_i128.pow(*scale as u32) before converting to i256. Decimal256 columns allow scales up to 76, but any scale greater than 38 exceeds the range of i128, so this call will overflow (panic in debug, wrap in release) and produce an invalid scalar whenever a high-scale Decimal256 column is compared with an integer literal. The multiplier should be constructed directly as an i256 (or checked for overflow) instead of first materializing it as an i128.

Useful? React with 👍 / 👎.

@wjones127 wjones127 force-pushed the primitive-tests branch 3 times, most recently from d35cafd to d37f4c7 Compare December 10, 2025 01:06
Copy link
Copy Markdown
Contributor

@jackye1995 jackye1995 left a comment

Choose a reason for hiding this comment

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

looks good to me, sorry for the late review 🙏

@wjones127 wjones127 merged commit 1d16013 into lance-format:main Dec 17, 2025
28 checks passed
@wjones127 wjones127 deleted the primitive-tests branch December 17, 2025 18:07
jackye1995 pushed a commit to jackye1995/lance that referenced this pull request Jan 21, 2026
Covers floats, strings, binary, decimals, dates, and timestamps.

Closes lance-format#4933
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Query tests: Primitive tests

3 participants