From dba96bdb90d227e7047800415f800e882b51e4f4 Mon Sep 17 00:00:00 2001 From: Thomas Gschwind Date: Tue, 16 Jun 2026 16:46:13 +0200 Subject: [PATCH] fix: handle unparameterized interval_day type Allow interval_day to be used without an explicit precision parameter. Signed-off-by: Thomas Gschwind --- src/substrait/derivation_expression.py | 6 ++++++ tests/test_derivation_expression.py | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/src/substrait/derivation_expression.py b/src/substrait/derivation_expression.py index c13dc46..01e8d57 100644 --- a/src/substrait/derivation_expression.py +++ b/src/substrait/derivation_expression.py @@ -151,6 +151,12 @@ def _evaluate(x, values: dict): elif isinstance( parametrized_type, SubstraitTypeParser.PrecisionIntervalDayContext ): + if parametrized_type.precision is None: + return Type( + interval_day=Type.IntervalDay( + nullability=nullability, + ) + ) precision = _evaluate(parametrized_type.precision, values) return Type( interval_day=Type.IntervalDay( diff --git a/tests/test_derivation_expression.py b/tests/test_derivation_expression.py index 680c7c2..10d462f 100644 --- a/tests/test_derivation_expression.py +++ b/tests/test_derivation_expression.py @@ -129,6 +129,15 @@ def test_interval_day(): ) +def test_interval_day_no_precision(): + assert evaluate("interval_day") == Type( + interval_day=Type.IntervalDay(nullability=Type.NULLABILITY_REQUIRED) + ) + assert evaluate("interval_day?") == Type( + interval_day=Type.IntervalDay(nullability=Type.NULLABILITY_NULLABLE) + ) + + def test_struct_simple(): """Test simple struct with two i32 fields.""" result = evaluate("struct", {})