Skip to content

Commit 84530cd

Browse files
committed
added UUID support
1 parent 9ec274f commit 84530cd

5 files changed

Lines changed: 21 additions & 5 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
target
22
*.csv
3+
*.json
34
private-data
45

56
tmp/

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "verticareader"
3-
version = "1.3.0"
3+
version = "1.4.0"
44
authors = ["Joey Gibson <joey@joeygibson.com>"]
55
edition = "2018"
66
description = "A program to read Vertica native binary files and convert them to CSV."

src/column_type.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ use std::result::Result;
55

66
use chrono::prelude::*;
77
use chrono::Duration;
8+
use lazy_static::lazy_static;
89
use regex;
910
use regex::Regex;
10-
11-
use lazy_static::lazy_static;
11+
use uuid::Uuid;
1212

1313
use crate::column_conversion::ColumnConversion;
1414

@@ -28,6 +28,7 @@ pub enum ColumnType {
2828
Binary,
2929
Numeric,
3030
Interval,
31+
UUID,
3132
}
3233

3334
impl ColumnType {
@@ -53,6 +54,7 @@ impl ColumnType {
5354
"binary" => ColumnType::Binary,
5455
"numeric" => ColumnType::Numeric,
5556
"interval" => ColumnType::Interval,
57+
"uuid" => ColumnType::UUID,
5658
_ => return Err(format!("invalid type: {}", string.clone())),
5759
};
5860

@@ -219,6 +221,18 @@ impl ColumnType {
219221

220222
format!("{:02}:{:02}:{:02}", hours, minutes, remainder)
221223
}
224+
ColumnType::UUID => {
225+
let tmp_bytes = &value[..];
226+
let mut bytes = [0; 16];
227+
228+
for i in 0..15 {
229+
bytes[i] = tmp_bytes[i];
230+
}
231+
232+
let uuid = Uuid::from_bytes(bytes);
233+
234+
format!("{}", uuid)
235+
}
222236
}
223237
}
224238
_ => "".to_string(),

src/vertica_native_file.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ impl Row {
168168
| ColumnType::TimeTz
169169
| ColumnType::Varbinary
170170
| ColumnType::Binary
171-
| ColumnType::Interval => Value::String(value),
171+
| ColumnType::Interval
172+
| ColumnType::UUID => Value::String(value),
172173
ColumnType::Boolean => Value::Bool(value == "true"),
173174
};
174175

0 commit comments

Comments
 (0)