Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/substrait/derivation_expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
)
Comment on lines +154 to +159

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do you have a little bit more context on whether this is only an issue for IntervalDay for you and how this is triggered? I'm asking since we have very similar code above for PrecisionTimestampContext and PrecisionTimestampTZContext.

precision = _evaluate(parametrized_type.precision, values)
return Type(
interval_day=Type.IntervalDay(
Expand Down
9 changes: 9 additions & 0 deletions tests/test_derivation_expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -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<i32, i32>", {})
Expand Down