We support the four standard set operations (UNION, UNION ALL, INTERSECT, EXCEPT), but PostgreSQL also supports INTERSECT ALL and EXCEPT ALL (which don't return distinct elements, much like UNION ALL). Our current design uses an enum to represent the operation type, so it's not easily extensible by providers. Options include:
Actual need for INTERSECT ALL and EXCEPT ALL isn't likely to be high, so we can also punt this (although it's a pretty fundamental design discussion).
Unrelated note: MySQL only supports UNION and UNION ALL, no INTERSECT or EXCEPT.
FWIW, UNION ALL, UNION DISTINCT, EXCEPT ALL, EXCEPT DISTINCT, INTERSECT ALL, and INTERSECT DISTINCT are all ANSI SQL standard operators. The DISTINCT keyword is optional.
Great! In that case maybe we can simply include them in our enum and be done with this?
The only issue with EXCEPT ALL and INTERSECT ALL is that there's no LINQ operator for them, so we'd have to add something on EF.Functions or similar?
Sql server does not support these operators, but a translation for intersect all/except all could be done as so::
select a,b,c from table1 t1
intersect all
select d,e,f from table2 t2
Is equivalent to::
select a,b,c from table1 t1
where exists (
select a,b,c
intersect
select d,e,f from table2 t2
)
@roji I think it would be okay to come up new IQueryable
Infrastructure changes made to design now supports following.
Pending work here is