Feature: functional dependency optimization
A functional dependency is a relationship between two attributes in the same database.
If an attribute determines another attribute, we will call it a determinant, and the determined attribute is functionally dependent on the determinant.
We will denote the relationship with $X \rightarrow Y$ if $X$ is a determinant of $Y$, where both $X$ and $Y$ can be a set of attributes.
For example, given a SQL:
select a, a+1 as b from t;Here the attribute a is a determinant of b because b is derived from a. Thus we can get a functional dependency $(a) \rightarrow (b)$.
Functional dependency is helpful in query optimization, with it we can eliminate outer joins, eliminate useless DISTINCT, eliminate cross joins and etc.
Reference wiki and the thesis for more details.
The functional dependencies can be derived from relational operators, so it's possible to encapsulate them into RelationalProperty.
Source: databendlabs/databend