Hi Guys

Please let me know if any other ways to typecast as below is throwing error
unable to typecast java.lang Long to Longwritable and same for Double for
Text also in spark -sql  Below piece of code is from hive udf which i am
trying to run in spark-sql




public Object get(Object name) {
          int pos = getPos((String)name);
  if(pos<0) return null;
  String f = "string";
          Object obj= list.get(pos);
  if(obj==null) return null;
  ObjectInspector ins = ((StructField)colnames.get(
pos)).getFieldObjectInspector();
  if(ins!=null) f = ins.getTypeName();
  switch (f) {
    case "double" :  return ((DoubleWritable)obj).get();
            case "bigint" :  return ((LongWritable)obj).get();
            case "string" :  return ((Text)obj).toString();
    default  :  return obj;
  }
}

Reply via email to