     aggregate count of places
     filter = liked false))
 
-(defn- int->bool [x]
-  (condp = x
-    0 false
-    1 true
-      x))
+(defn- ->bool [x] ; SQLite returns 0/1 for false/true;
+  (condp = x      ; Redshift returns nil/true.
+    0   false     ; convert to false/true and restore sanity.
+    1   true
+    nil false
+    x))
 
 ;;; filter = true
 (datasets/expect-with-all-engines

  "Format the values in result ROWS with the fns at the corresponding indecies in FORMAT-FNS.
   ROWS can be a sequence or any of the common map formats we expect in QP tests.

     (format-rows-by [int str double] [[1 1 1]]) -> [[1 \"1\" 1.0]]"
  [format-fns rows]
  (cond
    (:data rows) (update-in rows [:data :rows] (partial format-rows-by format-fns))
    (:rows rows) (update    rows :rows         (partial format-rows-by format-fns))
    :else        (vec (for [row rows]
                        (vec (for [[f v] (partition 2 (interleave format-fns row))]
                               (when v
                                 (f v))))))))

(def ^:private formatted-venues-rows (partial format-rows-by [int str int (partial u/round-to-decimals 4) (partial u/round-to-decimals 4) int]))


  (Q dataset places-cam-likes
     aggregate rows of places
     filter != liked false, order id+
     return rows (format-rows-by [int ->bool str] :format-nil-values)))

;;; filter != true
(datasets/expect-with-all-engines
