feat(query)[TS-5058]: support AUTO OFFSET in INTERVAL clause

Add the AUTO keyword, which allows automatic determination of the
INTERVAL OFFSET based on the WHERE condition. It simplifies usage by
allowing users to rely on the system to infer the correct offset
without manual specification.
This commit is contained in:
Jinqing Kuang 2024-12-03 19:25:30 +08:00
parent bfd6f7609b
commit c2256e9443
34 changed files with 3445 additions and 59 deletions

View File

@ -130,11 +130,25 @@ The forward sliding time of SLIDING cannot exceed the time range of one window.
SELECT COUNT(*) FROM temp_tb_1 INTERVAL(1m) SLIDING(2m);
```
The INTERVAL clause allows the use of the AUTO keyword to specify the window offset. If the WHERE condition provides a clear applicable start time limit, the required offset will be automatically calculated, dividing the time window from that point; otherwise, it defaults to an offset of 0. Here are some simple examples:
```sql
-- With a start time limit, divide the time window from '2018-10-03 14:38:05'
SELECT COUNT(*) FROM meters WHERE _rowts >= '2018-10-03 14:38:05' INTERVAL (1m, AUTO);
-- Without a start time limit, defaults to an offset of 0
SELECT COUNT(*) FROM meters WHERE _rowts < '2018-10-03 15:00:00' INTERVAL (1m, AUTO);
-- Unclear start time limit, defaults to an offset of 0
SELECT COUNT(*) FROM meters WHERE _rowts - voltage > 1000000;
```
When using time windows, note:
- The window width of the aggregation period is specified by the keyword INTERVAL, with the shortest interval being 10 milliseconds (10a); it also supports an offset (the offset must be less than the interval), which is the offset of the time window division compared to "UTC moment 0". The SLIDING statement is used to specify the forward increment of the aggregation period, i.e., the duration of each window slide forward.
- When using the INTERVAL statement, unless in very special cases, it is required to configure the timezone parameter in the taos.cfg configuration files of both the client and server to the same value to avoid frequent cross-time zone conversions by time processing functions, which can cause severe performance impacts.
- The returned results have a strictly monotonically increasing time-series.
- When using AUTO as the window offset, if the window width unit is d (day), n (month), w (week), y (year), such as: INTERVAL(1d, AUTO), INTERVAL(3w, AUTO), the TSMA optimization cannot take effect. If TSMA is manually created on the target table, the statement will report an error and exit; in this case, you can explicitly specify the Hint SKIP_TSMA or not use AUTO as the window offset.
### State Window

View File

@ -120,11 +120,25 @@ SLIDING 的向前滑动的时间不能超过一个窗口的时间范围。以下
SELECT COUNT(*) FROM temp_tb_1 INTERVAL(1m) SLIDING(2m);
```
INTERVAL 子句允许使用 AUTO 关键字来指定窗口偏移量,此时如果 WHERE 条件给定了明确可应用的起始时间限制,则会自动计算所需偏移量,使得从该时间点切分时间窗口;否则不生效,即:仍以 0 作为偏移量。以下是简单示例说明:
```sql
-- 有起始时间限制,从 '2018-10-03 14:38:05' 切分时间窗口
SELECT COUNT(*) FROM meters WHERE _rowts >= '2018-10-03 14:38:05' INTERVAL (1m AUTO);
-- 无起始时间限制,不生效,仍以 0 为偏移量
SELECT COUNT(*) FROM meters WHERE _rowts < '2018-10-03 15:00:00' INTERVAL (1m, AUTO);
-- 起始时间限制不明确,不生效,仍以 0 为偏移量
SELECT COUNT(*) FROM meters WHERE _rowts - voltage > 1000000;
```
使用时间窗口需要注意:
- 聚合时间段的窗口宽度由关键词 INTERVAL 指定,最短时间间隔 10 毫秒10a并且支持偏移 offset偏移必须小于间隔也即时间窗口划分与“UTC 时刻 0”相比的偏移量。SLIDING 语句用于指定聚合时间段的前向增量,也即每次窗口向前滑动的时长。
- 使用 INTERVAL 语句时,除非极特殊的情况,都要求把客户端和服务端的 taos.cfg 配置文件中的 timezone 参数配置为相同的取值,以避免时间处理函数频繁进行跨时区转换而导致的严重性能影响。
- 返回的结果中时间序列严格单调递增。
- 使用 AUTO 作为窗口偏移量时,如果窗口宽度的单位是 d (天), n (月), w (周), y (年),比如: INTERVAL(1d, AUTO), INTERVAL(3w, AUTO),此时 TSMA 优化无法生效。如果目标表上手动创建了TSMA语句会报错退出这种情况下可以显式指定 Hint SKIP_TSMA 或者不使用 AUTO 作为窗口偏移量。
### 状态窗口

View File

@ -1242,14 +1242,15 @@ typedef struct {
} STsBufInfo;
typedef struct {
int32_t tz; // query client timezone
char intervalUnit;
char slidingUnit;
char offsetUnit;
int8_t precision;
int64_t interval;
int64_t sliding;
int64_t offset;
int32_t tz; // query client timezone
char intervalUnit;
char slidingUnit;
char offsetUnit;
int8_t precision;
int64_t interval;
int64_t sliding;
int64_t offset;
STimeWindow timeRange;
} SInterval;
typedef struct STbVerInfo {

View File

@ -36,6 +36,9 @@ extern "C" {
#define TIME_UNIT_MONTH 'n'
#define TIME_UNIT_YEAR 'y'
#define AUTO_DURATION_LITERAL "auto"
#define AUTO_DURATION_VALUE -1
/*
* @return timestamp decided by global conf variable, tsTimePrecision
* if precision == TSDB_TIME_PRECISION_MICRO, it returns timestamp in microsecond.
@ -78,6 +81,7 @@ int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision);
int64_t taosTimeTruncate(int64_t ts, const SInterval* pInterval);
int64_t taosTimeGetIntervalEnd(int64_t ts, const SInterval* pInterval);
int32_t taosTimeCountIntervalForFill(int64_t skey, int64_t ekey, int64_t interval, char unit, int32_t precision, int32_t order);
void calcIntervalAutoOffset(SInterval* interval);
int32_t parseAbsoluteDuration(const char* token, int32_t tokenlen, int64_t* ts, char* unit, int32_t timePrecision);
int32_t parseNatualDuration(const char* token, int32_t tokenLen, int64_t* duration, char* unit, int32_t timePrecision, bool negativeAllow);

View File

@ -192,8 +192,9 @@ void qProcessRspMsg(void* parent, struct SRpcMsg* pMsg, struct SEpSet* pEpSet);
int32_t qGetExplainExecInfo(qTaskInfo_t tinfo, SArray* pExecInfoList);
void getNextTimeWindow(const SInterval* pInterval, STimeWindow* tw, int32_t order);
void getInitialStartTimeWindow(SInterval* pInterval, TSKEY ts, STimeWindow* w, bool ascQuery);
TSKEY getNextTimeWindowStart(const SInterval* pInterval, TSKEY start, int32_t order);
void getNextTimeWindow(const SInterval* pInterval, STimeWindow* tw, int32_t order);
void getInitialStartTimeWindow(SInterval* pInterval, TSKEY ts, STimeWindow* w, bool ascQuery);
STimeWindow getAlignQueryTimeWindow(const SInterval* pInterval, int64_t key);
SArray* qGetQueriedTableListInfo(qTaskInfo_t tinfo);

View File

@ -319,6 +319,7 @@ typedef struct SWindowLogicNode {
int64_t sliding;
int8_t intervalUnit;
int8_t slidingUnit;
STimeWindow timeRange;
int64_t sessionGap;
SNode* pTspk;
SNode* pTsEnd;
@ -682,6 +683,7 @@ typedef struct SIntervalPhysiNode {
int64_t sliding;
int8_t intervalUnit;
int8_t slidingUnit;
STimeWindow timeRange;
} SIntervalPhysiNode;
typedef SIntervalPhysiNode SMergeIntervalPhysiNode;

View File

@ -325,12 +325,13 @@ typedef struct SSessionWindowNode {
} SSessionWindowNode;
typedef struct SIntervalWindowNode {
ENodeType type; // QUERY_NODE_INTERVAL_WINDOW
SNode* pCol; // timestamp primary key
SNode* pInterval; // SValueNode
SNode* pOffset; // SValueNode
SNode* pSliding; // SValueNode
SNode* pFill;
ENodeType type; // QUERY_NODE_INTERVAL_WINDOW
SNode* pCol; // timestamp primary key
SNode* pInterval; // SValueNode
SNode* pOffset; // SValueNode
SNode* pSliding; // SValueNode
SNode* pFill;
STimeWindow timeRange;
} SIntervalWindowNode;
typedef struct SEventWindowNode {

View File

@ -968,6 +968,7 @@ int32_t taosGetErrSize();
#define TSDB_CODE_TSMA_MUST_BE_DROPPED TAOS_DEF_ERROR_CODE(0, 0x3110)
#define TSDB_CODE_TSMA_NAME_TOO_LONG TAOS_DEF_ERROR_CODE(0, 0x3111)
#define TSDB_CODE_TSMA_INVALID_RECURSIVE_INTERVAL TAOS_DEF_ERROR_CODE(0, 0x3112)
#define TSDB_CODE_TSMA_INVALID_AUTO_OFFSET TAOS_DEF_ERROR_CODE(0, 0x3113)
//rsma
#define TSDB_CODE_RSMA_INVALID_ENV TAOS_DEF_ERROR_CODE(0, 0x3150)

View File

@ -809,6 +809,7 @@ int64_t taosTimeTruncate(int64_t ts, const SInterval* pInterval) {
news += (int64_t)(timezone * TSDB_TICK_PER_SECOND(precision));
}
start = news;
if (news <= ts) {
int64_t prev = news;
int64_t newe = taosTimeAdd(news, pInterval->interval, pInterval->intervalUnit, precision) - 1;
@ -828,7 +829,7 @@ int64_t taosTimeTruncate(int64_t ts, const SInterval* pInterval) {
}
}
return prev;
start = prev;
}
} else {
int64_t delta = ts - pInterval->interval;
@ -881,8 +882,8 @@ int64_t taosTimeTruncate(int64_t ts, const SInterval* pInterval) {
while (newe >= ts) {
start = slidingStart;
slidingStart = taosTimeAdd(slidingStart, -pInterval->sliding, pInterval->slidingUnit, precision);
int64_t slidingEnd = taosTimeAdd(slidingStart, pInterval->interval, pInterval->intervalUnit, precision) - 1;
newe = taosTimeAdd(slidingEnd, pInterval->offset, pInterval->offsetUnit, precision);
int64_t news = taosTimeAdd(slidingStart, pInterval->offset, pInterval->offsetUnit, precision);
newe = taosTimeAdd(news, pInterval->interval, pInterval->intervalUnit, precision) - 1;
}
start = taosTimeAdd(start, pInterval->offset, pInterval->offsetUnit, precision);
}
@ -892,17 +893,37 @@ int64_t taosTimeTruncate(int64_t ts, const SInterval* pInterval) {
// used together with taosTimeTruncate. when offset is great than zero, slide-start/slide-end is the anchor point
int64_t taosTimeGetIntervalEnd(int64_t intervalStart, const SInterval* pInterval) {
if (pInterval->offset > 0) {
int64_t slideStart =
taosTimeAdd(intervalStart, -1 * pInterval->offset, pInterval->offsetUnit, pInterval->precision);
int64_t slideEnd = taosTimeAdd(slideStart, pInterval->interval, pInterval->intervalUnit, pInterval->precision) - 1;
int64_t result = taosTimeAdd(slideEnd, pInterval->offset, pInterval->offsetUnit, pInterval->precision);
return result;
} else {
int64_t result = taosTimeAdd(intervalStart, pInterval->interval, pInterval->intervalUnit, pInterval->precision) - 1;
return result;
}
return taosTimeAdd(intervalStart, pInterval->interval, pInterval->intervalUnit, pInterval->precision) - 1;
}
void calcIntervalAutoOffset(SInterval* interval) {
if (!interval || interval->offset != AUTO_DURATION_VALUE) {
return;
}
interval->offset = 0;
if (interval->timeRange.skey == INT64_MIN) {
return;
}
TSKEY skey = interval->timeRange.skey;
TSKEY start = taosTimeTruncate(skey, interval);
TSKEY news = start;
while (news <= skey) {
start = news;
news = taosTimeAdd(start, interval->sliding, interval->slidingUnit, interval->precision);
if (news < start) {
// overflow happens
uError("%s failed and skip, skey [%" PRId64 "], inter[%" PRId64 "(%c)], slid[%" PRId64 "(%c)], precision[%d]",
__func__, skey, interval->interval, interval->intervalUnit, interval->sliding, interval->slidingUnit,
interval->precision);
return;
}
}
interval->offset = skey - start;
}
// internal function, when program is paused in debugger,
// one can call this function from debugger to print a
// timestamp as human readable string, for example (gdb):

View File

@ -990,6 +990,9 @@ static int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx
EXPLAIN_ROW_APPEND_SLIMIT(pIntNode->window.node.pSlimit);
EXPLAIN_ROW_END();
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_TIMERANGE_FORMAT, pIntNode->timeRange.skey, pIntNode->timeRange.ekey);
EXPLAIN_ROW_END();
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
uint8_t precision = qExplainGetIntervalPrecision(pIntNode);
int64_t time1 = -1;
int64_t time2 = -1;

View File

@ -2289,7 +2289,9 @@ SInterval extractIntervalInfo(const STableScanPhysiNode* pTableScanNode) {
.slidingUnit = pTableScanNode->slidingUnit,
.offset = pTableScanNode->offset,
.precision = pTableScanNode->scan.node.pOutputDataBlockDesc->precision,
.timeRange = pTableScanNode->scanRange,
};
calcIntervalAutoOffset(&interval);
return interval;
}
@ -2409,13 +2411,14 @@ void getInitialStartTimeWindow(SInterval* pInterval, TSKEY ts, STimeWindow* w, b
int64_t key = w->skey;
while (key < ts) { // moving towards end
key = taosTimeAdd(key, pInterval->sliding, pInterval->slidingUnit, pInterval->precision);
key = getNextTimeWindowStart(pInterval, key, TSDB_ORDER_ASC);
if (key > ts) {
break;
}
w->skey = key;
}
w->ekey = taosTimeAdd(w->skey, pInterval->interval, pInterval->intervalUnit, pInterval->precision) - 1;
}
}
@ -2428,14 +2431,12 @@ static STimeWindow doCalculateTimeWindow(int64_t ts, SInterval* pInterval) {
}
STimeWindow getFirstQualifiedTimeWindow(int64_t ts, STimeWindow* pWindow, SInterval* pInterval, int32_t order) {
int32_t factor = (order == TSDB_ORDER_ASC) ? -1 : 1;
STimeWindow win = *pWindow;
STimeWindow save = win;
while (win.skey <= ts && win.ekey >= ts) {
save = win;
win.skey = taosTimeAdd(win.skey, factor * pInterval->sliding, pInterval->slidingUnit, pInterval->precision);
win.ekey = taosTimeAdd(win.ekey, factor * pInterval->sliding, pInterval->slidingUnit, pInterval->precision);
// get previous time window
getNextTimeWindow(pInterval, &win, order == TSDB_ORDER_ASC ? TSDB_ORDER_DESC : TSDB_ORDER_ASC);
}
return save;
@ -2448,7 +2449,6 @@ STimeWindow getActiveTimeWindow(SDiskbasedBuf* pBuf, SResultRowInfo* pResultRowI
STimeWindow w = {0};
if (pResultRowInfo->cur.pageId == -1) { // the first window, from the previous stored value
getInitialStartTimeWindow(pInterval, ts, &w, (order == TSDB_ORDER_ASC));
w.ekey = taosTimeGetIntervalEnd(w.skey, pInterval);
return w;
}
@ -2471,19 +2471,17 @@ STimeWindow getActiveTimeWindow(SDiskbasedBuf* pBuf, SResultRowInfo* pResultRowI
return w;
}
void getNextTimeWindow(const SInterval* pInterval, STimeWindow* tw, int32_t order) {
int64_t slidingStart = 0;
if (pInterval->offset > 0) {
slidingStart = taosTimeAdd(tw->skey, -1 * pInterval->offset, pInterval->offsetUnit, pInterval->precision);
} else {
slidingStart = tw->skey;
}
TSKEY getNextTimeWindowStart(const SInterval* pInterval, TSKEY start, int32_t order) {
int32_t factor = GET_FORWARD_DIRECTION_FACTOR(order);
slidingStart = taosTimeAdd(slidingStart, factor * pInterval->sliding, pInterval->slidingUnit, pInterval->precision);
tw->skey = taosTimeAdd(slidingStart, pInterval->offset, pInterval->offsetUnit, pInterval->precision);
int64_t slidingEnd =
taosTimeAdd(slidingStart, pInterval->interval, pInterval->intervalUnit, pInterval->precision) - 1;
tw->ekey = taosTimeAdd(slidingEnd, pInterval->offset, pInterval->offsetUnit, pInterval->precision);
TSKEY nextStart = taosTimeAdd(start, -1 * pInterval->offset, pInterval->offsetUnit, pInterval->precision);
nextStart = taosTimeAdd(nextStart, factor * pInterval->sliding, pInterval->slidingUnit, pInterval->precision);
nextStart = taosTimeAdd(nextStart, pInterval->offset, pInterval->offsetUnit, pInterval->precision);
return nextStart;
}
void getNextTimeWindow(const SInterval* pInterval, STimeWindow* tw, int32_t order) {
tw->skey = getNextTimeWindowStart(pInterval, tw->skey, order);
tw->ekey = taosTimeAdd(tw->skey, pInterval->interval, pInterval->intervalUnit, pInterval->precision) - 1;
}
bool hasLimitOffsetInfo(SLimitInfo* pLimitInfo) {

View File

@ -578,7 +578,9 @@ int32_t createStreamIntervalSliceOperatorInfo(SOperatorInfo* downstream, SPhysiN
.intervalUnit = pIntervalPhyNode->intervalUnit,
.slidingUnit = pIntervalPhyNode->slidingUnit,
.offset = pIntervalPhyNode->offset,
.precision = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->node.resType.precision};
.precision = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->node.resType.precision,
.timeRange = pIntervalPhyNode->timeRange};
calcIntervalAutoOffset(&pInfo->interval);
pInfo->twAggSup =
(STimeWindowAggSupp){.waterMark = pIntervalPhyNode->window.watermark,

View File

@ -1932,7 +1932,9 @@ int32_t createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, SPhysiN
.intervalUnit = pIntervalPhyNode->intervalUnit,
.slidingUnit = pIntervalPhyNode->slidingUnit,
.offset = pIntervalPhyNode->offset,
.precision = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->node.resType.precision};
.precision = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->node.resType.precision,
.timeRange = pIntervalPhyNode->timeRange};
calcIntervalAutoOffset(&pInfo->interval);
pInfo->twAggSup = (STimeWindowAggSupp){
.waterMark = pIntervalPhyNode->window.watermark,
.calTrigger = pIntervalPhyNode->window.triggerType,
@ -5342,7 +5344,9 @@ static int32_t createStreamSingleIntervalOperatorInfo(SOperatorInfo* downstream,
.slidingUnit = pIntervalPhyNode->slidingUnit,
.offset = pIntervalPhyNode->offset,
.precision = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->node.resType.precision,
.timeRange = pIntervalPhyNode->timeRange,
};
calcIntervalAutoOffset(&pInfo->interval);
pInfo->twAggSup =
(STimeWindowAggSupp){.waterMark = pIntervalPhyNode->window.watermark,

View File

@ -1401,7 +1401,9 @@ int32_t createIntervalOperatorInfo(SOperatorInfo* downstream, SIntervalPhysiNode
.intervalUnit = pPhyNode->intervalUnit,
.slidingUnit = pPhyNode->slidingUnit,
.offset = pPhyNode->offset,
.precision = ((SColumnNode*)pPhyNode->window.pTspk)->node.resType.precision};
.precision = ((SColumnNode*)pPhyNode->window.pTspk)->node.resType.precision,
.timeRange = pPhyNode->timeRange};
calcIntervalAutoOffset(&interval);
STimeWindowAggSupp as = {
.waterMark = pPhyNode->window.watermark,
@ -2122,7 +2124,9 @@ int32_t createMergeAlignedIntervalOperatorInfo(SOperatorInfo* downstream, SMerge
.intervalUnit = pNode->intervalUnit,
.slidingUnit = pNode->slidingUnit,
.offset = pNode->offset,
.precision = ((SColumnNode*)pNode->window.pTspk)->node.resType.precision};
.precision = ((SColumnNode*)pNode->window.pTspk)->node.resType.precision,
.timeRange = pNode->timeRange};
calcIntervalAutoOffset(&interval);
SIntervalAggOperatorInfo* iaInfo = miaInfo->intervalAggOperatorInfo;
SExprSupp* pSup = &pOperator->exprSupp;
@ -2462,7 +2466,9 @@ int32_t createMergeIntervalOperatorInfo(SOperatorInfo* downstream, SMergeInterva
.intervalUnit = pIntervalPhyNode->intervalUnit,
.slidingUnit = pIntervalPhyNode->slidingUnit,
.offset = pIntervalPhyNode->offset,
.precision = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->node.resType.precision};
.precision = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->node.resType.precision,
.timeRange = pIntervalPhyNode->timeRange};
calcIntervalAutoOffset(&interval);
pMergeIntervalInfo->groupIntervals = tdListNew(sizeof(SGroupTimeWindow));

View File

@ -387,6 +387,7 @@ static int32_t intervalWindowNodeCopy(const SIntervalWindowNode* pSrc, SInterval
CLONE_NODE_FIELD(pOffset);
CLONE_NODE_FIELD(pSliding);
CLONE_NODE_FIELD(pFill);
COPY_OBJECT_FIELD(timeRange, sizeof(STimeWindow));
return TSDB_CODE_SUCCESS;
}
@ -615,6 +616,7 @@ static int32_t logicWindowCopy(const SWindowLogicNode* pSrc, SWindowLogicNode* p
COPY_SCALAR_FIELD(sliding);
COPY_SCALAR_FIELD(intervalUnit);
COPY_SCALAR_FIELD(slidingUnit);
COPY_OBJECT_FIELD(timeRange, sizeof(STimeWindow));
COPY_SCALAR_FIELD(sessionGap);
CLONE_NODE_FIELD(pTspk);
CLONE_NODE_FIELD(pTsEnd);
@ -805,6 +807,7 @@ static int32_t physiIntervalCopy(const SIntervalPhysiNode* pSrc, SIntervalPhysiN
COPY_SCALAR_FIELD(sliding);
COPY_SCALAR_FIELD(intervalUnit);
COPY_SCALAR_FIELD(slidingUnit);
COPY_OBJECT_FIELD(timeRange, sizeof(STimeWindow));
return TSDB_CODE_SUCCESS;
}

View File

@ -1014,6 +1014,8 @@ static const char* jkWindowLogicPlanOffset = "Offset";
static const char* jkWindowLogicPlanSliding = "Sliding";
static const char* jkWindowLogicPlanIntervalUnit = "IntervalUnit";
static const char* jkWindowLogicPlanSlidingUnit = "SlidingUnit";
static const char* jkWindowLogicPlanStartTime = "StartTime";
static const char* jkWindowLogicPlanEndTime = "EndTime";
static const char* jkWindowLogicPlanSessionGap = "SessionGap";
static const char* jkWindowLogicPlanTspk = "Tspk";
static const char* jkWindowLogicPlanStateExpr = "StateExpr";
@ -1046,6 +1048,12 @@ static int32_t logicWindowNodeToJson(const void* pObj, SJson* pJson) {
if (TSDB_CODE_SUCCESS == code) {
code = tjsonAddIntegerToObject(pJson, jkWindowLogicPlanSlidingUnit, pNode->slidingUnit);
}
if (TSDB_CODE_SUCCESS == code) {
code = tjsonAddIntegerToObject(pJson, jkWindowLogicPlanStartTime, pNode->timeRange.skey);
}
if (TSDB_CODE_SUCCESS == code) {
code = tjsonAddIntegerToObject(pJson, jkWindowLogicPlanEndTime, pNode->timeRange.ekey);
}
if (TSDB_CODE_SUCCESS == code) {
code = tjsonAddIntegerToObject(pJson, jkWindowLogicPlanSessionGap, pNode->sessionGap);
}
@ -1093,6 +1101,12 @@ static int32_t jsonToLogicWindowNode(const SJson* pJson, void* pObj) {
if (TSDB_CODE_SUCCESS == code) {
code = tjsonGetTinyIntValue(pJson, jkWindowLogicPlanSlidingUnit, &pNode->slidingUnit);
}
if (TSDB_CODE_SUCCESS == code) {
code = tjsonGetBigIntValue(pJson, jkWindowLogicPlanStartTime, &pNode->timeRange.skey);
}
if (TSDB_CODE_SUCCESS == code) {
code = tjsonGetBigIntValue(pJson, jkWindowLogicPlanEndTime, &pNode->timeRange.ekey);
}
if (TSDB_CODE_SUCCESS == code) {
code = tjsonGetBigIntValue(pJson, jkWindowLogicPlanSessionGap, &pNode->sessionGap);
}
@ -2944,6 +2958,8 @@ static const char* jkIntervalPhysiPlanOffset = "Offset";
static const char* jkIntervalPhysiPlanSliding = "Sliding";
static const char* jkIntervalPhysiPlanIntervalUnit = "intervalUnit";
static const char* jkIntervalPhysiPlanSlidingUnit = "slidingUnit";
static const char* jkIntervalPhysiPlanStartTime = "StartTime";
static const char* jkIntervalPhysiPlanEndTime = "EndTime";
static int32_t physiIntervalNodeToJson(const void* pObj, SJson* pJson) {
const SIntervalPhysiNode* pNode = (const SIntervalPhysiNode*)pObj;
@ -2964,6 +2980,12 @@ static int32_t physiIntervalNodeToJson(const void* pObj, SJson* pJson) {
if (TSDB_CODE_SUCCESS == code) {
code = tjsonAddIntegerToObject(pJson, jkIntervalPhysiPlanSlidingUnit, pNode->slidingUnit);
}
if (TSDB_CODE_SUCCESS == code) {
code = tjsonAddIntegerToObject(pJson, jkIntervalPhysiPlanStartTime, pNode->timeRange.skey);
}
if (TSDB_CODE_SUCCESS == code) {
code = tjsonAddIntegerToObject(pJson, jkIntervalPhysiPlanEndTime, pNode->timeRange.ekey);
}
return code;
}
@ -2987,6 +3009,12 @@ static int32_t jsonToPhysiIntervalNode(const SJson* pJson, void* pObj) {
if (TSDB_CODE_SUCCESS == code) {
code = tjsonGetTinyIntValue(pJson, jkIntervalPhysiPlanSlidingUnit, &pNode->slidingUnit);
}
if (TSDB_CODE_SUCCESS == code) {
code = tjsonGetBigIntValue(pJson, jkIntervalPhysiPlanStartTime, &pNode->timeRange.skey);
}
if (TSDB_CODE_SUCCESS == code) {
code = tjsonGetBigIntValue(pJson, jkIntervalPhysiPlanEndTime, &pNode->timeRange.ekey);
}
return code;
}
@ -5058,6 +5086,8 @@ static const char* jkIntervalWindowOffset = "Offset";
static const char* jkIntervalWindowSliding = "Sliding";
static const char* jkIntervalWindowFill = "Fill";
static const char* jkIntervalWindowTsPk = "TsPk";
static const char* jkIntervalStartTime = "StartTime";
static const char* jkIntervalEndTime = "EndTime";
static int32_t intervalWindowNodeToJson(const void* pObj, SJson* pJson) {
const SIntervalWindowNode* pNode = (const SIntervalWindowNode*)pObj;
@ -5075,6 +5105,12 @@ static int32_t intervalWindowNodeToJson(const void* pObj, SJson* pJson) {
if (TSDB_CODE_SUCCESS == code) {
code = tjsonAddObject(pJson, jkIntervalWindowTsPk, nodeToJson, pNode->pCol);
}
if (TSDB_CODE_SUCCESS == code) {
code = tjsonAddIntegerToObject(pJson, jkIntervalStartTime, pNode->timeRange.skey);
}
if (TSDB_CODE_SUCCESS == code) {
code = tjsonAddIntegerToObject(pJson, jkIntervalEndTime, pNode->timeRange.ekey);
}
return code;
}
@ -5095,6 +5131,12 @@ static int32_t jsonToIntervalWindowNode(const SJson* pJson, void* pObj) {
if (TSDB_CODE_SUCCESS == code) {
code = jsonToNodeObject(pJson, jkIntervalWindowTsPk, &pNode->pCol);
}
if (TSDB_CODE_SUCCESS == code) {
code = tjsonGetBigIntValue(pJson, jkIntervalStartTime, &pNode->timeRange.skey);
}
if (TSDB_CODE_SUCCESS == code) {
code = tjsonGetBigIntValue(pJson, jkIntervalEndTime, &pNode->timeRange.ekey);
}
return code;
}

View File

@ -3250,7 +3250,7 @@ static int32_t msgToPhysiWindowNode(STlvDecoder* pDecoder, void* pObj) {
return code;
}
enum { PHY_INTERVAL_CODE_WINDOW = 1, PHY_INTERVAL_CODE_INLINE_ATTRS };
enum { PHY_INTERVAL_CODE_WINDOW = 1, PHY_INTERVAL_CODE_INLINE_ATTRS, PHY_INTERVAL_CODE_TIME_RANGE };
static int32_t physiIntervalNodeInlineToMsg(const void* pObj, STlvEncoder* pEncoder) {
const SIntervalPhysiNode* pNode = (const SIntervalPhysiNode*)pObj;
@ -3279,6 +3279,9 @@ static int32_t physiIntervalNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
if (TSDB_CODE_SUCCESS == code) {
code = tlvEncodeObj(pEncoder, PHY_INTERVAL_CODE_INLINE_ATTRS, physiIntervalNodeInlineToMsg, pNode);
}
if (TSDB_CODE_SUCCESS == code) {
code = tlvEncodeObj(pEncoder, PHY_INTERVAL_CODE_TIME_RANGE, timeWindowToMsg, &pNode->timeRange);
}
return code;
}
@ -3316,6 +3319,8 @@ static int32_t msgToPhysiIntervalNode(STlvDecoder* pDecoder, void* pObj) {
case PHY_INTERVAL_CODE_INLINE_ATTRS:
code = tlvDecodeObjFromTlv(pTlv, msgToPhysiIntervalNodeInline, pNode);
break;
case PHY_INTERVAL_CODE_TIME_RANGE:
code = tlvDecodeObjFromTlv(pTlv, msgToTimeWindow, &pNode->timeRange);
default:
break;
}

View File

@ -143,6 +143,8 @@ TEST_F(NodesCloneTest, intervalWindow) {
if (NULL != pSrcNode->pFill) {
ASSERT_EQ(nodeType(pSrcNode->pFill), nodeType(pDstNode->pFill));
}
ASSERT_EQ(pSrcNode->timeRange.skey, pDstNode->timeRange.skey);
ASSERT_EQ(pSrcNode->timeRange.ekey, pDstNode->timeRange.ekey);
});
std::unique_ptr<SNode, void (*)(SNode*)> srcNode(nullptr, nodesDestroyNode);
@ -156,6 +158,8 @@ TEST_F(NodesCloneTest, intervalWindow) {
code = nodesMakeNode(QUERY_NODE_VALUE, &pNode->pOffset);
code = nodesMakeNode(QUERY_NODE_VALUE, &pNode->pSliding);
code = nodesMakeNode(QUERY_NODE_FILL, &pNode->pFill);
pNode->timeRange.skey = 1666756692907;
pNode->timeRange.ekey = 1666756699907;
return srcNode.get();
}());
}

View File

@ -1523,6 +1523,9 @@ twindow_clause_opt(A) ::=
INTERVAL NK_LP interval_sliding_duration_literal(B) NK_COMMA
interval_sliding_duration_literal(C) NK_RP
sliding_opt(D) fill_opt(E). { A = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C), D, E); }
twindow_clause_opt(A) ::=
INTERVAL NK_LP interval_sliding_duration_literal(B) NK_COMMA
AUTO(C) NK_RP sliding_opt(D) fill_opt(E). { A = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, B), createDurationValueNode(pCxt, &C), D, E); }
twindow_clause_opt(A) ::=
EVENT_WINDOW START WITH search_condition(B) END WITH search_condition(C). { A = createEventWindowNode(pCxt, B, C); }
twindow_clause_opt(A) ::=

View File

@ -1399,6 +1399,7 @@ SNode* createIntervalWindowNode(SAstCreateContext* pCxt, SNode* pInterval, SNode
interval->pOffset = pOffset;
interval->pSliding = pSliding;
interval->pFill = pFill;
interval->timeRange = TSWINDOW_INITIALIZER;
return (SNode*)interval;
_err:
nodesDestroyNode((SNode*)interval);

View File

@ -351,6 +351,7 @@ static SKeyword keywordTable[] = {
{"IS_IMPORT", TK_IS_IMPORT},
{"FORCE_WINDOW_CLOSE", TK_FORCE_WINDOW_CLOSE},
{"DISK_INFO", TK_DISK_INFO},
{"AUTO", TK_AUTO},
};
// clang-format on

View File

@ -1994,8 +1994,11 @@ static int32_t parseBoolFromValueNode(STranslateContext* pCxt, SValueNode* pVal)
}
static EDealRes translateDurationValue(STranslateContext* pCxt, SValueNode* pVal) {
if (parseNatualDuration(pVal->literal, strlen(pVal->literal), &pVal->datum.i, &pVal->unit,
pVal->node.resType.precision, false) != TSDB_CODE_SUCCESS) {
if (strncmp(pVal->literal, AUTO_DURATION_LITERAL, strlen(AUTO_DURATION_LITERAL) + 1) == 0) {
pVal->datum.i = AUTO_DURATION_VALUE;
pVal->unit = getPrecisionUnit(pVal->node.resType.precision);
} else if (parseNatualDuration(pVal->literal, strlen(pVal->literal), &pVal->datum.i, &pVal->unit,
pVal->node.resType.precision, false) != TSDB_CODE_SUCCESS) {
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal);
}
*(int64_t*)&pVal->typeData = pVal->datum.i;
@ -5840,7 +5843,13 @@ static int32_t checkIntervalWindow(STranslateContext* pCxt, SIntervalWindowNode*
if (NULL != pInterval->pOffset) {
SValueNode* pOffset = (SValueNode*)pInterval->pOffset;
if (pOffset->datum.i <= 0) {
if (pOffset->datum.i == AUTO_DURATION_VALUE) {
if (pOffset->unit != getPrecisionUnit(precision)) {
parserError("invalid offset unit %d for auto offset with precision %u", pOffset->unit, precision);
return TSDB_CODE_INVALID_PARA;
}
}
else if (pOffset->datum.i < 0) {
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_OFFSET_NEGATIVE);
}
if (pInter->unit == 'n' && pOffset->unit == 'y') {
@ -5904,9 +5913,52 @@ static int32_t checkIntervalWindow(STranslateContext* pCxt, SIntervalWindowNode*
return TSDB_CODE_SUCCESS;
}
void tryCalcIntervalAutoOffset(SIntervalWindowNode *pInterval) {
SValueNode* pOffset = (SValueNode*)pInterval->pOffset;
uint8_t precision = ((SColumnNode*)pInterval->pCol)->node.resType.precision;
SValueNode* pInter = (SValueNode*)pInterval->pInterval;
SValueNode* pSliding = (SValueNode*)pInterval->pSliding;
if (pOffset == NULL || pOffset->datum.i != AUTO_DURATION_VALUE) {
return;
}
// ignore auto offset if not applicable
if (pInterval->timeRange.skey == INT64_MIN) {
pOffset->datum.i = 0;
return;
}
SInterval interval = {.interval = pInter->datum.i,
.sliding = (pSliding != NULL) ? pSliding->datum.i : pInter->datum.i,
.intervalUnit = pInter->unit,
.slidingUnit = (pSliding != NULL) ? pSliding->unit : pInter->unit,
.offset = pOffset->datum.i,
.precision = precision,
.timeRange = pInterval->timeRange};
/**
* Considering that the client and server may be in different time zones,
* these situations need to be deferred to the server for calculation.
*/
if (IS_CALENDAR_TIME_DURATION(interval.intervalUnit) || interval.intervalUnit == 'd' ||
interval.intervalUnit == 'w' || IS_CALENDAR_TIME_DURATION(interval.slidingUnit) || interval.slidingUnit == 'd' ||
interval.slidingUnit == 'w') {
return;
}
calcIntervalAutoOffset(&interval);
pOffset->datum.i = interval.offset;
}
static int32_t translateIntervalWindow(STranslateContext* pCxt, SSelectStmt* pSelect) {
SIntervalWindowNode* pInterval = (SIntervalWindowNode*)pSelect->pWindow;
int32_t code = checkIntervalWindow(pCxt, pInterval);
int32_t code = TSDB_CODE_SUCCESS;
pInterval->timeRange = pSelect->timeRange;
tryCalcIntervalAutoOffset(pInterval);
code = checkIntervalWindow(pCxt, pInterval);
if (TSDB_CODE_SUCCESS == code) {
code = translateFill(pCxt, pSelect, pInterval);
}
@ -9047,6 +9099,13 @@ static int32_t buildIntervalForSampleAst(SSampleAstInfo* pInfo, SNode** pOutput)
TSWAP(pInterval->pInterval, pInfo->pInterval);
TSWAP(pInterval->pOffset, pInfo->pOffset);
TSWAP(pInterval->pSliding, pInfo->pSliding);
SValueNode* pOffset = (SValueNode*)pInterval->pOffset;
if (pOffset && pOffset->datum.i < 0) {
parserError("%s failed for invalid interval offset %" PRId64, __func__, pOffset->datum.i);
return TSDB_CODE_INVALID_PARA;
}
pInterval->pCol = NULL;
code = nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)&pInterval->pCol);
if (NULL == pInterval->pCol) {
@ -10058,6 +10117,10 @@ int32_t createIntervalFromCreateSmaIndexStmt(SCreateIndexStmt* pStmt, SInterval*
pInterval->slidingUnit =
NULL != pStmt->pOptions->pSliding ? ((SValueNode*)pStmt->pOptions->pSliding)->unit : pInterval->intervalUnit;
pInterval->precision = pStmt->pOptions->tsPrecision;
if (pInterval->offset < 0) {
parserError("%s failed for invalid interval offset %" PRId64, __func__, pInterval->offset);
return TSDB_CODE_INVALID_PARA;
}
return TSDB_CODE_SUCCESS;
}
@ -11909,6 +11972,7 @@ static int32_t buildIntervalForCreateStream(SCreateStreamStmt* pStmt, SInterval*
pInterval->slidingUnit =
(NULL != pWindow->pSliding ? ((SValueNode*)pWindow->pSliding)->unit : pInterval->intervalUnit);
pInterval->precision = ((SColumnNode*)pWindow->pCol)->node.resType.precision;
pInterval->timeRange = pWindow->timeRange;
return code;
}

View File

@ -1186,6 +1186,7 @@ static int32_t createWindowLogicNodeByInterval(SLogicPlanContext* pCxt, SInterva
return code;
}
pWindow->isPartTb = pSelect->pPartitionByList ? keysHasTbname(pSelect->pPartitionByList) : 0;
pWindow->timeRange = pInterval->timeRange;
return createWindowLogicNodeFinalize(pCxt, pSelect, pWindow, pLogicNode);
}

View File

@ -6728,6 +6728,20 @@ static bool tsmaOptMayBeOptimized(SLogicNode* pNode, void* pCtx) {
}
}
if (nodeType(pParent) == QUERY_NODE_LOGIC_PLAN_WINDOW) {
SWindowLogicNode* pWindow = (SWindowLogicNode*)pParent;
if (pWindow->winType == WINDOW_TYPE_INTERVAL && pWindow->offset == AUTO_DURATION_VALUE) {
SLogicNode* pRootNode = getLogicNodeRootNode(pParent);
// When using interval auto offset, tsma optimization cannot take effect.
// Unless the user explicitly specifies not to use tsma, an error should be reported.
if (!getOptHint(pRootNode->pHint, HINT_SKIP_TSMA)) {
planError("%s failed since tsma optimization cannot be applied with interval auto offset", __func__);
*(int32_t*)pCtx = TSDB_CODE_TSMA_INVALID_AUTO_OFFSET;
return false;
}
}
}
return true;
}
return false;
@ -7502,7 +7516,7 @@ static bool tsmaOptIsUsingTsmas(STSMAOptCtx* pCtx) {
static int32_t tsmaOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan) {
int32_t code = 0;
STSMAOptCtx tsmaOptCtx = {0};
SScanLogicNode* pScan = (SScanLogicNode*)optFindPossibleNode(pLogicSubplan->pNode, tsmaOptMayBeOptimized, NULL);
SScanLogicNode* pScan = (SScanLogicNode*)optFindPossibleNode(pLogicSubplan->pNode, tsmaOptMayBeOptimized, &code);
if (!pScan) return code;
SLogicNode* pRootNode = getLogicNodeRootNode((SLogicNode*)pScan);

View File

@ -2260,6 +2260,7 @@ static int32_t createIntervalPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChil
pInterval->sliding = pWindowLogicNode->sliding;
pInterval->intervalUnit = pWindowLogicNode->intervalUnit;
pInterval->slidingUnit = pWindowLogicNode->slidingUnit;
pInterval->timeRange = pWindowLogicNode->timeRange;
int32_t code = createWindowPhysiNodeFinalize(pCxt, pChildren, &pInterval->window, pWindowLogicNode);
if (TSDB_CODE_SUCCESS == code) {

View File

@ -812,6 +812,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_UNSUPPORTED_FUNC, "Tsma func not suppo
TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_MUST_BE_DROPPED, "Tsma must be dropped first")
TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_NAME_TOO_LONG, "Tsma name too long")
TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_INVALID_RECURSIVE_INTERVAL,"Invalid recursive tsma interval")
TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_INVALID_AUTO_OFFSET, "TSMA optimization cannot be applied with INTERVAL AUTO offset. Use SKIP_TSMA hint to skip TSMA optimization or specify a manual offset.")
//rsma
TAOS_DEFINE_ERROR(TSDB_CODE_RSMA_INVALID_ENV, "Invalid rsma env")

View File

@ -1839,7 +1839,8 @@ class TDCom:
tdLog.exit(f"Input file '{inputfile}' does not exist.")
else:
self.query_result_file = f"./temp_{test_case}.result"
os.system(f"taos -f {inputfile} | grep -v 'Query OK'|grep -v 'Copyright'| grep -v 'Welcome to the TDengine Command' > {self.query_result_file} ")
cfgPath = self.getClientCfgPath()
os.system(f"taos -c {cfgPath} -f {inputfile} | grep -v 'Query OK'|grep -v 'Copyright'| grep -v 'Welcome to the TDengine Command' > {self.query_result_file} ")
return self.query_result_file
def compare_result_files(self, file1, file2):

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,160 @@
select _wstart, _wend, _wduration, count(*) from test.st interval(1m, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts < '2020-10-01 00:07:19' interval(1m, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts <= '2020-09-30 23:59:59' interval(1h, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts = '2020-10-01 23:45:00' interval(1s, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts = '2020-10-01 23:45:00' interval(1m, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts = '2020-11-01 23:45:00' interval(1h, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts = '2020-12-01 23:45:00' interval(1d, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts in ('2020-10-01 23:45:00') interval(1s, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts in ('2020-10-01 23:45:00') interval(1m, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts in ('2020-11-01 23:45:00') interval(1h, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts in ('2020-12-01 23:45:00') interval(1d, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts = '2020-10-01 23:45:00' interval(1s, auto) sliding(700a) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts = '2020-10-01 23:45:00' interval(1m, auto) sliding(37s) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts = '2020-11-01 23:45:00' interval(1h, auto) sliding(27m) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts = '2020-12-01 23:45:00' interval(1d, auto) sliding(17h) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts in ('2020-10-01 23:45:00') interval(1s, auto) sliding(700a) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts in ('2020-10-01 23:45:00') interval(1m, auto) sliding(37s) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts in ('2020-11-01 23:45:00') interval(1h, auto) sliding(27m) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts in ('2020-12-01 23:45:00') interval(1d, auto) sliding(17h) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts = '2020-11-12 23:32:43' interval(1n, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts = '2020-11-12 23:32:00' interval(1n, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts in ('2020-11-12 23:32:43') interval(1n, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts in ('2020-11-12 23:32:00') interval(1n, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts = '2020-11-12 23:32:43' interval(1n, auto) sliding(9d) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts = '2020-11-12 23:32:00' interval(1n, auto) sliding(9d) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts in ('2020-11-12 23:32:43') interval(1n, auto) sliding(13d) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts in ('2020-11-12 23:32:00') interval(1n, auto) sliding(13d) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts > '2020-10-09 01:23:00' interval(1s, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts > '2020-10-09 01:23:00' interval(1m, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts > '2020-11-09 01:23:00' interval(1h, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts > '2020-12-09 01:23:00' interval(1d, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts >= '2020-10-09 01:23:00' interval(1s, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts >= '2020-10-09 01:23:00' interval(1m, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts >= '2020-11-09 01:23:00' interval(1h, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts >= '2020-12-09 01:23:00' interval(1d, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts in ('2020-10-09 01:23:00', '2020-11-09 01:23:00', '2020-12-09 01:23:00') interval(1s, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts in ('2020-10-09 01:23:00', '2020-11-09 01:23:00', '2020-12-09 01:23:00') interval(1m, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts in ('2020-10-09 01:23:00', '2020-11-09 01:23:00', '2020-12-09 01:23:00') interval(1h, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts in ('2020-10-09 01:23:00', '2020-11-09 01:23:00', '2020-12-09 01:23:00') interval(1d, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts > '2020-10-09 01:23:00' interval(1s, auto) sliding(700a) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts > '2020-10-09 01:23:00' interval(1m, auto) sliding(37s) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts > '2020-11-09 01:23:00' interval(1h, auto) sliding(27m) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts > '2020-12-09 01:23:00' interval(1d, auto) sliding(17h) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts >= '2020-10-09 01:23:00' interval(1s, auto) sliding(700a) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts >= '2020-10-09 01:23:00' interval(1m, auto) sliding(37s) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts >= '2020-11-09 01:23:00' interval(1h, auto) sliding(27m) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts >= '2020-12-09 01:23:00' interval(1d, auto) sliding(17h) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts in ('2020-10-09 01:23:00', '2020-11-09 01:23:00', '2020-12-09 01:23:00') interval(1s, auto) sliding(700a) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts in ('2020-10-09 01:23:00', '2020-11-09 01:23:00', '2020-12-09 01:23:00') interval(1m, auto) sliding(37s) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts in ('2020-10-09 01:23:00', '2020-11-09 01:23:00', '2020-12-09 01:23:00') interval(1h, auto) sliding(27m) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts in ('2020-10-09 01:23:00', '2020-11-09 01:23:00', '2020-12-09 01:23:00') interval(1d, auto) sliding(17h) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts > '2020-10-09 01:23:00' interval(1n, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts > '2020-11-09 01:23:00' interval(1n, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts > '2020-12-09 01:23:00' interval(1n, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts > '2020-12-19 01:23:00' interval(1n, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts >= '2020-10-09 01:23:00' interval(1n, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts >= '2020-11-09 01:23:00' interval(1n, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts >= '2020-12-09 01:23:00' interval(1n, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts >= '2020-12-19 01:23:00' interval(1n, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts in ('2020-10-09 01:23:00', '2020-11-09 01:23:00', '2020-12-09 01:23:00') interval(1n, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts > '2020-10-09 01:23:00' interval(1n, auto) sliding(9d) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts > '2020-11-09 01:23:00' interval(1n, auto) sliding(9d) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts > '2020-12-09 01:23:00' interval(1n, auto) sliding(9d) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts > '2020-12-19 01:23:00' interval(1n, auto) sliding(9d) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts >= '2020-10-09 01:23:00' interval(1n, auto) sliding(13d) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts >= '2020-11-09 01:23:00' interval(1n, auto) sliding(13d) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts >= '2020-12-09 01:23:00' interval(1n, auto) sliding(13d) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts >= '2020-12-19 01:23:00' interval(1n, auto) sliding(13d) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts in ('2020-10-09 01:23:00', '2020-11-09 01:23:00', '2020-12-09 01:23:00') interval(1n, auto) sliding(9d) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts in ('2020-10-09 01:23:00', '2020-11-09 01:23:00', '2020-12-09 01:23:00') interval(1n, auto) sliding(13d) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts = cast('2020-10-01 23:45:00' as timestamp) + 1d interval(1s, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts = cast('2020-10-01 23:45:00' as timestamp) + 1d interval(1m, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts = cast('2020-11-01 23:45:00' as timestamp) + 1d interval(1h, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts = cast('2020-12-01 23:45:00' as timestamp) + 1d interval(1d, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts = cast('2020-10-01 23:45:00' as timestamp) + 1d interval(1s, auto) sliding(700a) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts = cast('2020-10-01 23:45:00' as timestamp) + 1d interval(1m, auto) sliding(37s) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts = cast('2020-11-01 23:45:00' as timestamp) + 1d interval(1h, auto) sliding(27m) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts = cast('2020-12-01 23:45:00' as timestamp) + 1d interval(1d, auto) sliding(17h) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts = cast('2020-11-12 23:32:43' as timestamp) + 1d interval(1n, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts = cast('2020-11-12 23:32:00' as timestamp) + 1d interval(1n, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts = cast('2020-11-12 23:32:00' as timestamp) + 1d interval(1n, auto) sliding(9d) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts = cast('2020-11-12 23:32:00' as timestamp) + 1d interval(1n, auto) sliding(13d) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts > cast('2020-10-08 01:23:00' as timestamp) + 1d interval(1s, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts > cast('2020-10-08 01:23:00' as timestamp) + 1d interval(1m, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts > cast('2020-11-08 01:23:00' as timestamp) + 1d interval(1h, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts > cast('2020-12-08 01:23:00' as timestamp) + 1d interval(1d, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts >= cast('2020-10-08 01:23:00' as timestamp) + 1d interval(1s, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts >= cast('2020-10-08 01:23:00' as timestamp) + 1d interval(1m, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts >= cast('2020-11-08 01:23:00' as timestamp) + 1d interval(1h, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts >= cast('2020-12-08 01:23:00' as timestamp) + 1d interval(1d, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts > cast('2020-10-08 01:23:00' as timestamp) + 1d interval(1s, auto) sliding(700a) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts > cast('2020-10-08 01:23:00' as timestamp) + 1d interval(1m, auto) sliding(37s) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts > cast('2020-11-08 01:23:00' as timestamp) + 1d interval(1h, auto) sliding(27m) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts > cast('2020-12-08 01:23:00' as timestamp) + 1d interval(1d, auto) sliding(17h) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts >= cast('2020-10-08 01:23:00' as timestamp) + 1d interval(1s, auto) sliding(700a) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts >= cast('2020-10-08 01:23:00' as timestamp) + 1d interval(1m, auto) sliding(37s) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts >= cast('2020-11-08 01:23:00' as timestamp) + 1d interval(1h, auto) sliding(27m) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts >= cast('2020-12-08 01:23:00' as timestamp) + 1d interval(1d, auto) sliding(17h) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts > cast('2020-10-08 01:23:00' as timestamp) + 1d interval(1n, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts > cast('2020-11-08 01:23:00' as timestamp) + 1d interval(1n, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts > cast('2020-12-08 01:23:00' as timestamp) + 1d interval(1n, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts > cast('2020-12-18 01:23:00' as timestamp) + 1d interval(1n, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts >= cast('2020-10-08 01:23:00' as timestamp) + 1d interval(1n, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts >= cast('2020-11-08 01:23:00' as timestamp) + 1d interval(1n, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts >= cast('2020-12-08 01:23:00' as timestamp) + 1d interval(1n, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts >= cast('2020-12-18 01:23:00' as timestamp) + 1d interval(1n, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts > cast('2020-10-08 01:23:00' as timestamp) + 1d interval(1n, auto) sliding(9d) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts > cast('2020-11-08 01:23:00' as timestamp) + 1d interval(1n, auto) sliding(9d) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts > cast('2020-12-08 01:23:00' as timestamp) + 1d interval(1n, auto) sliding(9d) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts > cast('2020-12-18 01:23:00' as timestamp) + 1d interval(1n, auto) sliding(9d) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts >= cast('2020-10-08 01:23:00' as timestamp) + 1d interval(1n, auto) sliding(13d) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts >= cast('2020-11-08 01:23:00' as timestamp) + 1d interval(1n, auto) sliding(13d) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts >= cast('2020-12-08 01:23:00' as timestamp) + 1d interval(1n, auto) sliding(13d) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts >= cast('2020-12-18 01:23:00' as timestamp) + 1d interval(1n, auto) sliding(13d) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts > i1 interval(1h, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts > i1 and ts <= bi2 interval(1d, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts >= i1 or ts < bi2 interval(1n, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts - 1d = '2020-11-11 23:32:00' interval(1h, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts - 1d in ('2020-10-08 01:23:00', '2020-11-08 01:23:00', '2020-12-08 01:23:00', '2020-12-18 01:23:00') interval(1d, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts - 1d >= '2020-11-08 01:23:00' interval(1n, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts = cast('2020-10-08 01:23:00' as timestamp) + 1d or ts >= '2020-11-19 11:22:00' interval(1s, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where (ts >= '2020-10-02 23:45:00' and ts < '2020-10-12 23:32:00') or (ts > '2020-11-12 23:32:00' and ts = '2020-12-02 23:45:00') interval(1s, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where (ts >= '2020-10-02 23:45:00' and ts < '2020-10-12 23:32:00') or ts in ('2020-10-09 01:23:00', '2020-11-09 01:23:00', '2020-12-09 01:23:00') interval(1s, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts = cast('2020-10-08 01:23:00' as timestamp) + 1d or ts >= '2020-11-19 11:22:00' interval(1m, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where (ts >= '2020-10-02 23:45:00' and ts < '2020-10-12 23:32:00') or (ts > '2020-11-12 23:32:00' and ts = '2020-12-02 23:45:00') interval(1m, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where (ts >= '2020-10-02 23:45:00' and ts < '2020-10-12 23:32:00') or ts in ('2020-10-09 01:23:00', '2020-11-09 01:23:00', '2020-12-09 01:23:00') interval(1m, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts = cast('2020-10-08 01:23:00' as timestamp) + 1d or ts >= '2020-11-19 11:22:00' interval(1h, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where (ts >= '2020-10-02 23:45:00' and ts < '2020-10-12 23:32:00') or (ts > '2020-11-12 23:32:00' and ts = '2020-12-02 23:45:00') interval(1h, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where (ts >= '2020-10-02 23:45:00' and ts < '2020-10-12 23:32:00') or ts in ('2020-10-09 01:23:00', '2020-11-09 01:23:00', '2020-12-09 01:23:00') interval(1h, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts = cast('2020-10-08 01:23:00' as timestamp) + 1d or ts >= '2020-11-19 11:22:00' interval(1d, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where (ts >= '2020-10-02 23:45:00' and ts < '2020-10-12 23:32:00') or (ts > '2020-11-12 23:32:00' and ts = '2020-12-02 23:45:00') interval(1d, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where (ts >= '2020-10-02 23:45:00' and ts < '2020-10-12 23:32:00') or ts in ('2020-10-09 01:23:00', '2020-11-09 01:23:00', '2020-12-09 01:23:00') interval(1d, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts = cast('2020-10-08 01:23:00' as timestamp) + 1d or ts >= '2020-11-19 11:22:00' interval(1s, auto) sliding(700a) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where (ts >= '2020-10-02 23:45:00' and ts < '2020-10-12 23:32:00') or (ts > '2020-11-12 23:32:00' and ts = '2020-12-02 23:45:00') interval(1s, auto) sliding(700a) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where (ts >= '2020-10-02 23:45:00' and ts < '2020-10-12 23:32:00') or ts in ('2020-10-09 01:23:00', '2020-11-09 01:23:00', '2020-12-09 01:23:00') interval(1s, auto) sliding(700a) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts = cast('2020-10-08 01:23:00' as timestamp) + 1d or ts >= '2020-11-19 11:22:00' interval(1m, auto) sliding(37s) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where (ts >= '2020-10-02 23:45:00' and ts < '2020-10-12 23:32:00') or (ts > '2020-11-12 23:32:00' and ts = '2020-12-02 23:45:00') interval(1m, auto) sliding(37s) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where (ts >= '2020-10-02 23:45:00' and ts < '2020-10-12 23:32:00') or ts in ('2020-10-09 01:23:00', '2020-11-09 01:23:00', '2020-12-09 01:23:00') interval(1m, auto) sliding(37s) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts = cast('2020-10-08 01:23:00' as timestamp) + 1d or ts >= '2020-11-19 11:22:00' interval(1h, auto) sliding(27m) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where (ts >= '2020-10-02 23:45:00' and ts < '2020-10-12 23:32:00') or (ts > '2020-11-12 23:32:00' and ts = '2020-12-02 23:45:00') interval(1h, auto) sliding(27m) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where (ts >= '2020-10-02 23:45:00' and ts < '2020-10-12 23:32:00') or ts in ('2020-10-09 01:23:00', '2020-11-09 01:23:00', '2020-12-09 01:23:00') interval(1h, auto) sliding(27m) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts = cast('2020-10-08 01:23:00' as timestamp) + 1d or ts >= '2020-11-19 11:22:00' interval(1d, auto) sliding(17h) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where (ts >= '2020-10-02 23:45:00' and ts < '2020-10-12 23:32:00') or (ts > '2020-11-12 23:32:00' and ts = '2020-12-02 23:45:00') interval(1d, auto) sliding(17h) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where (ts >= '2020-10-02 23:45:00' and ts < '2020-10-12 23:32:00') or ts in ('2020-10-09 01:23:00', '2020-11-09 01:23:00', '2020-12-09 01:23:00') interval(1d, auto) sliding(17h) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts = cast('2020-10-08 01:23:00' as timestamp) + 1d or ts >= '2020-11-19 11:22:00' interval(1n, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where (ts >= '2020-10-02 23:45:00' and ts < '2020-10-12 23:32:00') or (ts > '2020-11-12 23:32:00' and ts = '2020-12-02 23:45:00') interval(1n, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where (ts >= '2020-10-02 23:45:00' and ts < '2020-10-12 23:32:00') or ts in ('2020-10-09 01:23:00', '2020-11-09 01:23:00', '2020-12-09 01:23:00') interval(1n, auto) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts = cast('2020-10-08 01:23:00' as timestamp) + 1d or ts >= '2020-11-19 11:22:00' interval(1n, auto) sliding(9d) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where (ts >= '2020-10-02 23:45:00' and ts < '2020-10-12 23:32:00') or (ts > '2020-11-12 23:32:00' and ts = '2020-12-02 23:45:00') interval(1n, auto) sliding(9d) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where (ts >= '2020-10-02 23:45:00' and ts < '2020-10-12 23:32:00') or ts in ('2020-10-09 01:23:00', '2020-11-09 01:23:00', '2020-12-09 01:23:00') interval(1n, auto) sliding(9d) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where ts = cast('2020-10-08 01:23:00' as timestamp) + 1d or ts >= '2020-11-19 11:22:00' interval(1n, auto) sliding(13d) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where (ts >= '2020-10-02 23:45:00' and ts < '2020-10-12 23:32:00') or (ts > '2020-11-12 23:32:00' and ts = '2020-12-02 23:45:00') interval(1n, auto) sliding(13d) limit 10;
select _wstart, _wend, _wduration, count(*) from test.st where (ts >= '2020-10-02 23:45:00' and ts < '2020-10-12 23:32:00') or ts in ('2020-10-09 01:23:00', '2020-11-09 01:23:00', '2020-12-09 01:23:00') interval(1n, auto) sliding(13d) limit 10;
select * from test.sta;
select * from test.stb;
select * from test.stc;
select * from test.std;
select * from test.ste;
select * from test.stf;
select * from test.stg;

View File

@ -0,0 +1,67 @@
{
"filetype": "insert",
"cfgdir": "/etc/taos",
"host": "127.0.0.1",
"port": 6030,
"user": "root",
"password": "taosdata",
"connection_pool_size": 8,
"thread_count": 4,
"create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"num_of_records_per_req": 10000,
"prepared_rand": 10000,
"chinese": "no",
"escape_character": "yes",
"continue_if_fail": "no",
"databases": [
{
"dbinfo": {
"name": "test",
"drop": "yes",
"vgroups": 4,
"precision": "ms",
"keep": "3650"
},
"super_tables": [
{
"name": "st",
"child_table_exists": "no",
"childtable_count": 1,
"childtable_prefix": "ct",
"auto_create_table": "no",
"batch_create_tbl_num": 5,
"data_source": "rand",
"insert_mode": "taosc",
"non_stop_mode": "no",
"line_protocol": "line",
"insert_rows": 100000,
"childtable_limit": 0,
"childtable_offset": 0,
"interlace_rows": 0,
"insert_interval": 0,
"partial_col_num": 0,
"timestamp_step": 60000,
"start_timestamp": "2020-10-01 00:00:00.000",
"sample_format": "csv",
"sample_file": "./sample.csv",
"use_sample_ts": "no",
"tags_file": "",
"columns": [
{"type": "INT", "name": "i1"},
{"type": "BIGINT", "name": "bi2"},
{"type": "FLOAT", "name": "f3"},
{"type": "DOUBLE", "name": "d4"}
],
"tags": [
{"type": "TINYINT", "name": "groupid", "max": 10, "min": 1},
{"name": "location","type": "binary", "len": 16, "values":
["San Francisco", "Los Angles", "San Diego", "San Jose", "Palo Alto", "Campbell", "Mountain View","Sunnyvale", "Santa Clara", "Cupertino"]
}
]
}
]
}
]
}

View File

@ -0,0 +1,79 @@
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
from frame import etool
from frame.etool import *
from frame.log import *
from frame.cases import *
from frame.sql import *
from frame.caseBase import *
from frame.common import *
class TDTestCase(TBase):
def init(self, conn, logSql, replicaVar=1):
self.replicaVar = int(replicaVar)
tdLog.debug(f"start to excute {__file__}")
tdSql.init(conn.cursor(), True)
def insert_data(self):
tdLog.info("insert interval test data.")
# taosBenchmark run
json = etool.curFile(__file__, "interval.json")
etool.benchMark(json = json)
def create_streams(self):
tdSql.execute("use test;")
streams = [
"create stream stream1 fill_history 1 into sta as select _wstart, _wend, _wduration, count(*) from test.st where ts < '2020-10-01 00:07:19' interval(1m, auto);",
"create stream stream2 fill_history 1 into stb as select _wstart, _wend, _wduration, count(*) from test.st where ts = '2020-11-01 23:45:00' interval(1h, auto) sliding(27m);",
"create stream stream3 fill_history 1 into stc as select _wstart, _wend, _wduration, count(*) from test.st where ts in ('2020-11-12 23:32:00') interval(1n, auto) sliding(13d);",
"create stream stream4 fill_history 1 into std as select _wstart, _wend, _wduration, count(*) from test.st where ts in ('2020-10-09 01:23:00', '2020-11-09 01:23:00', '2020-12-09 01:23:00') interval(1s, auto);",
"create stream stream5 fill_history 1 into ste as select _wstart, _wend, _wduration, count(*) from test.st where ts > '2020-12-09 01:23:00' interval(1d, auto) sliding(17h);",
"create stream stream6 fill_history 1 into stf as select _wstart, _wend, _wduration, count(*) from test.st where ts >= '2020-10-09 01:23:00' interval(1n, auto);",
"create stream stream7 fill_history 1 into stg as select _wstart, _wend, _wduration, count(*) from test.st where ts >= '2020-11-09 01:23:00' interval(1n, auto) sliding(13d);",
]
for sql in streams:
tdSql.execute(sql)
for i in range(50):
rows = tdSql.query("select * from information_schema.ins_stream_tasks where history_task_status is not null;")
if rows == 0:
break;
tdLog.info(f"i={i} wait for history data calculation finish ...")
time.sleep(1)
def query_test(self):
# read sql from .sql file and execute
tdLog.info("test normal query.")
self.sqlFile = etool.curFile(__file__, f"in/interval.in")
self.ansFile = etool.curFile(__file__, f"ans/interval.csv")
tdCom.compare_testcase_result(self.sqlFile, self.ansFile, "interval")
def run(self):
self.insert_data()
self.create_streams()
self.query_test()
def stop(self):
tdSql.execute("drop stream stream1;")
tdSql.execute("drop stream stream2;")
tdSql.execute("drop stream stream3;")
tdSql.execute("drop stream stream4;")
tdSql.execute("drop stream stream5;")
tdSql.execute("drop stream stream6;")
tdSql.execute("drop stream stream7;")
tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase())

View File

@ -0,0 +1,57 @@
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
from frame import etool
from frame.etool import *
from frame.log import *
from frame.cases import *
from frame.sql import *
from frame.caseBase import *
from frame.common import *
class TDTestCase(TBase):
clientCfgDict = { "timezone": "UTC" }
updatecfgDict = {
"timezone": "UTC-8",
"clientCfg": clientCfgDict,
}
def init(self, conn, logSql, replicaVar=1):
self.replicaVar = int(replicaVar)
tdLog.debug(f"start to excute {__file__}")
tdSql.init(conn.cursor(), True)
def insert_data(self):
tdLog.info("insert interval test data.")
# taosBenchmark run
json = etool.curFile(__file__, "interval.json")
etool.benchMark(json = json)
def query_test(self):
# read sql from .sql file and execute
tdLog.info("test normal query.")
self.sqlFile = etool.curFile(__file__, f"in/interval.in")
self.ansFile = etool.curFile(__file__, f"ans/interval_diff_tz.csv")
tdCom.compare_testcase_result(self.sqlFile, self.ansFile, "interval_diff_tz")
def run(self):
self.insert_data()
self.query_test()
def stop(self):
tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase())

View File

@ -18,6 +18,8 @@
,,y,army,./pytest.sh python3 ./test.py -f query/function/test_percentile.py
,,y,army,./pytest.sh python3 ./test.py -f query/function/test_resinfo.py
,,y,army,./pytest.sh python3 ./test.py -f query/function/test_interp.py
,,y,army,./pytest.sh python3 ./test.py -f query/function/test_interval.py
,,y,army,./pytest.sh python3 ./test.py -f query/function/test_interval_diff_tz.py
,,y,army,./pytest.sh python3 ./test.py -f query/function/concat.py
,,y,army,./pytest.sh python3 ./test.py -f query/function/cast.py
,,y,army,./pytest.sh python3 ./test.py -f query/test_join.py