Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]
Created on 03-31-2017 03:01 PM - edited 09-16-2022 04:23 AM
I sqooped serveral tables from DB2 to hadoop HDFS. The data landed fine. I created hive tables using the following format(follows an example table create):
-- CCCE_APL
CREATE EXTERNAL TABLE IF NOT EXISTS ccce_apl_csv(
APL_LNK INT,
UPDT_DTTM CHAR(26),
UPDT_USER CHAR(8),
RLS_ORDR_MOD_CD CHAR(12),
RLS_ORDR_MOD_TXT VARCHAR(255) )
ROW FORMAT DELIMITED
STORED AS TEXTFILE
location '/hdfs/data-lake/master/criminal/csv/ccce_apl';
The table is successfully created. Now when I excute the following query(select * from ccce_apl_csv) in Hue, I only see NULLs in all the cols:
crct_cs_csv.cs_lnk crct_cs_csv.yr crct_cs_csv.tp crct_cs_csv.seq crct_cs_csv.cnty_geo_lnk crct_cs_csv.updt_user crct_cs_csv.updt_dttm crct_cs_csv.num_gnrtn_cd crct_cs_csv.inttng_doc_lnk
| 1 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL |
| 2 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL |
| 3 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL |
| 4 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL |
| 5 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL |
| 6 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL |
Any Ideas what went wrong. Again the data on HDFS looks fine, below sample data:
Created 04-03-2017 07:53 AM
Your comment gave me the clue, when I generated the script, I missed the statment that follows: ROW FORMAT DELIMITED, namely, -FIELDS TERMINATED BY ','. So the correct create statement would be:
CREATE EXTERNAL TABLE IF NOT EXISTS ccce_apl(
APL_LNK INT,
UPDT_DTTM CHAR(26),
UPDT_USER CHAR(8),
RLS_ORDR_MOD_CD CHAR(12),
RLS_ORDR_MOD_TXT VARCHAR(255) )
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
STORED AS TEXTFILE
location '/hdfs/data-lake/master/criminal/csv/ccce_apl';
Thanks.
Created 04-01-2017 05:30 AM
Hi imad87,
What is the purpose of specifying "ROW FORMAT DELIMITED" without a delimiter character?
On first glance it looks like your data file contains the substring "\N" (the \ character followed by the N character) to delimit lines, instead of the "\n" character (ASCII 0xA). Can you double check the file in a hex editor?
Cheers, Lars
Created 04-03-2017 07:53 AM
Your comment gave me the clue, when I generated the script, I missed the statment that follows: ROW FORMAT DELIMITED, namely, -FIELDS TERMINATED BY ','. So the correct create statement would be:
CREATE EXTERNAL TABLE IF NOT EXISTS ccce_apl(
APL_LNK INT,
UPDT_DTTM CHAR(26),
UPDT_USER CHAR(8),
RLS_ORDR_MOD_CD CHAR(12),
RLS_ORDR_MOD_TXT VARCHAR(255) )
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
STORED AS TEXTFILE
location '/hdfs/data-lake/master/criminal/csv/ccce_apl';
Thanks.