Uploaded image for project: 'Pig'
  1. Pig
  2. PIG-2650

Convenience mock Loader and Storer to simplify unit testing of Pig scripts

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 0.11, 0.10.1
    • None
    • None
    • Patch Available

    Description

      A test would look as follows:

      PigServer pigServer = new PigServer(ExecType.LOCAL);
      TupleFactory tf = TupleFactory.getInstance();
      Data data = Storage.resetData(pigServer.getPigContext());
      data.set("foo", Arrays.asList(
          tf.newTuple("a"),
          tf.newTuple("b"),
          tf.newTuple("c")
          ));
      
      pigServer.registerQuery("A = LOAD 'foo' USING mock.Storage();");
      // some complex script to test
      pigServer.registerQuery("STORE A INTO 'bar' USING mock.Storage();");
      
      Iterator<Tuple> out = data.get("bar").iterator();
      assertEquals("a", out.next().get(0));
      assertEquals("b", out.next().get(0));
      assertEquals("c", out.next().get(0));
      

      Attachments

        1. PIG-2650.patch
          12 kB
          Julien Le Dem
        2. PIG-2650-a.patch
          12 kB
          Julien Le Dem
        3. PIG-2650-b.patch
          17 kB
          Julien Le Dem
        4. PIG-2650-c.patch
          19 kB
          Julien Le Dem

        Activity

          People

            julienledem Julien Le Dem
            julienledem Julien Le Dem
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: