Skip to content

Commit

Permalink
[fix]:fix tdengine table name
Browse files Browse the repository at this point in the history
  • Loading branch information
lgt1126 committed Dec 21, 2021
1 parent f43c68e commit d2b55de
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ public class TDEngineSqlExecutor {

protected <T extends StorageData> SQLExecutor getInsertExecutor(String modelName, T metrics) {

SQLBuilder sqlBuilder = new SQLBuilder().append("h_").append(metrics.itemid() + " USING ");
SQLBuilder sqlBuilder = new SQLBuilder();

if (modelName.equals("history")) {

History history = (History) metrics;
sqlBuilder.append("history (deviceid, itemid) TAGS")
sqlBuilder.append("h_").append(metrics.itemid() + " USING ").append("history (deviceid, itemid) TAGS")
.append("('").append(history.getDeviceId()).append("'")
.append(",").append(history.getItemid() + " )")
.append(" VALUES (")
Expand All @@ -35,7 +35,7 @@ protected <T extends StorageData> SQLExecutor getInsertExecutor(String modelName
} else if (modelName.equals("history_uint")) {

UIntHistory uihistory = (UIntHistory) metrics;
sqlBuilder.append("history_uint (deviceid, itemid) TAGS")
sqlBuilder.append("huint_").append(metrics.itemid() + " USING ").append("history_uint (deviceid, itemid) TAGS")
.append(" ('").append(uihistory.getDeviceId()).append("'")
.append(",").append(uihistory.getItemid() + " )")
.append(" VALUES (")
Expand All @@ -45,7 +45,7 @@ protected <T extends StorageData> SQLExecutor getInsertExecutor(String modelName
TextHistory textHistory = (TextHistory) metrics;
String value = textHistory.getValue().replaceAll(",", "\\,");

sqlBuilder.append("history_text (deviceid, itemid) TAGS")
sqlBuilder.append("htxt_").append(metrics.itemid() + " USING ").append("history_text (deviceid, itemid) TAGS")
.append(" ('").append(textHistory.getDeviceId()).append("'")
.append(",").append(textHistory.getItemid() + " )")
.append(" VALUES (")
Expand All @@ -54,7 +54,7 @@ protected <T extends StorageData> SQLExecutor getInsertExecutor(String modelName

StrHistory strHistory = (StrHistory) metrics;
String value = strHistory.getValue().replaceAll(",", "\\,");
sqlBuilder.append("history_str (deviceid, itemid) TAGS")
sqlBuilder.append("hstr_").append(metrics.itemid() + " USING ").append("history_str (deviceid, itemid) TAGS")
.append(" ('").append(strHistory.getDeviceId()).append("'")
.append(",").append(strHistory.getItemid() + " )")
.append(" VALUES (")
Expand Down

0 comments on commit d2b55de

Please sign in to comment.