-
-
Notifications
You must be signed in to change notification settings - Fork 90
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
Add support for algebraic expressions on record types #1407
Conversation
7c0132b
to
51bdc3a
Compare
This looks intriguing! I'll give it a spin once CI is happy. |
89ec76a
to
8c4ae94
Compare
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.
This is working great in practice. I've had some minor questions on the code, but it looks great overall.
One that can error if a field of the same name is present in both inputs, another that takes a policy argument that indicates which input to prioritize.
We introduce 4 operations that can be used on record types or type aliases (the underlying type must be a record too): - `record + record`: Combine the fields of 2 records into a new record - `record <+ record`: Like `+`, but prefer the left operand in case of a field name clash. - `record +> record`: Like `+`, but prefer the right operand in case of a field name clash. - `record - field_name`: Remove the field named `field_name` from a record. The parser encodes these expressions into `record_type` trees, and the symbol resolver will replace them with the outputs as described in the list in the next commit.
293fdf6
to
065f5a3
Compare
@tobim is there a part of the code that I take a look at? Otherwise I'd like to give it a spin from a user perspective. |
Code-wise I would recommend to start with |
Fully agree, the code already received a very thorough review and is looking good. |
Yeah, I looked at the new Suricata schema and it's really great how concise it gets when you can pull the common and event-specific pieces apart. I'm sure @satta will approve 😁.
Good to know. I'll go at it from users perspective then and only look at the implementation if I have time left. |
Definitely! Not having to repeat base fields everywhere will surely lead to more readable schema definitions. It will also simplify our schema customization a lot, so I am looking forward to using this! 👍 |
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.
Probably one of the greatest UX improvements in recent times. 🚀
📔 Description
We introduce 4 operations that can be used on record types or type aliases (the underlying type must be a record too):
record + record
: Combine the fields of 2 records into a new recordrecord <+ record
: Like+
, but prefer the left operand in case of a field name clash.record +> record
: Like+
, but prefer the right operand in case of a field name clash.record - field_name
: Remove the field namedfield_name
from a record.📝 Checklist
🎯 Review Instructions
By commit.