    (extract-key-value key record-or-key-value {}))
 
   ([key record-or-key-value {:keys [key-value]}]
-   (let [key (flatten (v/coerce key)) ;; flatten partition key
-         key-value (or (v/coerce key-value nil)
+   (let [key (flatten-key key)
+         key-value (or (flatten-key key-value)
                        (if-not (map? record-or-key-value)
-                         (v/coerce record-or-key-value)
+                         (flatten-key record-or-key-value)
                          (repeat (count key) nil)))
          record (when (map? record-or-key-value)
                   record-or-key-value)

  "remove components from a [key key-value] pair, returning
   a new [key key-value] pair with the components removed"
  [key key-value remove-components]
  (let [kvs (map vector (flatten (v/coerce key)) (v/coerce key-value))
        rcs (set (v/coerce remove-components))
        fkvs (filter (fn [[k v]] (not (contains? rcs k)))
                     kvs)]
    (when (> (count fkvs) 0)
      [(map first fkvs) (map second fkvs)])))

(defn key-equality-clause
  [key key-value]
  (let [key (flatten (v/coerce key))
        key-value (v/coerce key-value)]
    (mapv (fn [k v]
            (if (sequential? v)

  "true if the record contains? keys for all the key components"
  [key record]
  (->> key
       flatten-key
       (map #(contains? record %))
       (every? identity)))
