uwdb / Cosette

Cosette is an automated SQL solver.
BSD 2-Clause "Simplified" License
662 stars 54 forks source link

EXISTS Freezes #63

Open vinvsv97 opened 6 years ago

vinvsv97 commented 6 years ago

When I ran cosette to check query that uses EXISTS in its WHERE caluse, cosette freezes. A similar query using IN in its WHERE clause works perfectly. Query 1 below works fine but query 2 freezes

schema sch_flights(fid:int,
    year:int,
    month_id:int,
    day_of_month:int,
    day_of_week_id:int,
    carrier_id:string,
    flight_num:int,
    origin_city:string,
    origin_state:string,
    dest_city:string,
    dest_state:string,
    departure_delay:int,
    taxi_out:int,
    arrival_delay:int,
    canceled:int,
    actual_time:int,
    distance:int,
    capacity:int,
    price:int
);

schema sch_carriers
(
    cid:int,
    name:string
);

SCHEMA sch_months
(
    mid:int,
    month:string
);

SCHEMA sch_weekdays
(
    did:int,
    day_of_week:string
);

table Flights(sch_flights);
table Carriers(sch_carriers);
table Weekdays(sch_weekdays);
table Months(sch_months);
query q1                -- define query q1 on tables a and b
 select distinct C.name as carrier
 from Carriers C
 where C.cid in (select F.carrier_id as carrier_id
                          from Flights F
                          where F.origin_city = 'Seattle WA' and 
                            F.dest_city = 'San Francisco CA' and
                            F.carrier_id = C.cid);

query q2                -- define query q2 likewise
 SELECT DISTINCT c.name AS carrier
 FROM Carriers AS c
 WHERE EXISTS ( SELECT *
                          FROM flights AS f
                          WHERE f.carrier_id = c.cid
                      AND f.origin_city = 'Seattle WA'
                      AND f.dest_city = 'San Francisco CA');
stechu commented 6 years ago

@vinvsv97 we hear you. This is a known issue. Unfortunately, I don't have any cycle right now. Will fix it after May 15th.