Posts

Showing posts with the label hiveql

Remove leading zeros using HiveQL

Image
Clash Royale CLAN TAG #URR8PPP Remove leading zeros using HiveQL I have a string value in which i might have leading zero's, so i want to remove all leading zeros. For example: accNumber = "000340" ---> "340" Any UDF is available in Hive? can we use regexp_extract for this? regexp_extract 1 Answer 1 Yes, just use REGEXP_REPLACE() . REGEXP_REPLACE() SELECT some_string, REGEXP_REPLACE(some_string, "^0+", '') stripped_string FROM db.tbl (fixed simple typo with comma) didn't know it. Thanks – syadav Jul 3 '16 at 6:51 By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and...

How to do a row wise count in Hive

Image
Clash Royale CLAN TAG #URR8PPP How to do a row wise count in Hive h1 h2 h3 h4 h5 h6 h7 h8 U U NULL U Y NULL Y X U NULL U U Y Y X X U U U NULL U NULL Y NULL NULL NULL NULL NULL NULL NULL NULL NULL X V U U Y NULL Z X Y X NULL X Y Z U X NULL U NULL NULL U Z Y NULL NULL NULL NULL NULL NULL NULL NULL Suppose, above data set is having 8 column h1,h2,h3......h8. if all the all the column is having NULL then the count is 0. if at least one column is having value then the count is 1. like first row has a count of 6.(donot consider null values). so, if a first row has 6 value then its count is 6 and next row has count of 7 and the last row has no value. so in this case the total count is 2 because only two row has information or values. because two row has values. just tell me the code how do i count those eight column values row wise?? i am confused s...

Unable to create temp file for insert values in hive

Image
Clash Royale CLAN TAG #URR8PPP Unable to create temp file for insert values in hive I have installed hive 1.2 in a Linux server and started metastore successfully when I am inserting data in a table I am getting below error.Please suggest some solution. /oradata_iscsi/hive/bin>hive ls: cannot access /oradata_iscsi/spark/lib/spark-assembly-*.jar: No such file or directory Logging initialized using configuration in jar:file:/oradata_iscsi/hive/lib/hive-common-1.2.0.jar!/hive-log4j.properties hive> Insert into test values(1); FAILED: SemanticException [Error 10293]: Unable to create temp file for insert values File /tmp/hive/ora12c/6a9e3ee7-620f-476c-939c-64a49c6a0a7e/_tmp_space.db/Values__Tmp__Table__1/data_file could only be replicated to 0 nodes instead of minReplication (=1). There are 1 datanode(s) running and no node(s) are excluded in this operation. at org.apache.hadoop.hdfs.server.blockmanagement.BlockManager.chooseTarget4NewBlock(BlockManager.java:1559) at...