- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
how to load double quotes data of fields in hive table without excluding double quotes?
- Labels:
-
Apache Hive
Created 03-12-2024 10:57 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can I know the working table property for splitting the records as shown below.
Input field - 123,"456","INDIA","INDIA",789,"DELHI INDIA, PIN. North INDIA","101","NEW Delhi ","LOCATION"
Expected hive output("|" indicates split) - 123 | "456" | "INDIA" | "INDIA" | 789 | "DELHI INDIA, PIN. North INDIA" | "101" | "NEW Delhi " | "LOCATION"
Created 03-14-2024 06:29 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try this:
CREATE external TABLE mytable (
col1 INT,
col2 STRING,
col3 STRING,
col4 STRING,
col5 INT,
col6 STRING,
col7 STRING
...
)
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.OpenCSVSerde'
WITH SERDEPROPERTIES (
"separatorChar" = ",",
"quoteChar" = "\""
)
STORED AS TEXTFILE;
It should work.
Created 03-12-2024 04:50 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@yashwanth Welcome to the Cloudera Community!
To help you get the best possible solution, I have tagged our Hive experts @abathla @Shmoo who may be able to assist you further.
Please keep us updated on your post, and we hope you find a satisfactory solution to your query.
Regards,
Diana Torres,Community Moderator
Was your question answered? Make sure to mark the answer as the accepted solution.
If you find a reply useful, say thanks by clicking on the thumbs up button.
Learn more about the Cloudera Community:
Created 03-12-2024 11:56 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@yashwanth It seems like you want to separate columns based on the position of comma.
In that case, you may create the table as follows:
CREATE TABLE my_table (
col1 STRING,
col2 INT,
...
)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ',' ...
Created 03-13-2024 08:53 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Smruti,
Thanks for your reply, I want the property in a way that ',' within double quotes should not split and the fields which are not having ',' inside double quotes should be splitted.
Created 03-14-2024 06:29 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try this:
CREATE external TABLE mytable (
col1 INT,
col2 STRING,
col3 STRING,
col4 STRING,
col5 INT,
col6 STRING,
col7 STRING
...
)
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.OpenCSVSerde'
WITH SERDEPROPERTIES (
"separatorChar" = ",",
"quoteChar" = "\""
)
STORED AS TEXTFILE;
It should work.
Created 03-18-2024 02:56 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@yashwanth Has the reply helped resolve your issue? If so, please mark the appropriate reply as the solution, as it will make it easier for others to find the answer in the future. Thanks.
Regards,
Diana Torres,Community Moderator
Was your question answered? Make sure to mark the answer as the accepted solution.
If you find a reply useful, say thanks by clicking on the thumbs up button.
Learn more about the Cloudera Community:
