Skip to content
This repository has been archived by the owner on Jan 13, 2023. It is now read-only.

Add decimal literal #39

Merged
merged 2 commits into from
Dec 15, 2022
Merged

Conversation

nseekhao
Copy link
Contributor

@nseekhao nseekhao commented Dec 12, 2022

Details

  • Add support for Decimal128 literal expression (producer, consumer, test)
  • Modified create_context() to explicitly set one column to type Decimal128 to test implementation

@andygrove andygrove merged commit adaccce into datafusion-contrib:main Dec 15, 2022
@@ -576,6 +583,13 @@ pub async fn from_substrait_rex(
Some(LiteralType::Fp64(f)) => {
Ok(Arc::new(Expr::Literal(ScalarValue::Float64(Some(*f)))))
}
Some(LiteralType::Decimal(d)) => Ok(Arc::new(Expr::Literal(ScalarValue::Decimal128(
Some(std::primitive::i128::from_le_bytes(
d.value.clone().try_into().unwrap(),

Choose a reason for hiding this comment

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

Is it OK to call .unwrap() here ?
Wouldn't it be better to use ? instead and propagate the error ? The method returns Result<Arc<Expr>>.
IMO a library should never panic!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants