Select statement in hive return some columns with null value

Previnkumar

I have seen this type of questions were asked many times, but those solutions not worked for me. I created a external hive table, since i had the data is from map-only job output. Then, by load command i given the path for the specific file. It showed ok. But when i give select * from table command it returns some column with null values. Each command i have executed is in the error pic.

My delimiter in file is ||, so i mentioned the same in create table command too.

Here is my input file pic file pic. And here is the error pic . I have also tried a normal table instead of external table. That too showed the same error. I also tried by mentioning delimiter as //|| and also \|\|. But none worked.

Ambrish

The problem that you are facing is related to multiple characters as FIELD delimiter.

According to documentation FIELD delimiter should be a CHAR

row_format
  : DELIMITED [FIELDS TERMINATED BY char [ESCAPED BY char]] [COLLECTION ITEMS TERMINATED BY char]
        [MAP KEYS TERMINATED BY char] [LINES TERMINATED BY char]
        [NULL DEFINED AS char]   -- (Note: Available in Hive 0.13 and later)

You need to change your data to have only single char field delimiter.

If you can not do that then the other approach is to use stage table with single field. Load your data to that table and then in your actual target table, split the column in stage table by || delimiter and then insert. You need to make sure that field counts are consistent in the data otherwise your final output will be off.

Reference: https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-CreateTableCreate/Drop/TruncateTable

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Select statement to return one value or another one if the first one is null

Select statement return if there is a value and if there is no value

how to select some columns with null or empty rows

Can I create a table with columns named similar to field value of another table, return by SELECT statement

PHP MySQL SELECT statement return null

MySQL Return the first non-NULL value from the list of the column in select statement with column name

SQL statement select columns with specific value

Select all columns greater than some value

Why does count( distinct ) with NULL columns return 0 in Hive SQL?

Return the value of if statement in case when it's not null

how to store a select statement return value in a variable

Return Boolean Value on SQL Select Statement

select statement to return value from a different row

nodejs mysql query return value of select statement

Some value return null on Dapper Multi Mapping

Run Second Select statement if the first SQL statement return NULL(or nothing)

SQL statement to return Null values for multiple columns if no rows found

oledb excel some date-columns return null

How to concatenate two columns that might contain NULL values in a select statement?

Using a SQL SELECT * Insert Into Statement But With Missing Columns Being Null

Insert into select statement that sets all other columns to null

How to assing a value to a variable with NULL value in SELECT INTO statement?

SQL select statement that checks two columns and returns the value from a third

Inserting rows in sql table problem, some columns inserted NULL value

select from multipe tables join return null if columns not match

Entity Framework select multiple columns and return the one that is not null

Select Statement with rows as columns

want to store return value of sql select statement in c#

use Table valued function return value in select statement