Member since
03-21-2018
2
Posts
0
Kudos Received
0
Solutions
11-19-2020
10:13 AM
You can use an expression incited of a query. in the expression , your query should be something like this. =" SELECT A.COL1 , A. COL2 FROM schema.tableName A WHERE A.COL1 = '" & Parameters!parameterName.Value & "' " Notice the Quotation marks besides the parameter ( " , ' ) and equal ( = ) sign at the beginning You should create fields manually( Use query designer without parameters and let SSRS do the Refresh Fields task)
... View more
07-16-2019
12:06 PM
try it by removing the evaluate(),forward() and getDisplay() methods. Also , extend from class GenericUDTF, if you are writing a UDTF. hope this helps.Refer to below working code. package org.kp.atg; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.apache.hadoop.hive.ql.exec.UDFArgumentException; import org.apache.hadoop.hive.ql.metadata.HiveException; import org.apache.hadoop.hive.ql.udf.generic.GenericUDTF; import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector; import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorFactory; import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; import org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector; import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; public class GenericWhereUDTF extends GenericUDTF { private PrimitiveObjectInspector stringOI = null; @Override public StructObjectInspector initialize(ObjectInspector[] args) throws UDFArgumentException { if (args.length != 1) { throw new UDFArgumentException("GenericWhereUDTF() takes exactly one argument"); } if (args[0].getCategory() != ObjectInspector.Category.PRIMITIVE && ((PrimitiveObjectInspector) args[0]).getPrimitiveCategory() != PrimitiveObjectInspector.PrimitiveCategory.STRING) { throw new UDFArgumentException("GenericWhereUDTF() takes a string as a parameter"); } // input inspectors stringOI = (PrimitiveObjectInspector) args[0]; // output inspectors -- an object with three fields! List<String> fieldNames = new ArrayList<String>(2); List<ObjectInspector> fieldOIs = new ArrayList<ObjectInspector>(2); fieldNames.add("id"); fieldNames.add("loc_number"); fieldOIs.add(PrimitiveObjectInspectorFactory.javaStringObjectInspector); fieldOIs.add(PrimitiveObjectInspectorFactory.javaStringObjectInspector); return ObjectInspectorFactory.getStandardStructObjectInspector(fieldNames, fieldOIs); } public ArrayList<Object[]> processInputRecord(String id) { ArrayList<Object[]> result = new ArrayList<Object[]>(); // ignoring null or empty input if (id == null || id.isEmpty()) { return result; } String[] tokens = id.split("\\s+"); if (tokens.length == 2) { result.add(new Object[] { tokens[0], tokens[1] }); } else if (tokens.length == 3) { result.add(new Object[] { tokens[0], tokens[1] }); result.add(new Object[] { tokens[0], tokens[2] }); } return result; } @Override public void close() throws HiveException { // TODO Auto-generated method stub } @Override public void process(Object[] record) throws HiveException { // final String name = stringOI.getPrimitiveJavaObject(record[0]).toString(); //ArrayList<Object[]> results = processInputRecord(name); ArrayList<Object[]> results = new ArrayList<Object[]>(); results.add(new Object[] { "123", "value1" }); results.add(new Object[] { "111", "value2" }); results.add(new Object[] { "111", "value3" }); Iterator<Object[]> it = results.iterator(); while (it.hasNext()) { Object[] r = it.next(); forward(r); } } }
... View more