yanxinyi commented on a change in pull request #878:
URL: https://github.com/apache/phoenix/pull/878#discussion_r538002449
##########
File path:
phoenix-pherf/src/main/java/org/apache/phoenix/pherf/util/PhoenixUtil.java
##########
@@ -455,4 +473,156 @@ public String getExplainPlan(Query query, Scenario
scenario, RulesApplier ruleAp
}
return buf.toString();
}
+
+ public PreparedStatement buildStatement(RulesApplier rulesApplier,
Scenario scenario, List<Column> columns,
+ PreparedStatement statement, SimpleDateFormat simpleDateFormat)
throws Exception {
+
+ int count = 1;
+ for (Column column : columns) {
+ DataValue dataValue = rulesApplier.getDataForRule(scenario,
column);
+ switch (column.getType()) {
+ case VARCHAR:
+ if (dataValue.getValue().equals("")) {
+ statement.setNull(count, Types.VARCHAR);
+ } else {
+ statement.setString(count, dataValue.getValue());
+ }
+ break;
+ case CHAR:
+ if (dataValue.getValue().equals("")) {
+ statement.setNull(count, Types.CHAR);
+ } else {
+ statement.setString(count, dataValue.getValue());
+ }
+ break;
+ case DECIMAL:
+ if (dataValue.getValue().equals("")) {
+ statement.setNull(count, Types.DECIMAL);
+ } else {
+ statement.setBigDecimal(count, new
BigDecimal(dataValue.getValue()));
+ }
+ break;
+ case INTEGER:
+ if (dataValue.getValue().equals("")) {
+ statement.setNull(count, Types.INTEGER);
+ } else {
+ statement.setInt(count,
Integer.parseInt(dataValue.getValue()));
+ }
+ break;
+ case UNSIGNED_LONG:
+ if (dataValue.getValue().equals("")) {
+ statement.setNull(count, Types.OTHER);
+ } else {
+ statement.setLong(count,
Long.parseLong(dataValue.getValue()));
+ }
+ break;
+ case BIGINT:
+ if (dataValue.getValue().equals("")) {
+ statement.setNull(count, Types.BIGINT);
+ } else {
+ statement.setLong(count,
Long.parseLong(dataValue.getValue()));
+ }
+ break;
+ case TINYINT:
+ if (dataValue.getValue().equals("")) {
+ statement.setNull(count, Types.TINYINT);
+ } else {
+ statement.setLong(count,
Integer.parseInt(dataValue.getValue()));
+ }
+ break;
+ case DATE:
+ if (dataValue.getValue().equals("")) {
+ statement.setNull(count, Types.DATE);
+ } else {
+ Date
+ date =
Review comment:
nit: style issue
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]