提交 65e4e0e6 编写于 作者: G Ganlin Zhao

[TD-10532]<enhance>: schemaless add hour/minute support

上级 8b342156
......@@ -44,6 +44,8 @@ typedef struct {
typedef enum {
SML_TIME_STAMP_NOW,
SML_TIME_STAMP_HOURS,
SML_TIME_STAMP_MINUTES,
SML_TIME_STAMP_SECONDS,
SML_TIME_STAMP_MILLI_SECONDS,
SML_TIME_STAMP_MICRO_SECONDS,
......
......@@ -1731,6 +1731,14 @@ static int32_t getTimeStampValue(char *value, uint16_t len,
*ts = taosGetTimestampNs();
break;
}
case SML_TIME_STAMP_HOURS: {
*ts = (int64_t)(*ts * 3600 * 1e9);
break;
}
case SML_TIME_STAMP_MINUTES: {
*ts = (int64_t)(*ts * 60 * 1e9);
break;
}
case SML_TIME_STAMP_SECONDS: {
*ts = (int64_t)(*ts * 1e9);
break;
......@@ -2241,17 +2249,34 @@ int32_t convertPrecisionStrType(char* precision, SMLTimeStampType *tsType) {
*tsType = SML_TIME_STAMP_NOT_CONFIGURED;
return TSDB_CODE_SUCCESS;
}
if (strcmp(precision, "μ") == 0) {
*tsType = SML_TIME_STAMP_MICRO_SECONDS;
return TSDB_CODE_SUCCESS;
}
int32_t len = (int32_t)strlen(precision);
if (len == 1 && precision[0] == 's') {
*tsType = SML_TIME_STAMP_SECONDS;
if (len == 1) {
switch (precision[0]) {
case 'u':
*tsType = SML_TIME_STAMP_MICRO_SECONDS;
break;
case 's':
*tsType = SML_TIME_STAMP_SECONDS;
break;
case 'm':
*tsType = SML_TIME_STAMP_MINUTES;
break;
case 'h':
*tsType = SML_TIME_STAMP_HOURS;
break;
default:
return TSDB_CODE_TSC_INVALID_PRECISION_TYPE;
}
} else if (len == 2 && precision[1] == 's') {
switch (precision[0]) {
case 'm':
*tsType = SML_TIME_STAMP_MILLI_SECONDS;
break;
case 'u':
*tsType = SML_TIME_STAMP_MICRO_SECONDS;
break;
case 'n':
*tsType = SML_TIME_STAMP_NANO_SECONDS;
break;
......@@ -2286,12 +2311,12 @@ int32_t convertPrecisionStrType(char* precision, SMLTimeStampType *tsType) {
*
*/
int taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int protocol, char* precision) {
int taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int protocol, char* timePrecision) {
int code;
SMLTimeStampType tsType;
if (protocol == SML_LINE_PROTOCOL) {
code = convertPrecisionStrType(precision, &tsType);
code = convertPrecisionStrType(timePrecision, &tsType);
if (code != TSDB_CODE_SUCCESS) {
return code;
}
......
......@@ -823,6 +823,7 @@ def taos_schemaless_insert(connection, lines, protocol, precision):
lines = (c_char_p(line.encode("utf-8")) for line in lines)
lines_type = ctypes.c_char_p * num_of_lines
p_lines = lines_type(*lines)
precision = c_char_p(precision.encode("utf-8"))
errno = _libtaos.taos_schemaless_insert(connection, p_lines, num_of_lines, protocol, precision)
if errno != 0:
raise SchemalessError("schemaless insert error", errno)
......
......@@ -74,7 +74,7 @@ class TDTestCase:
tdSql.checkData(2, 2, 14)
self._conn.schemaless_insert([
"sth,t1=4i64,t2=5f64,t4=5f64,ID=\"childtable\" c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933641",
"sth,t1=4i64,t2=5f64,t4=5f64,ID=childtable c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933641",
"sth,t1=4i64,t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933654"
], 0, "ms")
tdSql.execute('reset query cache')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册