March 10, 2013 12:57 PM
Hi Paul, thank you for the tips, I surprisingly got this working as I
never worked with macros before:
(defmacro dynamic_test
[columns predicates]
`(let [fields# (clojure.string/split ~columns #"\s+")
tap# (lfs-textline "/mnt/hadoop/data/users.json")
users# (<- (fields_with_?s fields#)
(tap# ?line)
(user_data_parser :line ?line :fields fields# :>>
(fields_with_?s fields#))
~(read-string predicates)
)
]
(?- (stdout) users#)
)
)
I did play around with the 2nd method a little,but was unable to get
that to work.
March 10, 2013 12:39 AM
eval wouldn't work because the query itself is generated from macros. a couple solutions. 1) make dynamic_test a macro; or 2) refactor filter_predicates so you pass in the predicate func and field name each as its own argument from dynamic_test without having to use eval. something like this:(defn dynamic-test [vars pred field](...)(pred field))(dynamic-test my-vars (partial <= 42) "?id")
I am not sure about #2 though because of field. Give it a go and let us know how it goes.
On Sunday, 10 March 2013 00:46:12 UTC, toy wrote:
--
You received this message because you are subscribed to the Google Groups "cascalog-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cascalog-use...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
March 9, 2013 4:46 PM
cascading.flow.stack.EachMapperStackElement.collect(EachMapperStackElement.java:
at clojure.lang.AFn.applyToHelper(AFn.java:161)
at clojure.lang.Var.applyTo(Var.java:482)
at
cascalog.ClojureCascadingBase.applyFunction(ClojureCascadingBase.java:
67)
... 72 more
Caused by: java.lang.Exception: Unable to resolve symbol: ?id in this
context
at clojure.lang.Compiler.resolveIn(Compiler.java:5677)
at clojure.lang.Compiler.resolve(Compiler.java:5621)
at clojure.lang.Compiler.analyzeSymbol(Compiler.java:5584)
at clojure.lang.Compiler.analyze(Compiler.java:5172)
... 93 more