to create new topics or reply. | New User Registration

This topic contains 1 reply, has 1 voice, and was last updated by  Andy Kruth 1 year, 7 months ago.

  • Creator
  • #45709

    Andy Kruth


    SAMPLE works great to get a small sample returned from a data relation, but does it work on grouped data inside of a FOREACH? Here is my script, my data is just a row file with field delimiters.

    This SAMPLE usage works just fine:

    data = load '/user/akruth/data.txt' using PigStorage('^') as (... Metro:chararray...);
    samples = sample data 0.1;
    dump samples;

    But say I want to do something like this:

    data = load '/user/akruth/data.txt' using PigStorage('^') as (... Metro:chararray... );
    grouped = group data by Metro;
    samples = foreach grouped {
    s = sample data 0.1;
    generate group as metro, s as sample;

    I get this error: exception during parsing: Error during parsing. mismatched input ‘data’ expecting LEFT_PAREN
    The line number corresponds to this line: s = sample data 0.1;

    I think the culprit is the data structrue that is going in to SAMPLE but I don’t understand it well enough to fix it.

    Here are some describes:
    describe data;
    This works –> data: {…Metro:chararray…}

    describe grouped
    This doesn’t –> grouped: {group: chararray, data: {(…Metro:chararray…)}

    I think the key to the problem is the parentheses but I’m not sure what that means.

Viewing 1 replies (of 1 total)

You must be to reply to this topic. | Create Account

  • Author
  • #45713

    Andy Kruth

    Also, received this question from colleagues:

    “Why not just group AFTER doing the top level sampling.”

    My answer is that by doing that you are not guaranteed getting an even sample (or any sampling at all) for each possible Metro value.

    The use case here is to find all possible Metro values in the data set, then get an even sampling of data for each.


Viewing 1 replies (of 1 total)
Hortonworks Data Platform
The Hortonworks Data Platform is a 100% open source distribution of Apache Hadoop that is truly enterprise grade having been built, tested and hardened with enterprise rigor.
Get started with Sandbox
Hortonworks Sandbox is a self-contained virtual machine with Apache Hadoop pre-configured alongside a set of hands-on, step-by-step Hadoop tutorials.
Modern Data Architecture
Tackle the challenges of big data. Hadoop integrates with existing EDW, RDBMS and MPP systems to deliver lower cost, higher capacity infrastructure.