Package org.apache.pig.builtin

Examples of org.apache.pig.builtin.BagToString.exec()


  @Test
  public void testNullInputBagToStringUDF() throws Exception {
    BagToString udf = new BagToString();
    Tuple udfInput = tf.newTuple(1);
    udfInput.set(0, null);
    String output = udf.exec(udfInput);
    assertNull(output);
  }

  @Test(expected=org.apache.pig.backend.executionengine.ExecException.class)
  public void testInvalidInputForBagToStringUDF() throws Exception {
View Full Code Here


    // input contains tuple instead of bag
    udfInput.set(0, tf.newTuple());
    BagToString udf = new BagToString();

    // expecting an exception because the input if of type Tuple, not DataBag
    udf.exec(udfInput);
  }

  @Test
  public void testUseDefaultDelimiterBagToStringUDF() throws Exception {
    BagFactory bf = BagFactory.getInstance();
View Full Code Here

    bag.add(t2);

    BagToString udf = new BagToString();
    Tuple udfInput = tf.newTuple(1);
    udfInput.set(0, bag);
    String result = udf.exec(udfInput);

    assertEquals("a_5_c_6", result);
  }

  @Test
View Full Code Here

    BagToString udf = new BagToString();
    Tuple udfInput = tf.newTuple(2);
    udfInput.set(0, bag);
    udfInput.set(1, "-");
    String result = udf.exec(udfInput);

    assertEquals("a-5-c-6", result);
  }

  @Test
View Full Code Here

    BagToString udf = new BagToString();
    Tuple udfInput = tf.newTuple(2);
    udfInput.set(0, inputBag);
    udfInput.set(1, "_");
    String result = udf.exec(udfInput);

    assertEquals("a_5_c_6_(d,7)", result);
  }

  @Test
View Full Code Here

    BagToString udf = new BagToString();
    Tuple udfInput = tf.newTuple(2);
    udfInput.set(0, inputBag);
    udfInput.set(1, "*");

    String result = udf.exec(udfInput);
    assertEquals("a*5*c*6*(d,7)*{(in bag,10)}", result);
  }


  @Test(expected=java.lang.RuntimeException.class)
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.