fix: deal with error in schemaless
This commit is contained in:
parent
37f7c0f2cc
commit
bda392bbe6
|
@ -58,13 +58,9 @@ for (int i = 1; i < keyLen; ++i) { \
|
|||
#define IS_INVALID_COL_LEN(len) ((len) <= 0 || (len) >= TSDB_COL_NAME_LEN)
|
||||
#define IS_INVALID_TABLE_LEN(len) ((len) <= 0 || (len) >= TSDB_TABLE_NAME_LEN)
|
||||
|
||||
#define OTD_MAX_FIELDS_NUM 2
|
||||
#define OTD_JSON_SUB_FIELDS_NUM 2
|
||||
#define OTD_JSON_FIELDS_NUM 4
|
||||
|
||||
#define OTD_TIMESTAMP_COLUMN_NAME "ts"
|
||||
#define OTD_METRIC_VALUE_COLUMN_NAME "value"
|
||||
|
||||
#define TS "_ts"
|
||||
#define TS_LEN 3
|
||||
#define TAG "_tag"
|
||||
|
@ -731,24 +727,24 @@ static int64_t smlGetTimeValue(const char *value, int32_t len, int8_t type) {
|
|||
double ts = tsInt64;
|
||||
switch (type) {
|
||||
case TSDB_TIME_PRECISION_HOURS:
|
||||
ts *= (3600 * 1e9);
|
||||
tsInt64 *= (3600 * 1e9);
|
||||
ts *= NANOSECOND_PER_HOUR;
|
||||
tsInt64 *= NANOSECOND_PER_HOUR;
|
||||
break;
|
||||
case TSDB_TIME_PRECISION_MINUTES:
|
||||
ts *= (60 * 1e9);
|
||||
tsInt64 *= (60 * 1e9);
|
||||
ts *= NANOSECOND_PER_MINUTE;
|
||||
tsInt64 *= NANOSECOND_PER_MINUTE;
|
||||
break;
|
||||
case TSDB_TIME_PRECISION_SECONDS:
|
||||
ts *= (1e9);
|
||||
tsInt64 *= (1e9);
|
||||
ts *= NANOSECOND_PER_SEC;
|
||||
tsInt64 *= NANOSECOND_PER_SEC;
|
||||
break;
|
||||
case TSDB_TIME_PRECISION_MILLI:
|
||||
ts *= (1e6);
|
||||
tsInt64 *= (1e6);
|
||||
ts *= NANOSECOND_PER_MSEC;
|
||||
tsInt64 *= NANOSECOND_PER_MSEC;
|
||||
break;
|
||||
case TSDB_TIME_PRECISION_MICRO:
|
||||
ts *= (1e3);
|
||||
tsInt64 *= (1e3);
|
||||
ts *= NANOSECOND_PER_USEC;
|
||||
tsInt64 *= NANOSECOND_PER_USEC;
|
||||
break;
|
||||
case TSDB_TIME_PRECISION_NANO:
|
||||
break;
|
||||
|
@ -762,23 +758,6 @@ static int64_t smlGetTimeValue(const char *value, int32_t len, int8_t type) {
|
|||
return tsInt64;
|
||||
}
|
||||
|
||||
static int64_t smlGetTimeNow(int8_t precision) {
|
||||
switch (precision) {
|
||||
case TSDB_TIME_PRECISION_HOURS:
|
||||
return taosGetTimestampMs()/1000/3600;
|
||||
case TSDB_TIME_PRECISION_MINUTES:
|
||||
return taosGetTimestampMs()/1000/60;
|
||||
case TSDB_TIME_PRECISION_SECONDS:
|
||||
return taosGetTimestampMs()/1000;
|
||||
case TSDB_TIME_PRECISION_MILLI:
|
||||
case TSDB_TIME_PRECISION_MICRO:
|
||||
case TSDB_TIME_PRECISION_NANO:
|
||||
return taosGetTimestamp(precision);
|
||||
default:
|
||||
ASSERT(0);
|
||||
}
|
||||
}
|
||||
|
||||
static int8_t smlGetTsTypeByLen(int32_t len) {
|
||||
if (len == TSDB_TIME_PRECISION_SEC_DIGITS) {
|
||||
return TSDB_TIME_PRECISION_SECONDS;
|
||||
|
@ -810,14 +789,15 @@ static int8_t smlGetTsTypeByPrecision(int8_t precision) {
|
|||
}
|
||||
|
||||
static int64_t smlParseInfluxTime(SSmlHandle* info, const char* data, int32_t len){
|
||||
if(len == 0){
|
||||
return taosGetTimestamp(TSDB_TIME_PRECISION_NANO);
|
||||
}
|
||||
|
||||
int8_t tsType = smlGetTsTypeByPrecision(info->precision);
|
||||
if (tsType == -1) {
|
||||
smlBuildInvalidDataMsg(&info->msgBuf, "invalid timestamp precision", NULL);
|
||||
return -1;
|
||||
}
|
||||
if(len == 0){
|
||||
return smlGetTimeNow(tsType);
|
||||
}
|
||||
|
||||
int64_t ts = smlGetTimeValue(data, len, tsType);
|
||||
if(ts == -1){
|
||||
|
|
|
@ -1203,24 +1203,17 @@ TEST(testCase, sml_TD15662_Test) {
|
|||
SRequestObj *request = (SRequestObj *)createRequest((STscObj *)taos, NULL, NULL, TSDB_SQL_INSERT);
|
||||
ASSERT_NE(request, nullptr);
|
||||
|
||||
SSmlHandle *info = smlBuildSmlInfo(taos, request, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS);
|
||||
SSmlHandle *info = smlBuildSmlInfo(taos, request, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_MILLI_SECONDS);
|
||||
ASSERT_NE(info, nullptr);
|
||||
|
||||
const char *sql[] = {
|
||||
"iyyyje,id=iyyyje_41943_1303,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=false,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"binaryColValue\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000",
|
||||
"hetrey,id=sub_table_0123456,t0=f,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"binaryColValue\",c8=L\"ncharColValue\",c9=7u64",
|
||||
};
|
||||
int ret = smlProcess(info, (char **)sql, sizeof(sql) / sizeof(sql[0]));
|
||||
ASSERT_EQ(ret, 0);
|
||||
|
||||
// case 1
|
||||
TAOS_RES *res = taos_query(taos, "select * from t_a5615048edae55218a22a149edebdc82");
|
||||
ASSERT_NE(res, nullptr);
|
||||
|
||||
TAOS_ROW row = taos_fetch_row(res);
|
||||
int64_t ts = *(int64_t*)row[0];
|
||||
ASSERT_EQ(ts, 1626006833639000000);
|
||||
|
||||
taos_free_result(res);
|
||||
destroyRequest(request);
|
||||
smlDestroyInfo(info);
|
||||
}
|
||||
|
||||
TEST(testCase, sml_TD15735_Test) {
|
||||
|
@ -1262,11 +1255,11 @@ TEST(testCase, sml_TD15742_Test) {
|
|||
SRequestObj *request = (SRequestObj *)createRequest((STscObj*)taos, NULL, NULL, TSDB_SQL_INSERT);
|
||||
ASSERT_NE(request, nullptr);
|
||||
|
||||
SSmlHandle *info = smlBuildSmlInfo(taos, request, TSDB_SML_TELNET_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS);
|
||||
SSmlHandle *info = smlBuildSmlInfo(taos, request, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_MILLI_SECONDS);
|
||||
ASSERT_NE(info, nullptr);
|
||||
|
||||
const char *sql[] = {
|
||||
"zgzbix 1626006833641 False id=zgzbix_992_38861 t0=t t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64 t7=\"binaryTagValue\" t8=L\"ncharTagValue\"",
|
||||
"test_ms,t0=t c0=f 1626006833641",
|
||||
};
|
||||
int ret = smlProcess(info, (char**)sql, sizeof(sql)/sizeof(sql[0]));
|
||||
ASSERT_EQ(ret, 0);
|
||||
|
|
Loading…
Reference in New Issue