提交 aae2de07 编写于 作者: X Xiaoyu Wang

enh: add event_winodw test case

上级 4c2a41ec
...@@ -23,12 +23,12 @@ ...@@ -23,12 +23,12 @@
#include "scheduler.h" #include "scheduler.h"
#include "tcache.h" #include "tcache.h"
#include "tglobal.h" #include "tglobal.h"
#include "thttp.h"
#include "tmsg.h" #include "tmsg.h"
#include "tref.h" #include "tref.h"
#include "trpc.h" #include "trpc.h"
#include "tsched.h" #include "tsched.h"
#include "ttime.h" #include "ttime.h"
#include "thttp.h"
#define TSC_VAR_NOT_RELEASE 1 #define TSC_VAR_NOT_RELEASE 1
#define TSC_VAR_RELEASED 0 #define TSC_VAR_RELEASED 0
...@@ -65,7 +65,7 @@ static int32_t registerRequest(SRequestObj *pRequest, STscObj *pTscObj) { ...@@ -65,7 +65,7 @@ static int32_t registerRequest(SRequestObj *pRequest, STscObj *pTscObj) {
static void deregisterRequest(SRequestObj *pRequest) { static void deregisterRequest(SRequestObj *pRequest) {
const static int64_t SLOW_QUERY_INTERVAL = 3000000L; // todo configurable const static int64_t SLOW_QUERY_INTERVAL = 3000000L; // todo configurable
if(pRequest == NULL){ if (pRequest == NULL) {
tscError("pRequest == NULL"); tscError("pRequest == NULL");
return; return;
} }
...@@ -380,9 +380,9 @@ void doDestroyRequest(void *p) { ...@@ -380,9 +380,9 @@ void doDestroyRequest(void *p) {
} }
if (pRequest->syncQuery) { if (pRequest->syncQuery) {
if (pRequest->body.param){ if (pRequest->body.param) {
tsem_destroy(&((SSyncQueryParam*)pRequest->body.param)->sem); tsem_destroy(&((SSyncQueryParam *)pRequest->body.param)->sem);
} }
taosMemoryFree(pRequest->body.param); taosMemoryFree(pRequest->body.param);
} }
...@@ -406,20 +406,20 @@ static void *tscCrashReportThreadFp(void *param) { ...@@ -406,20 +406,20 @@ static void *tscCrashReportThreadFp(void *param) {
setThreadName("client-crashReport"); setThreadName("client-crashReport");
char filepath[PATH_MAX] = {0}; char filepath[PATH_MAX] = {0};
snprintf(filepath, sizeof(filepath), "%s%s.taosCrashLog", tsLogDir, TD_DIRSEP); snprintf(filepath, sizeof(filepath), "%s%s.taosCrashLog", tsLogDir, TD_DIRSEP);
char *pMsg = NULL; char *pMsg = NULL;
int64_t msgLen = 0; int64_t msgLen = 0;
TdFilePtr pFile = NULL; TdFilePtr pFile = NULL;
bool truncateFile = false; bool truncateFile = false;
int32_t sleepTime = 200; int32_t sleepTime = 200;
int32_t reportPeriodNum = 3600 * 1000 / sleepTime; int32_t reportPeriodNum = 3600 * 1000 / sleepTime;
int32_t loopTimes = reportPeriodNum; int32_t loopTimes = reportPeriodNum;
#ifdef WINDOWS #ifdef WINDOWS
if (taosCheckCurrentInDll()) { if (taosCheckCurrentInDll()) {
atexit(crashReportThreadFuncUnexpectedStopped); atexit(crashReportThreadFuncUnexpectedStopped);
} }
#endif #endif
while (1) { while (1) {
if (clientStop) break; if (clientStop) break;
if (loopTimes++ < reportPeriodNum) { if (loopTimes++ < reportPeriodNum) {
...@@ -449,12 +449,12 @@ static void *tscCrashReportThreadFp(void *param) { ...@@ -449,12 +449,12 @@ static void *tscCrashReportThreadFp(void *param) {
pMsg = NULL; pMsg = NULL;
continue; continue;
} }
if (pFile) { if (pFile) {
taosReleaseCrashLogFile(pFile, truncateFile); taosReleaseCrashLogFile(pFile, truncateFile);
truncateFile = false; truncateFile = false;
} }
taosMsleep(sleepTime); taosMsleep(sleepTime);
loopTimes = 0; loopTimes = 0;
} }
...@@ -467,11 +467,11 @@ int32_t tscCrashReportInit() { ...@@ -467,11 +467,11 @@ int32_t tscCrashReportInit() {
if (!tsEnableCrashReport) { if (!tsEnableCrashReport) {
return 0; return 0;
} }
TdThreadAttr thAttr; TdThreadAttr thAttr;
taosThreadAttrInit(&thAttr); taosThreadAttrInit(&thAttr);
taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE); taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
TdThread crashReportThread; TdThread crashReportThread;
if (taosThreadCreate(&crashReportThread, &thAttr, tscCrashReportThreadFp, NULL) != 0) { if (taosThreadCreate(&crashReportThread, &thAttr, tscCrashReportThreadFp, NULL) != 0) {
tscError("failed to create crashReport thread since %s", strerror(errno)); tscError("failed to create crashReport thread since %s", strerror(errno));
return -1; return -1;
...@@ -496,26 +496,24 @@ void tscStopCrashReport() { ...@@ -496,26 +496,24 @@ void tscStopCrashReport() {
} }
} }
void tscWriteCrashInfo(int signum, void *sigInfo, void *context) { void tscWriteCrashInfo(int signum, void *sigInfo, void *context) {
char *pMsg = NULL; char *pMsg = NULL;
const char *flags = "UTL FATAL "; const char *flags = "UTL FATAL ";
ELogLevel level = DEBUG_FATAL; ELogLevel level = DEBUG_FATAL;
int32_t dflag = 255; int32_t dflag = 255;
int64_t msgLen= -1; int64_t msgLen = -1;
if (tsEnableCrashReport) { if (tsEnableCrashReport) {
if (taosGenCrashJsonMsg(signum, &pMsg, lastClusterId, appInfo.startTime)) { if (taosGenCrashJsonMsg(signum, &pMsg, lastClusterId, appInfo.startTime)) {
taosPrintLog(flags, level, dflag, "failed to generate crash json msg"); taosPrintLog(flags, level, dflag, "failed to generate crash json msg");
} else { } else {
msgLen = strlen(pMsg); msgLen = strlen(pMsg);
} }
} }
taosLogCrashInfo("taos", pMsg, msgLen, signum, sigInfo); taosLogCrashInfo("taos", pMsg, msgLen, signum, sigInfo);
} }
void taos_init_imp(void) { void taos_init_imp(void) {
// In the APIs of other program language, taos_cleanup is not available yet. // In the APIs of other program language, taos_cleanup is not available yet.
// So, to make sure taos_cleanup will be invoked to clean up the allocated resource to suppress the valgrind warning. // So, to make sure taos_cleanup will be invoked to clean up the allocated resource to suppress the valgrind warning.
...@@ -570,7 +568,7 @@ void taos_init_imp(void) { ...@@ -570,7 +568,7 @@ void taos_init_imp(void) {
taosThreadMutexInit(&appInfo.mutex, NULL); taosThreadMutexInit(&appInfo.mutex, NULL);
tscCrashReportInit(); tscCrashReportInit();
tscDebug("client is initialized successfully"); tscDebug("client is initialized successfully");
} }
...@@ -621,6 +619,9 @@ int taos_options_imp(TSDB_OPTION option, const char *str) { ...@@ -621,6 +619,9 @@ int taos_options_imp(TSDB_OPTION option, const char *str) {
tscError("failed to set cfg:%s to %s since %s", pItem->name, str, terrstr()); tscError("failed to set cfg:%s to %s since %s", pItem->name, str, terrstr());
} else { } else {
tscInfo("set cfg:%s to %s", pItem->name, str); tscInfo("set cfg:%s to %s", pItem->name, str);
if (TSDB_OPTION_SHELL_ACTIVITY_TIMER == option || TSDB_OPTION_USE_ADAPTER == option) {
code = taosSetCfg(pCfg, pItem->name);
}
} }
return code; return code;
......
...@@ -76,19 +76,19 @@ bool tsEnableTelem = true; ...@@ -76,19 +76,19 @@ bool tsEnableTelem = true;
int32_t tsTelemInterval = 43200; int32_t tsTelemInterval = 43200;
char tsTelemServer[TSDB_FQDN_LEN] = "telemetry.taosdata.com"; char tsTelemServer[TSDB_FQDN_LEN] = "telemetry.taosdata.com";
uint16_t tsTelemPort = 80; uint16_t tsTelemPort = 80;
char* tsTelemUri = "/report"; char *tsTelemUri = "/report";
bool tsEnableCrashReport = true; bool tsEnableCrashReport = true;
char* tsClientCrashReportUri = "/ccrashreport"; char *tsClientCrashReportUri = "/ccrashreport";
char* tsSvrCrashReportUri = "/dcrashreport"; char *tsSvrCrashReportUri = "/dcrashreport";
// schemaless // schemaless
char tsSmlTagName[TSDB_COL_NAME_LEN] = "_tag_null"; char tsSmlTagName[TSDB_COL_NAME_LEN] = "_tag_null";
char tsSmlChildTableName[TSDB_TABLE_NAME_LEN] = ""; // user defined child table name can be specified in tag value. char tsSmlChildTableName[TSDB_TABLE_NAME_LEN] = ""; // user defined child table name can be specified in tag value.
// If set to empty system will generate table name using MD5 hash. // If set to empty system will generate table name using MD5 hash.
// true means that the name and order of cols in each line are the same(only for influx protocol) // true means that the name and order of cols in each line are the same(only for influx protocol)
//bool tsSmlDataFormat = false; // bool tsSmlDataFormat = false;
//int32_t tsSmlBatchSize = 10000; // int32_t tsSmlBatchSize = 10000;
// query // query
int32_t tsQueryPolicy = 1; int32_t tsQueryPolicy = 1;
...@@ -210,9 +210,7 @@ int32_t taosSetTfsCfg(SConfig *pCfg) { ...@@ -210,9 +210,7 @@ int32_t taosSetTfsCfg(SConfig *pCfg) {
int32_t taosSetTfsCfg(SConfig *pCfg); int32_t taosSetTfsCfg(SConfig *pCfg);
#endif #endif
struct SConfig *taosGetCfg() { struct SConfig *taosGetCfg() { return tsCfg; }
return tsCfg;
}
static int32_t taosLoadCfg(SConfig *pCfg, const char **envCmd, const char *inputCfgDir, const char *envFile, static int32_t taosLoadCfg(SConfig *pCfg, const char **envCmd, const char *inputCfgDir, const char *envFile,
char *apolloUrl) { char *apolloUrl) {
...@@ -319,8 +317,8 @@ static int32_t taosAddClientCfg(SConfig *pCfg) { ...@@ -319,8 +317,8 @@ static int32_t taosAddClientCfg(SConfig *pCfg) {
if (cfgAddBool(pCfg, "keepColumnName", tsKeepColumnName, true) != 0) return -1; if (cfgAddBool(pCfg, "keepColumnName", tsKeepColumnName, true) != 0) return -1;
if (cfgAddString(pCfg, "smlChildTableName", "", 1) != 0) return -1; if (cfgAddString(pCfg, "smlChildTableName", "", 1) != 0) return -1;
if (cfgAddString(pCfg, "smlTagName", tsSmlTagName, 1) != 0) return -1; if (cfgAddString(pCfg, "smlTagName", tsSmlTagName, 1) != 0) return -1;
// if (cfgAddBool(pCfg, "smlDataFormat", tsSmlDataFormat, 1) != 0) return -1; // if (cfgAddBool(pCfg, "smlDataFormat", tsSmlDataFormat, 1) != 0) return -1;
// if (cfgAddInt32(pCfg, "smlBatchSize", tsSmlBatchSize, 1, INT32_MAX, true) != 0) return -1; // if (cfgAddInt32(pCfg, "smlBatchSize", tsSmlBatchSize, 1, INT32_MAX, true) != 0) return -1;
if (cfgAddInt32(pCfg, "maxMemUsedByInsert", tsMaxMemUsedByInsert, 1, INT32_MAX, true) != 0) return -1; if (cfgAddInt32(pCfg, "maxMemUsedByInsert", tsMaxMemUsedByInsert, 1, INT32_MAX, true) != 0) return -1;
if (cfgAddInt32(pCfg, "maxRetryWaitTime", tsMaxRetryWaitTime, 0, 86400000, 0) != 0) return -1; if (cfgAddInt32(pCfg, "maxRetryWaitTime", tsMaxRetryWaitTime, 0, 86400000, 0) != 0) return -1;
if (cfgAddBool(pCfg, "useAdapter", tsUseAdapter, true) != 0) return -1; if (cfgAddBool(pCfg, "useAdapter", tsUseAdapter, true) != 0) return -1;
...@@ -662,9 +660,9 @@ static int32_t taosSetClientCfg(SConfig *pCfg) { ...@@ -662,9 +660,9 @@ static int32_t taosSetClientCfg(SConfig *pCfg) {
tstrncpy(tsSmlChildTableName, cfgGetItem(pCfg, "smlChildTableName")->str, TSDB_TABLE_NAME_LEN); tstrncpy(tsSmlChildTableName, cfgGetItem(pCfg, "smlChildTableName")->str, TSDB_TABLE_NAME_LEN);
tstrncpy(tsSmlTagName, cfgGetItem(pCfg, "smlTagName")->str, TSDB_COL_NAME_LEN); tstrncpy(tsSmlTagName, cfgGetItem(pCfg, "smlTagName")->str, TSDB_COL_NAME_LEN);
// tsSmlDataFormat = cfgGetItem(pCfg, "smlDataFormat")->bval; // tsSmlDataFormat = cfgGetItem(pCfg, "smlDataFormat")->bval;
// tsSmlBatchSize = cfgGetItem(pCfg, "smlBatchSize")->i32; // tsSmlBatchSize = cfgGetItem(pCfg, "smlBatchSize")->i32;
tsMaxMemUsedByInsert = cfgGetItem(pCfg, "maxMemUsedByInsert")->i32; tsMaxMemUsedByInsert = cfgGetItem(pCfg, "maxMemUsedByInsert")->i32;
tsShellActivityTimer = cfgGetItem(pCfg, "shellActivityTimer")->i32; tsShellActivityTimer = cfgGetItem(pCfg, "shellActivityTimer")->i32;
...@@ -1048,10 +1046,10 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) { ...@@ -1048,10 +1046,10 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) {
tstrncpy(tsSmlChildTableName, cfgGetItem(pCfg, "smlChildTableName")->str, TSDB_TABLE_NAME_LEN); tstrncpy(tsSmlChildTableName, cfgGetItem(pCfg, "smlChildTableName")->str, TSDB_TABLE_NAME_LEN);
} else if (strcasecmp("smlTagName", name) == 0) { } else if (strcasecmp("smlTagName", name) == 0) {
tstrncpy(tsSmlTagName, cfgGetItem(pCfg, "smlTagName")->str, TSDB_COL_NAME_LEN); tstrncpy(tsSmlTagName, cfgGetItem(pCfg, "smlTagName")->str, TSDB_COL_NAME_LEN);
// } else if (strcasecmp("smlDataFormat", name) == 0) { // } else if (strcasecmp("smlDataFormat", name) == 0) {
// tsSmlDataFormat = cfgGetItem(pCfg, "smlDataFormat")->bval; // tsSmlDataFormat = cfgGetItem(pCfg, "smlDataFormat")->bval;
// } else if (strcasecmp("smlBatchSize", name) == 0) { // } else if (strcasecmp("smlBatchSize", name) == 0) {
// tsSmlBatchSize = cfgGetItem(pCfg, "smlBatchSize")->i32; // tsSmlBatchSize = cfgGetItem(pCfg, "smlBatchSize")->i32;
} else if (strcasecmp("shellActivityTimer", name) == 0) { } else if (strcasecmp("shellActivityTimer", name) == 0) {
tsShellActivityTimer = cfgGetItem(pCfg, "shellActivityTimer")->i32; tsShellActivityTimer = cfgGetItem(pCfg, "shellActivityTimer")->i32;
} else if (strcasecmp("supportVnodes", name) == 0) { } else if (strcasecmp("supportVnodes", name) == 0) {
...@@ -1121,6 +1119,8 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) { ...@@ -1121,6 +1119,8 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) {
tsStartUdfd = cfgGetItem(pCfg, "udf")->bval; tsStartUdfd = cfgGetItem(pCfg, "udf")->bval;
} else if (strcasecmp("uDebugFlag", name) == 0) { } else if (strcasecmp("uDebugFlag", name) == 0) {
uDebugFlag = cfgGetItem(pCfg, "uDebugFlag")->i32; uDebugFlag = cfgGetItem(pCfg, "uDebugFlag")->i32;
} else if (strcasecmp("useAdapter", name) == 0) {
tsUseAdapter = cfgGetItem(pCfg, "useAdapter")->bval;
} }
break; break;
} }
......
...@@ -179,6 +179,7 @@ ...@@ -179,6 +179,7 @@
,,y,script,./test.sh -f tsim/query/udf_with_const.sim ,,y,script,./test.sh -f tsim/query/udf_with_const.sim
,,y,script,./test.sh -f tsim/query/sys_tbname.sim ,,y,script,./test.sh -f tsim/query/sys_tbname.sim
,,y,script,./test.sh -f tsim/query/groupby.sim ,,y,script,./test.sh -f tsim/query/groupby.sim
,,y,script,./test.sh -f tsim/query/event.sim
,,y,script,./test.sh -f tsim/qnode/basic1.sim ,,y,script,./test.sh -f tsim/qnode/basic1.sim
,,y,script,./test.sh -f tsim/snode/basic1.sim ,,y,script,./test.sh -f tsim/snode/basic1.sim
,,y,script,./test.sh -f tsim/mnode/basic1.sim ,,y,script,./test.sh -f tsim/mnode/basic1.sim
......
...@@ -11,20 +11,18 @@ sql use db1; ...@@ -11,20 +11,18 @@ sql use db1;
sql create stable sta (ts timestamp, f1 int, f2 binary(10), f3 bool) tags(t1 int, t2 bool, t3 binary(10)); sql create stable sta (ts timestamp, f1 int, f2 binary(10), f3 bool) tags(t1 int, t2 bool, t3 binary(10));
sql create table tba1 using sta tags(0, false, '0'); sql create table tba1 using sta tags(0, false, '0');
sql create table tba2 using sta tags(1, true, '1'); sql create table tba2 using sta tags(1, true, '1');
sql create table tba3 using sta tags(null, null, '');
sql create table tba4 using sta tags(1, false, null);
sql create table tba5 using sta tags(3, true, 'aa');
sql insert into tba1 values ('2022-09-26 15:15:01', 0, "a", false); sql insert into tba1 values ('2022-09-26 15:15:01', 0, "a", false);
sql insert into tba1 values ('2022-09-26 15:15:02', 1, "0", true); sql insert into tba1 values ('2022-09-26 15:15:02', 1, "0", true);
sql insert into tba1 values ('2022-09-26 15:15:03', 5, "5", false); sql insert into tba1 values ('2022-09-26 15:15:03', 5, "5", false);
sql insert into tba1 values ('2022-09-26 15:15:04', 3, 'b', false); sql insert into tba1 values ('2022-09-26 15:15:04', 3, 'b', false);
sql insert into tba1 values ('2022-09-26 15:15:05', 0, '1', false); sql insert into tba1 values ('2022-09-26 15:15:05', 0, '1', false);
sql insert into tba1 values ('2022-09-26 15:15:06', 2, 'd', true); sql insert into tba1 values ('2022-09-26 15:15:06', 2, 'd', true);
sql insert into tba2 values ('2022-09-26 15:15:01', 0, "a", false);
sql insert into tba2 values ('2022-09-27 15:15:01', 0, "a", false); sql insert into tba2 values ('2022-09-26 15:15:02', 1, "0", true);
sql insert into tba2 values ('2022-09-27 15:15:02', 1, "0", true); sql insert into tba2 values ('2022-09-26 15:15:03', 5, "5", false);
sql insert into tba2 values ('2022-09-27 15:15:03', 5, "5", false); sql insert into tba2 values ('2022-09-26 15:15:04', 3, 'b', false);
sql insert into tba2 values ('2022-09-27 15:15:04', null, null, null); sql insert into tba2 values ('2022-09-26 15:15:05', 0, '1', false);
sql insert into tba2 values ('2022-09-26 15:15:06', 2, 'd', true);
# child table: no window # child table: no window
print ====> select count(*) from tba1 event_window start with f1 = 0 end with f2 = 'c'; print ====> select count(*) from tba1 event_window start with f1 = 0 end with f2 = 'c';
...@@ -35,7 +33,7 @@ endi ...@@ -35,7 +33,7 @@ endi
# child table: single row window # child table: single row window
print ====> select count(*) from tba1 event_window start with f1 = 0 end with f3 = false; print ====> select count(*) from tba1 event_window start with f1 = 0 end with f3 = false;
sql select count(*) from tba1 event_window start with f1 = 0 end with f3 = false sql select count(*) from tba1 event_window start with f1 = 0 end with f3 = false;
if $rows != 2 then if $rows != 2 then
return -1 return -1
endi endi
...@@ -66,4 +64,176 @@ if $data10 != 4 then ...@@ -66,4 +64,176 @@ if $data10 != 4 then
return -1 return -1
endi endi
# super table: no window
print ====> select count(*) from sta event_window start with f1 = 0 end with f2 = 'c';
sql select count(*) from sta event_window start with f1 = 0 end with f2 = 'c';
if $rows != 0 then
return -1
endi
# super table: single row window
print ====> select count(*) from sta event_window start with f1 = 0 end with f3 = false;
sql select count(*) from sta event_window start with f1 = 0 end with f3 = false;
if $rows != 4 then
return -1
endi
if $data00 != 1 then
return -1
endi
# super table: multi rows window
print ====> select count(*) from sta event_window start with f1 = 0 end with f2 = 'b';
sql select count(*) from sta event_window start with f1 = 0 end with f2 = 'b';
if $rows != 1 then
return -1
endi
if $data00 != 7 then
return -1
endi
# super table: multi windows
print ====> select count(*) from sta event_window start with f1 >= 0 end with f3 = true;
sql select count(*) from sta event_window start with f1 >= 0 end with f3 = true;
if $rows != 4 then
return -1
endi
if $data00 != 3 then
return -1
endi
if $data10 != 1 then
return -1
endi
if $data20 != 7 then
return -1
endi
if $data30 != 1 then
return -1
endi
# multi-child table: no window
print ====> select tbname, count(*) from sta partition by tbname event_window start with f1 = 0 end with f2 = 'c';
sql select tbname, count(*) from sta partition by tbname event_window start with f1 = 0 end with f2 = 'c';
if $rows != 0 then
return -1
endi
# multi-child table: single row window
print ====> select tbname, count(*) from sta partition by tbname event_window start with f1 = 0 end with f3 = false;
sql select tbname, count(*) from sta partition by tbname event_window start with f1 = 0 end with f3 = false;
if $rows != 4 then
return -1
endi
if $data01 != 1 then
return -1
endi
# multi-child table: multi rows window
print ====> select tbname, count(*) from sta partition by tbname event_window start with f1 = 0 end with f2 = 'b';
sql select tbname, count(*) from sta partition by tbname event_window start with f1 = 0 end with f2 = 'b';
if $rows != 2 then
return -1
endi
if $data01 != 4 then
return -1
endi
if $data11 != 4 then
return -1
endi
# multi-child table: multi windows
print ====> select tbname, count(*) from sta partition by tbname event_window start with f1 >= 0 end with f3 = true;
sql select tbname, count(*) from sta partition by tbname event_window start with f1 >= 0 end with f3 = true;
if $rows != 4 then
return -1
endi
if $data01 != 2 then
return -1
endi
if $data11 != 4 then
return -1
endi
# where + partition by
print ====> select tbname, count(*) from sta where f3 = false partition by tbname event_window start with f1 >0 end with f2 > 0;
sql select tbname, count(*) from sta where f3 = false partition by tbname event_window start with f1 >0 end with f2 > 0;
if $rows != 4 then
return -1
endi
if $data01 != 1 then
return -1
endi
if $data11 != 2 then
return -1
endi
# where + order by
print ====> select count(*) cnt from tba1 where f3 = false event_window start with f1 >0 end with f2 > 0 order by cnt desc;
sql select count(*) cnt from tba1 where f3 = false event_window start with f1 >0 end with f2 > 0 order by cnt desc;
if $rows != 2 then
return -1
endi
if $data00 != 2 then
return -1
endi
if $data10 != 1 then
return -1
endi
# where + partition by + order by
print ====> select tbname, count(*) cnt from sta where f3 = false partition by tbname event_window start with f1 >0 end with f2 > 0 order by cnt;
sql select tbname, count(*) cnt from sta where f3 = false partition by tbname event_window start with f1 >0 end with f2 > 0 order by cnt;
if $rows != 4 then
return -1
endi
if $data01 != 1 then
return -1
endi
if $data11 != 1 then
return -1
endi
# where + partition by + order by + limit
print ====> select tbname, count(*) cnt from sta where f3 = false partition by tbname event_window start with f1 >0 end with f2 > 0 order by cnt limit 2 offset 2;
sql select tbname, count(*) cnt from sta where f3 = false partition by tbname event_window start with f1 >0 end with f2 > 0 order by cnt limit 2 offset 2;
if $rows != 2 then
return -1
endi
if $data01 != 2 then
return -1
endi
if $data11 != 2 then
return -1
endi
# subquery(where + partition by + order by + limit)
print ====> select * from (select tbname tname, count(*) cnt from sta where f3 = false partition by tbname event_window start with f1 >0 end with f2 > 0 order by cnt limit 2 offset 2);
sql select * from (select tbname tname, count(*) cnt from sta where f3 = false partition by tbname event_window start with f1 >0 end with f2 > 0 order by cnt limit 2 offset 2);
if $rows != 2 then
return -1
endi
if $data01 != 2 then
return -1
endi
if $data11 != 2 then
return -1
endi
# subquery + where + partition by + order by + limit
print ====> select tname, count(*) cnt from (select tbname tname, * from sta) where f3 = false partition by tname event_window start with f1 >0 end with f2 > 0 order by cnt limit 2 offset 2;
sql select tname, count(*) cnt from (select tbname tname, * from sta) where f3 = false partition by tname event_window start with f1 >0 end with f2 > 0 order by cnt limit 2 offset 2;
if $rows != 2 then
return -1
endi
if $data01 != 2 then
return -1
endi
if $data11 != 2 then
return -1
endi
sql_error select f1, f2 from sta event_window start with f1 >0 end with f2 > 0;
sql_error select count(*) from sta event_window start with f1 >0 end with f2 > 0 partition by tbname;
sql_error select count(*) from sta event_window start with f1 >0 end with f2 > 0 group by tbname;
sql_error select count(*) from sta event_window start with f1 >0 end with f2 > 0 fill(NULL);
system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode1 -s stop -x SIGINT
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册