Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Plain View
Hive >> mail # user >> substr() index out of range exception in hive 0.8.1


Copy link to this message
-
substr() index out of range exception in hive 0.8.1
Hi All,

I'm working on hive 0.8.1. and meet following problem.
I use function substr(item,-4,1) to process one item in hive table, and
there is one row in which the content of the item is
"ba_s0一朝忽觉京梦醒,半世浮沉雨打萍--衣俊卿小n实录010", then the job failed.
 I checked the task log, it appeared

java.lang.StringIndexOutOfBoundsException: String index out of range

Then I tried this program on my PC,

============================================
//test substring()

public class substrtest {

 public static void main(String args[]){
  String s="ba_s0一朝忽觉京梦醒,半世浮沉雨打萍--衣俊卿小n实录010";
  int len=s.length();
  System.out.println(len);
  String r=s.substring(28, 29);
  System.out.println(r);
 }
}
======================================
It worked. So I am confused why hive gave me index out of range exception.

can anyone help?
+
曹坤 2013-01-25, 06:09
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB