[
https://issues.apache.org/jira/browse/CALCITE-7767?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18112438#comment-18112438
]
Diveyam Mishra commented on CALCITE-7767:
-----------------------------------------
In {{RelMetadataTest.java }}There exists a test which is disabled because
"Plan contains casts, which inhibit metadata propagation" For the query :
{code:java}
SELECT name FROM dept UNION ALL SELECT ename FROM emp {code}
* In table {{{}DEPT{}}}, column {{NAME}} has type {{{}VARCHAR(10){}}}.
* In table {{{}EMP{}}}, column {{ENAME}} has type {{{}VARCHAR(20){}}}.
Because {{CAST($1 AS VARCHAR(20))}} is a {{RexCall}} and not a
{{{}RexInputRef{}}}, it unconditionally falls into
{{{}createDerivedColumnOrigins(set){}}}, which sets {{{}isDerived = true{}}}.
*Semantics of {{isDerived}} for CAST:* Should lossless / widening type casts
(e.g. {{VARCHAR(10) -> VARCHAR(20)}} or {{INT -> BIGINT}} via
{{{}RexUtil.isLosslessCast{}}}) preserve {{{}isDerived = false{}}}, or should
any type conversion strictly mark the column as derived?
*Optimizer Safety:* {{RelColumnOrigin.isDerived()}} is used by rules such as
{{LoptOptimizeJoinRule#areSelfJoinKeysUnique}} to verify that equality join
keys originate from identical, unaltered physical columns before eliminating
self-joins. Would treating lossless casts as non-derived violate safety
invariants for join elimination or other metadata consumers?
> Re-enable disabled in RelMetadataTest with updated selectivity expectations
> ---------------------------------------------------------------------------
>
> Key: CALCITE-7767
> URL: https://issues.apache.org/jira/browse/CALCITE-7767
> Project: Calcite
> Issue Type: Task
> Components: tests
> Reporter: Diveyam Mishra
> Assignee: Diveyam Mishra
> Priority: Trivial
>
> h4. Problem
> In {{{}RelMetadataTest.java{}}}, five tests verifying
> {{RelMetadataQuery#getPercentageOriginalRows}} have been disabled since the
> initial Optiq/Eigenbase migration:
> * {{testPercentageOriginalRowsTwoFilters}}
> * {{testPercentageOriginalRowsRedundantFilter}}
> * {{testPercentageOriginalRowsJoinTwoFilters}}
> * {{testPercentageOriginalRowsUnionLittleFilter}}
> * {{testPercentageOriginalRowsUnionBigFilter}}
> h4. Cause
> These legacy tests were written under early Optiq assumptions where all
> equality predicates were assigned a fixed default selectivity
> ({{{}DEFAULT_EQUAL_SELECTIVITY = 0.15{}}}).
> As Calcite's metadata framework evolved to incorporate schema knowledge
> (specifically identifying {{deptno}} as a unique primary key on table
> {{{}dept{}}}, yielding an exact selectivity of {{{}1.0 / DEPT_SIZE =
> 0.25{}}}), the hardcoded assertions expecting {{0.15}} and {{0.0225}} failed.
> Rather than updating the formulas to reflect Calcite's improved metadata
> formulas, {{@Disabled}} was added.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)