csv-serde/readme.md

66 lines
1.6 KiB
Markdown
Raw Permalink Normal View History

2010-11-13 06:35:42 +05:30
# Hive CSV Support
2010-11-13 06:33:34 +05:30
2013-10-31 00:35:23 +05:30
[![Build Status](https://drone.io/github.com/ogrodnek/csv-serde/status.png)](https://drone.io/github.com/ogrodnek/csv-serde/latest)
2010-11-13 06:33:34 +05:30
2013-10-31 00:35:23 +05:30
This SerDe adds *real* CSV input and ouput support to hive using the excellent [opencsv](http://opencsv.sourceforge.net/) library.
2010-11-13 06:33:34 +05:30
2013-10-31 00:35:23 +05:30
## Using
### Basic Use
```
add jar path/to/csv-serde.jar;
create table my_table(a string, b string, ...)
row format serde 'com.bizo.hive.serde.csv.CSVSerde'
stored as textfile
;
```
### Custom formatting
The default separator, quote, and escape characters from the `opencsv` library are:
```
DEFAULT_ESCAPE_CHARACTER \
DEFAULT_QUOTE_CHARACTER "
DEFAULT_SEPARATOR ,
```
2013-10-31 00:35:23 +05:30
You can also specify custom separator, quote, or escape characters.
```
add jar path/to/csv-serde.jar;
create table my_table(a string, b string, ...)
row format serde 'com.bizo.hive.serde.csv.CSVSerde'
with serdeproperties (
"separatorChar" = "\t",
"quoteChar" = "'",
"escapeChar" = "\\"
)
stored as textfile
;
```
## Files
2013-10-31 01:35:21 +05:30
The following include opencsv along with the serde, so only the single jar is needed. Currently built against Hive 0.11.0, but should be compatible with other hive versions.
2013-10-31 00:35:23 +05:30
2013-10-31 01:35:21 +05:30
* [csv-serde-1.1.2-0.11.0-all.jar](https://drone.io/github.com/ogrodnek/csv-serde/files/target/csv-serde-1.1.2-0.11.0-all.jar)
2013-10-31 00:35:23 +05:30
## Building
Run `mvn package` to build. Both a basic artifact as well as a "fat jar" (with opencsv) are produced.
2013-10-31 01:03:08 +05:30
### Eclipse support
Run `mvn eclipse:eclipse` to generate `.project` and `.classpath` files for eclipse.
2013-10-31 00:35:23 +05:30
## License
csv-serde is open source and licensed under the [Apache 2 License](http://www.apache.org/licenses/LICENSE-2.0.html).