in Education by
I have data regarding gender of people under 8 columns: mem1;mem2;mem3;mem4;mem5;mem6;mem7;mem8 MALE;FMALE;UNKN;MALE;FMALE;FMALE;MALE;MALE Now I want to find out the frequency of male, fmale, unkn using hive. Something like MALE 4 FMALE 3 UNKN 1 I'm new to Hive but I know we need to use group by. Can someone please help me with the query? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Use Hive Reflect to get the counts. Create table having whole line as one column Use Hive Reflection to count number of occurrence on the column. Example select reflect("org.apache.commons.lang.StringUtils", "countMatches", "MALE;FMALE;UNKN;MALE;FMALE;FMALE;MALE;MALE", "MALE") as Males, reflect("org.apache.commons.lang.StringUtils", "countMatches", "MALE;FMALE;UNKN;MALE;FMALE;FMALE;MALE;MALE", "FEMALE") as females from mytable

Related questions

0 votes
    Is there any way or any command which I can use in command prompt to know the version of Hadoop? Also, how ... the version of Hive? Select the correct answer from above options...
asked Jan 21, 2022 in Education by JackTerrance
0 votes
    I run hive query by java code. Example: "SELECT * FROM table WHERE id > 100" How to export result to hdfs file.a Select the correct answer from above options...
asked Jan 28, 2022 in Education by JackTerrance
0 votes
    Can someone tell me what is metadata? What is the difference between Internal tables and external tables in the hive? Select the correct answer from above options...
asked Jan 21, 2022 in Education by JackTerrance
0 votes
    In the hive, partitioning and bucketing a table, both are done on a column. But how exactly are they different? Select the correct answer from above options...
asked Jan 21, 2022 in Education by JackTerrance
0 votes
    What is the difference between Hadoop, HBase, Hive and Pig? I know the basic Definitions of all these terms, But ... can these be used? Select the correct answer from above options...
asked Jan 20, 2022 in Education by JackTerrance
0 votes
    I have just started with Hadoop. Using Cloudera's Hadoop VM, I worked with Hive, Pig and Hadoop. As I worked, ... we need them both? Select the correct answer from above options...
asked Jan 20, 2022 in Education by JackTerrance
0 votes
    Can anyone tell me what is Hive in Hadoop? Select the correct answer from above options...
asked Jan 11, 2022 in Education by JackTerrance
0 votes
    Can anyone tell me why Hive is used in Hadoop? Select the correct answer from above options...
asked Jan 11, 2022 in Education by JackTerrance
0 votes
    Hi, I am using MapReduce and there are so many steps in it. I want the value of the last reduced step as ... . Thank you in advance. Select the correct answer from above options...
asked Jan 21, 2022 in Education by JackTerrance
0 votes
    I have an image with horizontal and vertical lines. In fact, this image is the BBC website converted to ... rectangle. Thanks! Select the correct answer from above options...
asked Jan 29, 2022 in Education by JackTerrance
0 votes
    I am new to TensorFlow. While I am reading the existing documentation, I found the term tensor really confusing. ... types of tensors? Select the correct answer from above options...
asked Jan 29, 2022 in Education by JackTerrance
0 votes
    I would like to know is there any command/expression to get only the file name in hadoop. I need to fetch only the ... cut -d ' ' -f17 Select the correct answer from above options...
asked Jan 28, 2022 in Education by JackTerrance
0 votes
    I have uploaded a Directory to hadoop cluster that is having "," in its name like "MyDir, Name" when I ... such kind of Directories. Select the correct answer from above options...
asked Jan 28, 2022 in Education by JackTerrance
0 votes
    I want to put my Results of a hiveql query into a CSV file. How can I do it? I tried doing this, but ... select goods from the table; Select the correct answer from above options...
asked Jan 21, 2022 in Education by JackTerrance
0 votes
    I tried moving the files using WinSCP, but it didn't help. So, I wanna know how can I copy files from ... local computer file system. Select the correct answer from above options...
asked Jan 21, 2022 in Education by JackTerrance
...