You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pig.apache.org by George Pang <p0...@gmail.com> on 2009/05/22 06:49:07 UTC
JDBC for pig
Something I am looking is actually something like JDBC for pig.
Any idea?
George
Re: JDBC for pig
Posted by zhang jianfeng <zj...@gmail.com>.
You want to load data from jdbc and feed it to pig ?
if that's your goal, you should provide your own Load Func
On Fri, May 22, 2009 at 12:49 PM, George Pang <p0...@gmail.com> wrote:
> Something I am looking is actually something like JDBC for pig.
> Any idea?
>
> George
>
Re: JDBC for pig
Posted by Thejas Nair <te...@yahoo-inc.com>.
Are you looking for an iterator over the results ? Pig has one, but looks
like it is not documented.
Example - (modifying the example in
http://hadoop.apache.org/pig/docs/r0.2.0/quickstart.html)
idhadoop.java
import java.io.IOException;
import org.apache.pig.PigServer;
public class idhadoop {
public static void main(String[] args) {
try {
PigServer pigServer = new PigServer("mapreduce");
runIdQuery(pigServer, "passwd");
}
catch(Exception e) {
}
}
public static void runIdQuery(PigServer pigServer, String inputFile) throws
IOException {
pigServer.registerQuery("A = load '" + inputFile + "' using
PigStorage(':');")
pigServer.registerQuery("B = foreach A generate $0 as id:chararray ;");
// pigServer.store("B", "idout");
Iterator<Tuple> iter = pigServer.openIterator("B");
while(iter.hasNext()){
Tuple t = iter.next();
String uid = t.get(0);
}
}
}
On 5/21/09 9:49 PM, "George Pang" <p0...@gmail.com> wrote:
> Something I am looking is actually something like JDBC for pig.
> Any idea?
>
> George