Skip to content
This repository has been archived by the owner on Nov 28, 2018. It is now read-only.

Commit

Permalink
More date formats
Browse files Browse the repository at this point in the history
  • Loading branch information
Seshu Pasam committed Jun 21, 2017
1 parent 02e15ee commit b2533d9
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This SerDe adds support for reading pg_dump plain ouput. It does not support ski
## Using

```
hive> add jar path/to/pgdump-serde-1.0.3-1.2.0-all.jar;
hive> add jar path/to/pgdump-serde-1.0.4-1.2.0-all.jar;
hive> create table my_table(a integer, b string, ...)
row format serde 'com.pasam.hive.serde.pg.PgDumpSerDe'
Expand All @@ -15,7 +15,7 @@ hive> create table my_table(a integer, b string, ...)

## Files

* [pgdump-serde-1.0.3-1.2.0-all.jar](https://github.com/spasam/pgdump-serde/releases/download/1.0.3/pgdump-serde-1.0.3-1.2.0-all.jar)
* [pgdump-serde-1.0.4-1.2.0-all.jar](https://github.com/spasam/pgdump-serde/releases/download/1.0.4/pgdump-serde-1.0.4-1.2.0-all.jar)


## Building
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.pasam</groupId>
<artifactId>pgdump-serde</artifactId>
<version>1.0.3-1.2.0</version>
<version>1.0.4-1.2.0</version>
<dependencies>
<dependency>
<groupId>org.apache.hive</groupId>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/pasam/hive/serde/pg/PgDumpSerDe.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
public class PgDumpSerDe
extends AbstractSerDe {
private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern(
"yyyy[[-][/]]MM[[-][/]]dd[['T'][ ]]HH:mm:ss[[ ][.SSS][.S]][XXX][X]");
"yyyy[[-][/]]MM[[-][/]]dd[['T'][ ]]HH:mm:ss[[ ][.SSSSSS][.SSS][.S]][XXX][X]");

private ObjectInspector inspector;
private List<TypeInfo> columnTypes;
Expand Down
15 changes: 8 additions & 7 deletions src/test/java/com/pasam/hive/serde/pg/PgDumpSerDeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ public final class PgDumpSerDeTest {
@Before
public void setup() throws Exception {
props.put(serdeConstants.LIST_COLUMNS,
"ttint,tsint,tint,tbint,tfloat,tdouble,tdecimal,tbtrue,tbfalse,ttstamp1,ttstamp2,ttstamp3,ttstamp4,tstring,tnstring,tmstring,testring");
"ttint,tsint,tint,tbint,tfloat,tdouble,tdecimal,tbtrue,tbfalse,ttstamp1,ttstamp2,ttstamp3,ttstamp4,ttstamp5,tstring,tnstring,tmstring,testring");
props.put(serdeConstants.LIST_COLUMN_TYPES,
"tinyint,smallint,int,bigint,float,double,decimal,boolean,boolean,timestamp,timestamp,timestamp,timestamp,string,string,string,string");
"tinyint,smallint,int,bigint,float,double,decimal,boolean,boolean,timestamp,timestamp,timestamp,timestamp,timestamp,string,string,string,string");
}

@Test
Expand All @@ -37,7 +37,7 @@ public void testDeserialize() throws Exception {
final Text in = new Text(reader.readLine());
final List<?> row = (List<?>) serde.deserialize(in);

assertEquals(17, row.size());
assertEquals(18, row.size());
assertEquals(new Byte((byte) 1), row.get(0));
assertEquals(new Short((short) 100), row.get(1));
assertEquals(new Integer(65536), row.get(2));
Expand All @@ -51,9 +51,10 @@ public void testDeserialize() throws Exception {
assertTrue(row.get(10) instanceof Timestamp);
assertTrue(row.get(11) instanceof Timestamp);
assertTrue(row.get(12) instanceof Timestamp);
assertEquals("Hello Seshu", row.get(13));
assertEquals(null, row.get(14));
assertEquals("A\tB\\tC\nD\\nE\\rF\nG\\H\\I\\\\J\n", row.get(15));
assertEquals("", row.get(16));
assertTrue(row.get(13) instanceof Timestamp);
assertEquals("Hello Seshu", row.get(14));
assertEquals(null, row.get(15));
assertEquals("A\tB\\tC\nD\\nE\\rF\nG\\H\\I\\\\J\n", row.get(16));
assertEquals("", row.get(17));
}
}
2 changes: 1 addition & 1 deletion src/test/resources/pg.dump
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1 100 65536 1234567890 123.45 1234567890.12 1234567890.12 true false 2017-05-12 12:34:56.123 2017-04-20 06:40:40.5+00 2017-05-31 14:57:18.208-04 2017-05-17 20:53:47+00 Hello Seshu \N A\tB\\tC\nD\\nE\\rF\nG\\H\\I\\\\J\n
1 100 65536 1234567890 123.45 1234567890.12 1234567890.12 true false 2017-05-12 12:34:56.123 2017-04-20 06:40:40.5+00 2017-05-12 12:34:56.123456+04:00 2017-05-31 14:57:18.208-04 2017-05-17 20:53:47+00 Hello Seshu \N A\tB\\tC\nD\\nE\\rF\nG\\H\\I\\\\J\n

0 comments on commit b2533d9

Please sign in to comment.