reassigning outfields on a query

40 views
Skip to first unread message

Andy Xue

unread,
Nov 14, 2012, 1:36:33 PM11/14/12
to cascal...@googlegroups.com
hi - i have a little utility function to re assign the outfields on a query

one way is this:

(defn re-var [query new-vars]
  (<- new-vars (query :>> new-vars) (:distinct false)))

another is:

(defn re-var2 [query new-vars]}
  (assoc query :outfields new-vars))

they both work it seems but i wonder if there is something subtly different between the two that make one better than the other?

thanks
andy

Sam Ritchie

unread,
Nov 14, 2012, 4:40:23 PM11/14/12
to cascal...@googlegroups.com
The internal ":outfields" keyword is an implementation detail that might change down the road, while the first one uses the Cascalog DSL, so will stay functional. (Btw, distinct is false by default now, so no need for that predicate.)
--
Sam Ritchie, Twitter Inc
@sritchie

(Too brief? Here's why! http://emailcharter.org)

Andy Xue

unread,
Nov 16, 2012, 1:58:18 PM11/16/12
to cascal...@googlegroups.com
cool thanks -- makes a lot of sense. although it does bring up an interesting point; i use :outfields a lot to get out the vars from a query -- typically use this often when i am trying to chain up a bunch of queries together. i wonder of there is a better way to do it, some kind of (get-outfields query) type function. 

Paul Lam

unread,
Nov 17, 2012, 3:19:22 AM11/17/12
to cascal...@googlegroups.com
there're (get-out-fields) and (name-vars) already

Andy Xue

unread,
Nov 28, 2012, 11:59:49 AM11/28/12
to cascal...@googlegroups.com
perfect!
Reply all
Reply to author
Forward
0 new messages