It sounds like a good fit. Parse the SQL, translate to relational algebra, 
apply some query transformation rules on the algebra.

If you have a few simple transformations in mind, you may be able to achieve it 
without a cost model. Or, as you propose, a simple model based on cardinality.

To convert a union of conjunctive queries to a conjunction of possibly-union 
queries, you would probably need a rule called UnionJoinTransposeRule that 

  (Union (Join X Y) (Join X Y))


  (Join X (Union Y Z))

or something like that, and combines it with some existing rules to push 
unions. There is currently no such rule but it would not be hard to write.


> On Feb 14, 2018, at 5:24 AM, Guohui Xiao <> wrote:
> Hi,
> We are considering using Calcite to perform cost-based query optimization
> in our project.
> Specifically, we can already generate some SQL queries expressed in some
> relational algebra expression through our API, and we want to optimize the
> generated expressions using Calcite.
> We have a cost model based on cardinality estimation. We want to use it to
> convert e.g., a union of conjunctive queries (UCQ) into a a join of UCQs.
> We would like to understand how much efforts are needed to realize our idea
> using Calcite.
> Do you have suggestions about this?
> Thanks in advance.
> Best regards,
> Guohui & Davide
> -- 
> Guohui Xiao, PhD
> Assistant Professor with a fixed-term contract
> KRDB - Faculty of Computer Science
> Free University of Bozen-Bolzano
> Piazza Domenicani, 3
> I-39100 Bolzano, Italy

Reply via email to