diff --git a/src/main/java/com/sina/bip/hangout/outputs/Clickhouse.java b/src/main/java/com/sina/bip/hangout/outputs/Clickhouse.java index 5e55112..b2f56d2 100644 --- a/src/main/java/com/sina/bip/hangout/outputs/Clickhouse.java +++ b/src/main/java/com/sina/bip/hangout/outputs/Clickhouse.java @@ -108,16 +108,16 @@ protected void bulkInsert(Map event) throws Exception { String value = "("; for (int j =0; j < fields.size(); j++) { String field = fields.get(j); - if (this.fieldGetterMap.get(field).getField(e) != null) { + Object fieldValue = this.fieldGetterMap.get(field).getField(e); + if (fieldValue != null) { if (this.fieldGetterMap.get(field).getField(e) instanceof String) { - String fieldValue = this.fieldGetterMap.get(field).getField(e).toString(); - if (!(fieldValue.indexOf("'") > 0)){ - value += "'" + this.fieldGetterMap.get(field).getField(e).toString() + "'"; + if (!(fieldValue.toString().indexOf("'") > 0)){ + value += "'" + fieldValue.toString() + "'"; } else { value += "''"; } } else { - value += this.fieldGetterMap.get(field).getField(e).toString(); + value += fieldValue; } } else { value += ClickhouseUtils.renderDefault(this.schema.get(ClickhouseUtils.realField(field))); @@ -135,7 +135,7 @@ protected void bulkInsert(Map event) throws Exception { Connection conn = balanced.getConnection(); try { - System.out.println(sqls.toString()); + // System.out.println(sqls.toString()); conn.createStatement().execute(sqls.toString()); } catch (SQLException e){ System.out.println(e.toString());