Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix][Connector][TDEngine] TDEngine support NCHAR type #8411

Merged
merged 1 commit into from
Jan 1, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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";
@@ -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:
Original file line number Diff line number Diff line change
@@ -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;
@@ -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'");
}
}