Skip to content
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: elide attribute type with new StaticallyTypedAttrInterface #59

Merged

Conversation

ingomueller-net
Copy link
Collaborator

@ingomueller-net ingomueller-net commented Jan 17, 2025

This allows to omit the type of an attribute from the assembly if it can be inferred from the attribute value. For example, the type is redundant in #substrait.timestamp<100us> : !substrait.timestamp. The built-in TypedAttrInterface, however, forces the appearance of the type in the assembly. The new interface is almost identical but does not enforce it. The PR also makes the two timestamp, the date, and the time attributes implement that interface.

@ingomueller-net ingomueller-net force-pushed the statically-typed-attr branch 2 times, most recently from d3c98d6 to 02f7193 Compare January 21, 2025 09:12
@ingomueller-net ingomueller-net changed the title WIP: Elide attribute type with new StaticallyTypedAttrInterface feat: elide attribute type with new StaticallyTypedAttrInterface [WIP] Jan 21, 2025
@ingomueller-net ingomueller-net changed the title feat: elide attribute type with new StaticallyTypedAttrInterface [WIP] feat: elide attribute type with new StaticallyTypedAttrInterface Jan 21, 2025
@ingomueller-net ingomueller-net force-pushed the statically-typed-attr branch 2 times, most recently from efadd27 to 007fae0 Compare January 21, 2025 10:14
@ingomueller-net
Copy link
Collaborator Author

@dshaaban01: Have a look at this PR. I managed to elide the attribute type from the assembly. I hope we'll be able to merge it soon, so consider starting any new work based on this PR if it's related.

This allows to omit the type of an attribute from the assembly if it can
be inferred from the attribute value. For example, the type is redundant
in `#substrait.timestamp<100us> : !substrait.timestamp`. The built-in
`TypedAttrInterface`, however, forces the appearance of the type in the
assembly. The new interface is almost identical but does not enforce it.
The PR also makes the two timestamp, the date, and the time attributes
implement that interface.

Signed-off-by: Ingo Müller <[email protected]>
Copy link
Collaborator

@jpienaar jpienaar left a comment

Choose a reason for hiding this comment

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

Nice, we could even have a variant of this upstream :)

def Substrait_TimeAttr : Substrait_Attr<"Time", "time",
[TypedAttrInterface]> {
def Substrait_TimeAttr :
Substrait_StaticallyTypedAttr<"Time", "time", "TimeType"> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Micro nit: add additional spaces here to differentiate from body below (I normally just add 2 extra, else this and body looks at same scope ... I should really try out the new formatter)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed. I tried clang-format, which seems to work on .td files as well, and it works. I have formatted the lines of this commit using it. However, I am unsure as to whether and how to apply or enforce it on the existing files. The diff is quite big and a big commit just for reformatting has disadvantages...

}

def Substrait_TimestampAttr : Substrait_Attr<"Timestamp", "timestamp",
[TypedAttrInterface]> {
def Substrait_TimestampAttr
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: colon on this line to match the others.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

@ingomueller-net ingomueller-net merged commit 0a55131 into substrait-io:main Jan 30, 2025
7 checks passed
@ingomueller-net ingomueller-net deleted the statically-typed-attr branch January 30, 2025 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants