commit
4c3fd7639e
|
@ -4598,7 +4598,7 @@ static void setDefaultOrderInfo(SQueryInfo* pQueryInfo) {
|
||||||
int32_t parseOrderbyClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql, SSchema* pSchema) {
|
int32_t parseOrderbyClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql, SSchema* pSchema) {
|
||||||
const char* msg0 = "only support order by primary timestamp";
|
const char* msg0 = "only support order by primary timestamp";
|
||||||
const char* msg1 = "invalid column name";
|
const char* msg1 = "invalid column name";
|
||||||
const char* msg2 = "only support order by primary timestamp or queried column";
|
const char* msg2 = "only support order by primary timestamp or first tag in groupby clause allowed";
|
||||||
const char* msg3 = "invalid column in order by clause, only primary timestamp or first tag in groupby clause allowed";
|
const char* msg3 = "invalid column in order by clause, only primary timestamp or first tag in groupby clause allowed";
|
||||||
|
|
||||||
setDefaultOrderInfo(pQueryInfo);
|
setDefaultOrderInfo(pQueryInfo);
|
||||||
|
|
|
@ -1328,7 +1328,7 @@ static void stddev_function_f(SQLFunctionCtx *pCtx, int32_t index) {
|
||||||
/* the first stage is to calculate average value */
|
/* the first stage is to calculate average value */
|
||||||
if (pStd->stage == 0) {
|
if (pStd->stage == 0) {
|
||||||
avg_function_f(pCtx, index);
|
avg_function_f(pCtx, index);
|
||||||
} else {
|
} else if (pStd->num > 0) {
|
||||||
double avg = pStd->avg;
|
double avg = pStd->avg;
|
||||||
void * pData = GET_INPUT_DATA(pCtx, index);
|
void * pData = GET_INPUT_DATA(pCtx, index);
|
||||||
|
|
||||||
|
|
|
@ -143,6 +143,9 @@ SHistogramInfo* tHistogramCreateFrom(void* pBuf, int32_t numOfBins) {
|
||||||
|
|
||||||
SHistogramInfo* pHisto = (SHistogramInfo*)pBuf;
|
SHistogramInfo* pHisto = (SHistogramInfo*)pBuf;
|
||||||
pHisto->elems = (SHistBin*)((char*)pBuf + sizeof(SHistogramInfo));
|
pHisto->elems = (SHistBin*)((char*)pBuf + sizeof(SHistogramInfo));
|
||||||
|
for(int32_t i = 0; i < numOfBins; ++i) {
|
||||||
|
pHisto->elems[i].val = -DBL_MAX;
|
||||||
|
}
|
||||||
|
|
||||||
pHisto->maxEntries = numOfBins;
|
pHisto->maxEntries = numOfBins;
|
||||||
|
|
||||||
|
|
|
@ -4,42 +4,9 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "taos.h"
|
#include "taos.h"
|
||||||
#include "tsdb.h"
|
|
||||||
|
|
||||||
#include "tstoken.h"
|
|
||||||
#include "tutil.h"
|
|
||||||
|
|
||||||
#include "qHistogram.h"
|
#include "qHistogram.h"
|
||||||
|
namespace {
|
||||||
/* test validate the names for table/database */
|
void doHistogramAddTest() {
|
||||||
TEST(testCase, histogram_binary_search) {
|
|
||||||
SHistogramInfo* pHisto = tHistogramCreate(MAX_HISTOGRAM_BIN);
|
|
||||||
|
|
||||||
pHisto->numOfEntries = 10;
|
|
||||||
for (int32_t i = 0; i < 10; ++i) {
|
|
||||||
pHisto->elems[i].num = 1;
|
|
||||||
pHisto->elems[i].val = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t idx = histoBinarySearch(pHisto->elems, pHisto->numOfEntries, 1);
|
|
||||||
assert(idx == 1);
|
|
||||||
|
|
||||||
idx = histoBinarySearch(pHisto->elems, pHisto->numOfEntries, 9);
|
|
||||||
assert(idx == 9);
|
|
||||||
|
|
||||||
idx = histoBinarySearch(pHisto->elems, pHisto->numOfEntries, 20);
|
|
||||||
assert(idx == 10);
|
|
||||||
|
|
||||||
idx = histoBinarySearch(pHisto->elems, pHisto->numOfEntries, -1);
|
|
||||||
assert(idx == 0);
|
|
||||||
|
|
||||||
idx = histoBinarySearch(pHisto->elems, pHisto->numOfEntries, 3.9);
|
|
||||||
assert(idx == 4);
|
|
||||||
|
|
||||||
free(pHisto);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(testCase, histogram_add) {
|
|
||||||
SHistogramInfo* pHisto = NULL;
|
SHistogramInfo* pHisto = NULL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -99,6 +66,56 @@ TEST(testCase, histogram_add) {
|
||||||
tHistogramDestroy(&pRes);
|
tHistogramDestroy(&pRes);
|
||||||
free(res);
|
free(res);
|
||||||
}
|
}
|
||||||
|
void doHistogramRepeatTest() {
|
||||||
|
SHistogramInfo* pHisto = NULL;
|
||||||
|
struct timeval systemTime;
|
||||||
|
|
||||||
|
gettimeofday(&systemTime, NULL);
|
||||||
|
int64_t st =
|
||||||
|
(int64_t)systemTime.tv_sec * 1000L + (uint64_t)systemTime.tv_usec / 1000;
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < 1000; ++i) {
|
||||||
|
tHistogramAdd(&pHisto, -24 + i);
|
||||||
|
// tHistogramPrint(pHisto);
|
||||||
|
}
|
||||||
|
|
||||||
|
tHistogramDestroy(&pHisto);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* test validate the names for table/database */
|
||||||
|
TEST(testCase, histogram_binary_search) {
|
||||||
|
SHistogramInfo* pHisto = tHistogramCreate(MAX_HISTOGRAM_BIN);
|
||||||
|
|
||||||
|
pHisto->numOfEntries = 10;
|
||||||
|
for (int32_t i = 0; i < 10; ++i) {
|
||||||
|
pHisto->elems[i].num = 1;
|
||||||
|
pHisto->elems[i].val = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t idx = histoBinarySearch(pHisto->elems, pHisto->numOfEntries, 1);
|
||||||
|
assert(idx == 1);
|
||||||
|
|
||||||
|
idx = histoBinarySearch(pHisto->elems, pHisto->numOfEntries, 9);
|
||||||
|
assert(idx == 9);
|
||||||
|
|
||||||
|
idx = histoBinarySearch(pHisto->elems, pHisto->numOfEntries, 20);
|
||||||
|
assert(idx == 10);
|
||||||
|
|
||||||
|
idx = histoBinarySearch(pHisto->elems, pHisto->numOfEntries, -1);
|
||||||
|
assert(idx == 0);
|
||||||
|
|
||||||
|
idx = histoBinarySearch(pHisto->elems, pHisto->numOfEntries, 3.9);
|
||||||
|
assert(idx == 4);
|
||||||
|
|
||||||
|
free(pHisto);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(testCase, histogram_add) {
|
||||||
|
doHistogramAddTest();
|
||||||
|
doHistogramRepeatTest();
|
||||||
|
}
|
||||||
|
|
||||||
TEST(testCase, heapsort) {
|
TEST(testCase, heapsort) {
|
||||||
// int32_t num = 20;
|
// int32_t num = 20;
|
||||||
|
|
|
@ -73,6 +73,9 @@ endi
|
||||||
sql select * from stb where t1 > '1'
|
sql select * from stb where t1 > '1'
|
||||||
sql select * from stb where t1 > 'a'
|
sql select * from stb where t1 > 'a'
|
||||||
|
|
||||||
|
print =====================> TD-2685
|
||||||
|
sql_error select t1, count(t1) from stb;
|
||||||
|
|
||||||
## wildcard '%'
|
## wildcard '%'
|
||||||
#sql select * from stb where t1 like '%'
|
#sql select * from stb where t1 like '%'
|
||||||
#if $rows != 1 then
|
#if $rows != 1 then
|
||||||
|
|
Loading…
Reference in New Issue