Skip to content
This repository has been archived by the owner on Jan 6, 2022. It is now read-only.

Commit

Permalink
Merge branch 'rickyhuo.clickhouse.array'
Browse files Browse the repository at this point in the history
  • Loading branch information
RickyHuo committed May 8, 2018
2 parents fea4ad7 + 25dd9c8 commit e8e7fce
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/main/java/com/sina/bip/hangout/outputs/TabSeparated.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public void bulkInsert(List<Map> events) throws Exception {

int size = fields.size();
for (Map e: events) {
statement.setString(1, "sd");
//statement.setString(1, "sd");

for (int i=0; i<size; i++) {
String field = fields.get(i);
Expand All @@ -169,7 +169,7 @@ public void bulkInsert(List<Map> events) throws Exception {
statement.setInt(i + 1, v);

} catch (Exception exp) {
String msg = String.format("Cannot Convert %s %s to integer, render default", fieldValue.getClass(), fieldValue);
String msg = String.format("Cannot Convert %s %s to integer, render default. Field is %s", fieldValue.getClass(), fieldValue, field);
log.warn(msg);
log.error(exp);
statement.setInt(i + 1, 0);
Expand Down Expand Up @@ -225,6 +225,15 @@ public void bulkInsert(List<Map> events) throws Exception {
}

break;
case "Array(String)":
if (fieldValue != null) {
List<String> v = (List) fieldValue;
String [] array = v.toArray(new String[v.size()]);
statement.setArray(i + 1, this.conn.createArrayOf("string", array));
} else {
statement.setArray(i + 1, this.conn.createArrayOf("string", new String[1]));
}

}
}
statement.addBatch();
Expand Down

0 comments on commit e8e7fce

Please sign in to comment.