[
https://issues.apache.org/jira/browse/CALCITE-5913?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17752326#comment-17752326
]
Thomas Rebele edited comment on CALCITE-5913 at 8/9/23 8:54 AM:
----------------------------------------------------------------
[~jingda], the method would return the functional dependent columns of *all*
columns, not just from the provided parameter.
Pseudo-code example:
{code:java}
getFunctionalDependentColumns({empno}) = {empno, ename, sal, comm}
getFunctionalDependentColumns({empno, ename}) = {empno, ename, sal, comm}
getFunctionalDependentColumns({empno, ename, sal}) = {empno, ename, sal,
comm}{code}
The columns specified by the parameter are trivially functional dependent, see
the reflexivity from Armstrong's axioms:
{code:java}
getFunctionalDependentColumns({empno, ename, sal, comm}) = {empno, ename, sal,
comm}{code}
----
Another alternative for the method definition would be
FunctionalDependencies getFunctionalDependencies();
with
{code:java}
interface FunctionalDependencies {
boolean isFunctionallyDetermined(ImmutableBitSet columns, int column);
ImmutableBitSet getFunctionalDependentColumns(ImmutableBitSet columns);
List<FunctionalDependency> getNontrivialFunctionalDependencies();
}
interface FunctionalDependency {
ImmutableBitSet getDeterminantColumns();
ImmutableBitSet getDependentColumns();
}{code}
Each method determines the others, and default implementations could be
provided. It depends on the use-case which method would offer the best
performance.
was (Author: thomas.rebele):
[~jingda], the method would return the functional dependent columns of *all*
columns, not just from the provided parameter.
Pseudo-code example:
{code:java}
getFunctionalDependentColumns({empno}) = {empno, ename, sal, comm}
getFunctionalDependentColumns({empno, ename}) = {empno, ename, sal, comm}
getFunctionalDependentColumns({empno, ename, sal}) = {empno, ename, sal,
comm}{code}
The columns specified by the parameter are trivially functional dependent, see
the reflexivity from Armstrong's axioms:
{code:java}
getFunctionalDependentColumns({empno, ename, sal, comm}) = {empno, ename, sal,
comm}{code}
> Support to get functional dependency metadata in RelMetadataQuery
> -----------------------------------------------------------------
>
> Key: CALCITE-5913
> URL: https://issues.apache.org/jira/browse/CALCITE-5913
> Project: Calcite
> Issue Type: New Feature
> Reporter: JingDas
> Assignee: JingDas
> Priority: Major
>
> Functional dependency analysis can be applied to various problems in query
> optimization:
> selectivity estimation, estimation of (intermediate) result sizes, *order
> optimization*
> *(in particular sort avoidance),* cost estimation, and various problems in
> the area of semantic query optimization, as said in the book《[Exploiting
> Functional Dependence in Query
> Optimization》|https://cs.uwaterloo.ca/research/tr/2000/11/CS-2000-11.thesis.pdf]
>
> In calcite, it may be metadata that something like 'FunctionalDependency'
> BuiltInMetadata as following:
> {code:java}
> public abstract class BuiltInMetadata {
> // ...
> public interface FunctionalDependency extends Metadata {
> /** Returns whether column is functionally dependent on columns. */
> Boolean functionallyDetermine(ImmutableBitSet columns, int column);
> }
> } {code}
>
> As the above book said, functional dependency analysis is a valuable and
> challenging work. I think support order optimization
> (in particular sort avoidance) by the relevant functional dependency metadata
> firstly, and then get complete functional dependency function step by step.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)