Skip to content

Commit

Permalink
[Fix][Connector][TDEngine] TDEngine support NCHAR type (#8411)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangshenghang authored Jan 1, 2025
1 parent 84a1eb5 commit 88c92ae
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public class TDengineTypeMapper {

// -------------------------string----------------------------
private static final String TDENGINE_CHAR = "CHAR";
private static final String TDENGINE_NCHAR = "NCHAR";
private static final String TDENGINE_VARCHAR = "VARCHAR";
private static final String TDENGINE_TINYTEXT = "TINYTEXT";
private static final String TDENGINE_MEDIUMTEXT = "MEDIUMTEXT";
Expand Down Expand Up @@ -118,6 +119,7 @@ public static SeaTunnelDataType<?> mapping(String tdengineType) {
log.warn("{} will probably cause value overflow.", TDENGINE_DOUBLE_UNSIGNED);
return BasicType.DOUBLE_TYPE;
case TDENGINE_CHAR:
case TDENGINE_NCHAR:
case TDENGINE_TINYTEXT:
case TDENGINE_MEDIUMTEXT:
case TDENGINE_TEXT:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@ private int generateTestDataSet() {
try (Statement stmt = connection1.createStatement()) {
stmt.execute("CREATE DATABASE power KEEP 3650");
stmt.execute(
"CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT, off BOOL) "
"CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT, off BOOL, nc NCHAR(10)) "
+ "TAGS (location BINARY(64), groupId INT)");
String sql = getSQL();
rowCount = stmt.executeUpdate(sql);
}
try (Statement stmt = connection2.createStatement()) {
stmt.execute("CREATE DATABASE power2 KEEP 3650");
stmt.execute(
"CREATE STABLE power2.meters2 (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT, off BOOL) "
"CREATE STABLE power2.meters2 (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT, off BOOL, nc NCHAR(10)) "
+ "TAGS (location BINARY(64), groupId INT)");
}
return rowCount;
Expand Down Expand Up @@ -210,20 +210,22 @@ private static String getSQL() {
.append(ps[4])
.append(",") // off
.append(ps[7])
.append(",") // nc
.append(ps[8])
.append(") "); // phase
}
return sb.toString();
}

private static List<String> getRawData() {
return Arrays.asList(
"d1001,2018-10-03 14:38:05.000,10.30000,219,0.31000,'California.SanFrancisco',2,true",
"d1001,2018-10-03 14:38:15.000,12.60000,218,0.33000,'California.SanFrancisco',2,false",
"d1001,2018-10-03 14:38:16.800,12.30000,221,0.31000,'California.SanFrancisco',2,true",
"d1002,2018-10-03 14:38:16.650,10.30000,218,0.25000,'California.SanFrancisco',3,true",
"d1003,2018-10-03 14:38:05.500,11.80000,221,0.28000,'California.LosAngeles',2,true",
"d1003,2018-10-03 14:38:16.600,13.40000,223,0.29000,'California.LosAngeles',2,true",
"d1004,2018-10-03 14:38:05.000,10.80000,223,0.29000,'California.LosAngeles',3,true",
"d1004,2018-10-03 14:38:06.500,11.50000,221,0.35000,'California.LosAngeles',3,false");
"d1001,2018-10-03 14:38:05.000,10.30000,219,0.31000,'California.SanFrancisco',2,true,'nc'",
"d1001,2018-10-03 14:38:15.000,12.60000,218,0.33000,'California.SanFrancisco',2,false,'nc'",
"d1001,2018-10-03 14:38:16.800,12.30000,221,0.31000,'California.SanFrancisco',2,true,'nc'",
"d1002,2018-10-03 14:38:16.650,10.30000,218,0.25000,'California.SanFrancisco',3,true,'nc'",
"d1003,2018-10-03 14:38:05.500,11.80000,221,0.28000,'California.LosAngeles',2,true,'nc'",
"d1003,2018-10-03 14:38:16.600,13.40000,223,0.29000,'California.LosAngeles',2,true,'nc'",
"d1004,2018-10-03 14:38:05.000,10.80000,223,0.29000,'California.LosAngeles',3,true,'nc'",
"d1004,2018-10-03 14:38:06.500,11.50000,221,0.35000,'California.LosAngeles',3,false,'nc'");
}
}

0 comments on commit 88c92ae

Please sign in to comment.