Here’s a query that would give the wrong answer if you trim:

  select count(*) from (
    select deptno from scott.emp
    union
    select deptno from scott.dept);

returns 4. Note that ‘deptno’ is not used. But when I trim it away,

  select count(*) from (
    select 'a' from scott.emp
    union
    select 'a' from scott.dept);

returns 1. (I included ‘a’ because SQL doesn’t allow an empty SELECT clause. It 
doesn’t affect the reasoning.)

Julian



> On Jun 2, 2021, at 6:03 AM, Sean Broeder <sbroe...@apache.org> wrote:
> 
> Currently the RefFieldTrimmer only trims on a UNION ALL operation.  I've
> been experimenting to see if it is also possible to trim on UNION
> DISTINCT.  Is there a simple query that demonstrates why this is not
> possible?
> 
> Thanks,
> Sean

Reply via email to