Open fanfuxiaoran opened 1 day ago
Working on adding tests for it!
Found that gpdb has a similar commit : https://github.com/greenplum-db/gpdb-archive/commit/d3dd98c1a8daf04fbf6cb91fc4afa6f91b317e93 Just cherry-pick it . But it has some problems, added a commit to fix it.
For the below query
orca generates a wrong plan:
The root cause is '(t1.b < t1.b)' is been transformed into 'CScalarConst (0)' by 'PexprEliminateSelfComparison'. The reason is that when checking if the
selfcomparison
can be simplified by functionFSelfComparison
, it checks theCColRef
IsNullable only from the column definition, not checking if the column is from outer join.To fix it, before simplifing the scalar expression, we fisrt get the 'pcrsNotNull' from its parent expression. 'pcrsNotNull' recoreds the output columns' nullable property. If the column is not in 'pcrsNotNull', then the self comparison cannot be transformed into const true or false.
Fixes #594
What does this PR do?
Type of Change
Breaking Changes
Test Plan
make installcheck
make -C src/test installcheck-cbdb-parallel
Impact
Performance:
User-facing changes:
Dependencies:
Checklist
Additional Context
⚠️ To skip CI: Add
[skip ci]
to your PR title. Only use when necessary! ⚠️