verdict-project / verdict

Interactive-Speed Analytics: 200x Faster, 200x Fewer Cluster Resources, Approximate Query Processing
http://verdictdb.org
Apache License 2.0
248 stars 66 forks source link

Currently, subquery is not supported in HAVING clause #383

Closed solangepaz closed 5 years ago

solangepaz commented 5 years ago

I'm using the TPC-H queries you used in your paper, however, when I run query 11 I get this error:

java.sql.SQLException: org.verdictdb.exception.VerdictDBDbmsException: Currently, subquery is not supported in HAVING clause.
    at org.verdictdb.jdbc41.VerdictStatement.executeQuery(VerdictStatement.java:134)
    at com.speedment.example.App.runQuery(App.java:84)
    at com.speedment.example.App.main(App.java:46)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:282)
    at java.lang.Thread.run(Thread.java:748)
Caused by: org.verdictdb.exception.VerdictDBDbmsException: Currently, subquery is not supported in HAVING clause.
    at org.verdictdb.sqlreader.RelationStandardizer.standardize(RelationStandardizer.java:556)
    at org.verdictdb.sqlreader.RelationStandardizer.standardizeSelectQuery(RelationStandardizer.java:103)
    at org.verdictdb.coordinator.ExecutionContext.standardizeSelectQuery(ExecutionContext.java:357)
    at org.verdictdb.coordinator.ExecutionContext.standardizeQuery(ExecutionContext.java:337)
    at org.verdictdb.coordinator.ExecutionContext.standardizeQuery(ExecutionContext.java:332)
    at org.verdictdb.coordinator.ExecutionContext.sqlSelectQuery(ExecutionContext.java:236)
    at org.verdictdb.coordinator.ExecutionContext.sql(ExecutionContext.java:160)
    at org.verdictdb.coordinator.ExecutionContext.sql(ExecutionContext.java:137)
    at org.verdictdb.jdbc41.VerdictStatement.executeQuery(VerdictStatement.java:131)
    ... 8 more

The query is this:

select
    ps_partkey,
    sum(ps_supplycost * ps_availqty) as value
from
    partsupp,
    supplier,
    nation
where
    ps_suppkey = s_suppkey
    and s_nationkey = n_nationkey
    and n_name = 'GERMANY'
group by
    ps_partkey having
        sum(ps_supplycost * ps_availqty) > (
            select
                sum(ps_supplycost * ps_availqty) * 0.0001000000
            from
                partsupp,
                supplier,
                nation
            where
                ps_suppkey = s_suppkey
                and s_nationkey = n_nationkey
                and n_name = 'GERMANY'
        )
order by
    value desc;
pyongjoo commented 5 years ago

According to my notes, we used this query instead (by processing the subquery first):

select
  ps_partkey,
  sum(ps_supplycost * ps_availqty) as value
from
  partsupp,
  supplier,
  nation
where
  ps_suppkey = s_suppkey
  and s_nationkey = n_nationkey
  and n_name = 'GERMANY'
group by
  ps_partkey 
having
    sum(ps_supplycost * ps_availqty) > 10
order by
  value desc;

I don't guarantee that the current version supports this query since we have disabled some features for better usability (rather than covering every case).