Query input rows/size stats not tracked properly for JOIN queries
The query-level stats only include the row/size from the leaf stage. The should include the inputs for all stages that perform table scans.

For example:

```
1:20 [ 130M rows, 14.1GB] [1.64M rows/s,  182MB/s] [  <=>                                     ]

     STAGES   ROWS  ROWS/s  BYTES  BYTES/s  QUEUED    RUN   DONE
0.........R      0       0     0B       0B       0      1      0
  1.......R      0       0     0B       0B       0     20      0
    2.....S    13B    163M  1.82T    23.4G    1478   8870  27560
      3...F  43.1M       0  2.38G       0B       0      0     20
        4.F   130M       0  14.1G       0B       0      0   2363
```

The bug is possibly due to the following check in `QueryStateMachine.getQueryInfo()`, line 193:

``` java
if (stageInfo.getSubStages().isEmpty()) {
```

diff --git a/presto-main/src/main/java/com/facebook/presto/execution/QueryStateMachine.java b/presto-main/src/main/java/com/facebook/presto/execution/QueryStateMachine.java
index b909d8c410..67578efa87 100644
--- a/presto-main/src/main/java/com/facebook/presto/execution/QueryStateMachine.java
+++ b/presto-main/src/main/java/com/facebook/presto/execution/QueryStateMachine.java
@@ -19,12 +19,14 @@ import com.facebook.presto.client.FailureInfo;
 import com.facebook.presto.execution.StateMachine.StateChangeListener;
 import com.facebook.presto.spi.ErrorCode;
 import com.facebook.presto.spi.PrestoException;
+import com.facebook.presto.sql.planner.plan.TableScanNode;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Predicate;
 import com.google.common.base.Predicates;
 import com.google.common.collect.FluentIterable;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
 import io.airlift.log.Logger;
 import io.airlift.units.DataSize;
 import io.airlift.units.Duration;
@@ -190,7 +192,7 @@ public class QueryStateMachine
                 totalUserTime += stageStats.getTotalUserTime().roundTo(NANOSECONDS);
                 totalBlockedTime += stageStats.getTotalBlockedTime().roundTo(NANOSECONDS);
 
-                if (stageInfo.getSubStages().isEmpty()) {
+                if (Iterables.any(stageInfo.getPlan().getSources(), Predicates.instanceOf(TableScanNode.class))) {
                     rawInputDataSize += stageStats.getRawInputDataSize().toBytes();
                     rawInputPositions += stageStats.getRawInputPositions();
 
['presto-main/src/main/java/com/facebook/presto/execution/QueryStateMachine.java']