-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: introduce interval_year
and interval_day
types
#48
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,6 +70,34 @@ def Substrait_DateAttr | |
let assemblyFormat = [{ `<` $value `>` }]; | ||
} | ||
|
||
def Substrait_IntervalDaySecondAttr | ||
: Substrait_StaticallyTypedAttr<"IntervalDaySecond", "interval_day_second", | ||
"IntervalDaySecondType"> { | ||
let summary = "Substrait interval day to second type"; | ||
let description = [{ | ||
This type represents a substrait interval day to second attribute type. Note | ||
that this attribute does not attempt to canonicalize equivalent day-second | ||
intervals. | ||
}]; | ||
let parameters = (ins "int32_t":$days, "int32_t":$seconds); | ||
let assemblyFormat = [{ `<` $days `` `d` $seconds `` `s` `>` }]; | ||
let genVerifyDecl = 1; | ||
} | ||
|
||
def Substrait_IntervalYearMonthAttr | ||
: Substrait_StaticallyTypedAttr<"IntervalYearMonth", "interval_year_month", | ||
"IntervalYearMonthType"> { | ||
let summary = "Substrait interval year to month type"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need to document a decision here. The spec says:
We could deduce that we only want to store the number of months, then. However, I think that our design rationale suggest we should have two different numbers:
I'd argue that two plans that differ by the representation of an We should, however, eventually implement a canonicalization pattern that converts these attributes to the representation with |
||
let description = [{ | ||
This type represents a substrait interval year to month attribute type. Note | ||
that this attribute does not attempt to canonicalize equivalent year-month | ||
intervals. | ||
}]; | ||
let parameters = (ins "int32_t":$years, "int32_t":$months); | ||
let assemblyFormat = [{ `<` $years `` `y` $months `` `m` `>` }]; | ||
let genVerifyDecl = 1; | ||
} | ||
|
||
def Substrait_TimeAttr | ||
: Substrait_StaticallyTypedAttr<"Time", "time", "TimeType"> { | ||
let summary = "Substrait time type"; | ||
|
@@ -156,6 +184,8 @@ def Substrait_AtomicAttributes { | |
Substrait_TimestampTzAttr, // TimestampTZ | ||
Substrait_DateAttr, // Date | ||
Substrait_TimeAttr, // Time | ||
Substrait_IntervalYearMonthAttr, // IntervalYear | ||
Substrait_IntervalDaySecondAttr, // IntervalDay | ||
]; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,6 +68,26 @@ LogicalResult AdvancedExtensionAttr::verify( | |
return success(); | ||
} | ||
|
||
LogicalResult mlir::substrait::IntervalYearMonthAttr::verify( | ||
llvm::function_ref<mlir::InFlightDiagnostic()> emitError, int32_t year, | ||
int32_t month) { | ||
if (year < -100000 || year > 100000) | ||
return emitError() << "year must be in a range of [-10,000..10,000] years"; | ||
if (month < -120000 || month > 120000) | ||
return emitError() | ||
<< "month must be in a range of [120,000..120,000] months"; | ||
return success(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, nice! |
||
} | ||
|
||
LogicalResult mlir::substrait::IntervalDaySecondAttr::verify( | ||
llvm::function_ref<mlir::InFlightDiagnostic()> emitError, int32_t days, | ||
int32_t seconds) { | ||
if (days < -3650000 || days > 3650000) | ||
return emitError() | ||
<< "days must be in a range of [-3,650,000..3,650,000] days"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same for seconds. |
||
return success(); | ||
} | ||
|
||
//===----------------------------------------------------------------------===// | ||
// Substrait enums | ||
//===----------------------------------------------------------------------===// | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same two comments here as for the other interval type.