spark-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex <>
Subject alternatives for long to longwritable typecasting in spark sql
Date Tue, 31 Jan 2017 07:32:44 GMT
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(
  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;

View raw message