Extended and not-necessarily-relational algebra #234
julianhyde
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Allow the user to declare 'rewrite rules' that match patterns of operators in expressions, and apply those rewrite rules to optimize the expression.
This generalizes a relational algebra system. For example, Apache Calcite comes with the standard relational operators in the box (Scan, Project, Filter, Aggregate, Sort, Join, Union) and allows people to write rules that transform calls to those operators. For example, FilterJoinRule matches a Filter on top of a Join and transforms it to a Join with filters on one or more of its inputs.
In Calcite, as in any relational system, there is a huge difference between relational and ordinary expressions. Consider the (inner) Join operator and its three operands (
left
,right
,condition
). The relational operands (left
andright
) are called inputs, and thecondition
operand is a boolean expression operating on a record from the left and right. The output is also a relation.In Morel, we can consider
join
andfilter
to be ordinary functions:and we can write a rewrite rule that matches a call to
filter
whoseinput
operand is a call tojoin
.The relational system makes certain assumptions:
condition
operands are never values, always constant lambdas that can be inspected by the rule;But in Morel we can remove those assumptions, and apply rewrite rules to any functions. Let's sketch out the signature of a rule and of an engine to apply those rules.
Beta Was this translation helpful? Give feedback.
All reactions