Skip to content

Conversation

bvolpato
Copy link
Contributor

Which issue does this PR close?

Rationale for this change

Making sure that we can have proper mapping between Substrait and Arrow types.

What changes are included in this PR?

Adds support for ScalarValue::Time64Microsecond and ScalarValue::Time64Nanosecond to be converted to and from Substrait literals.

This includes the PrecisionTime literal type and specific TIME_64_TYPE_VARIATION_REF for 6-digit (microseconds) and 9-digit (nanoseconds) precision.

Are these changes tested?

Added unit tests

Are there any user-facing changes?

n/a

Adds support for `ScalarValue::Time64Microsecond` and `ScalarValue::Time64Nanosecond` to be converted to and from Substrait literals. This includes the `PrecisionTime` literal type and specific `TIME_64_TYPE_VARIATION_REF` for 6-digit (microseconds) and 9-digit (nanoseconds) precision.
@github-actions github-actions bot added the substrait Changes to the substrait crate label Sep 19, 2025
@alamb
Copy link
Contributor

alamb commented Sep 19, 2025

@LiaCastaneda and @gabotechs can one of you help review this PR?

@gabotechs
Copy link
Contributor

Sure! giving it a look shortly

Copy link
Contributor

@gabotechs gabotechs left a comment

Choose a reason for hiding this comment

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

👍 nice!

@@ -155,6 +155,29 @@ pub(crate) fn from_substrait_literal(
}
},
Some(LiteralType::Date(d)) => ScalarValue::Date32(Some(*d)),
Some(LiteralType::PrecisionTime(pt)) => match pt.precision {
6 => match lit.type_variation_reference {
Copy link
Contributor

@gabotechs gabotechs Sep 19, 2025

Choose a reason for hiding this comment

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

Nice, I imagine if we wanted to support the rest of the type variations it would look something like:

            0 => match lit.type_variation_reference {
                TIME_32_TYPE_VARIATION_REF => {
                    ScalarValue::Time32Second(Some(pt.value as i32))
                }
                others => {
                    return substrait_err!("Unknown type variation reference {others}");
                }
            },
            3 => match lit.type_variation_reference {
                TIME_32_TYPE_VARIATION_REF => {
                    ScalarValue::Time32Millisecond(Some(pt.value as i32))
                }
                others => {
                    return substrait_err!("Unknown type variation reference {others}");
                }
            },

If you are up for the ride I think we could also add them, otherwise I think it's fine as is

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
substrait Changes to the substrait crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Time literal support for Substrait
4 participants