Comments (7)
This just means that you can't close over a compiled function. For example:
(require '[simple-time.core :as st]))
;; works
(defn format-ts [data]
(pig/map (fn [x] (st/format x :date)) data))
(format-ts my-data)
;; works
(defn format-ts [data format]
(pig/map (fn [x] (st/format x format)) data))
(format-ts my-data :date)
;; won't work because f is compiled
(defn format-ts [data f]
(pig/map f data))
(format-ts my-data (fn [x] (st/format x :date)))
There is a way around this, but it's not officially supported yet:
(defn format-ts [data f]
(pigpen.map/map* f data))
(format-ts my-data (pigpen.code/trap (fn [x] (st/format x :date))))
Let me know if that's not clear or if you have a specific example of what you're trying to do.
Also, check out [email protected] or https://groups.google.com/forum/#!forum/pigpen-support for future questions.
from pigpen.
I still get CompilerException java.lang.RuntimeException: No such namespace: st
in cases that meant to be working :\
from pigpen.
Could you send a code sample and stack trace that you get?
from pigpen.
Might be worth mentioning - any code that you close over needs to be in a file that will end up in the uberjar that goes to hadoop. If you're just in a user ns in a repl, the code I listed won't work.
If that's the case, let me know if that's not clear from the docs & I can update them.
from pigpen.
I've spotted that it behaves differently when using pig/return
and loading data from files (same for JSON and Avro). This works just fine:
(require '[simple-time.core :as st])
(defn time->ymd
[data]
(pig/map (fn [entry]
(assoc entry
:ymd (st/format (st/datetime (:time entry)) :date)))
data))
(->> (pig/return [{:time 1425254400010} {:time 1425254400019} {:time 1425254400090}])
(time->ymd)
(pig/dump))
; [{:ymd "2015-03-02", :time 1425254400010}
; {:ymd "2015-03-02", :time 1425254400019}
; {:ymd "2015-03-02", :time 1425254400090}]
For JSON:
(spit "/tmp/events.json" "{\"time\": 1425254400010}\n{\"time\": 1425254400019}\n{\"time\": 1425254400090}")
(->> (pig/load-json "/tmp/events.json")
(time->ymd)
(pig/dump))
CompilerException java.lang.RuntimeException: No such namespace: st
Same error while using Avro.
from pigpen.
Yeah, it sounds like you're in a user ns. This complete example works for me:
(ns pigpen-demo.core
(:require [pigpen.core :as pig]
[simple-time.core :as st]))
(defn time->ymd
[data]
(pig/map (fn [entry]
(assoc entry
:ymd (st/format (st/datetime (:time entry)) :date)))
data))
(clojure.pprint/pprint
(->> (pig/return [{:time 1425254400010} {:time 1425254400019} {:time 1425254400090}])
(time->ymd)
(pig/dump)))
(spit "/tmp/events.json" "{\"time\": 1425254400010}\n{\"time\": 1425254400019}\n{\"time\": 1425254400090}")
(clojure.pprint/pprint
(->> (pig/load-json "/tmp/events.json")
(time->ymd)
(pig/dump)))
and produces this output:
[{:ymd "2015-03-01", :time 1425254400010}
{:ymd "2015-03-01", :time 1425254400019}
{:ymd "2015-03-01", :time 1425254400090}]
Start reading from /tmp/events.json
Stop reading from /tmp/events.json
[{:ymd "2015-03-01", :time 1425254400010}
{:ymd "2015-03-01", :time 1425254400019}
{:ymd "2015-03-01", :time 1425254400090}]
nil
If you're in a file & still getting that exception, could you run these commands in the REPL and let me know what you get?
(pigpen.code/trap identity)
(ns-name *ns*)
(pigpen.code/ns-exists *1)
from pigpen.
You're right — everything works fine when running from file and being not in a user namespace. Thank you for lightning fast and correct diagnosis!
Next time I'll use mailgroup. Sorry!
from pigpen.
Related Issues (20)
- Strange behavior of count distinct HOT 2
- Add support for distributed cache on the Cascading platform
- Release HOT 2
- Cascading: Optimize co-group with all folds
- Cascading: Add docs & tutorial
- Cascading: Update parquet and avro storage to work with cascading
- CUBE/ROLLUP in PigPen HOT 2
- Should locally executed load functions support compression? HOT 2
- Weird error when used with prismatic plumbing HOT 13
- Use cascading-hadoop2-mr1 by default HOT 10
- allow custom properties to be passed to FlowConnector when creating a flow HOT 2
- Add a pigpen.pig/dump command
- Tutorial error: Pig version 0.12.0-cdh5.4.2,0.14 is right. HOT 5
- Hadoop Versions lists hadoop-client twice in dependencies. HOT 1
- clojure.lang.ExceptionInfo: :auto not supported on headerless data. {} HOT 17
- pigpen.core store functions don't quite work HOT 2
- Incorrect script generation with large number of fields (parquet) HOT 4
- Doc CSS is broken HOT 1
- Is this project being maintained? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pigpen.