提交 5bdbf9b4 编写于 作者: H hjLiao

[TD-288]support alias name in from clause

上级 65e1ca3c
...@@ -53,9 +53,10 @@ typedef struct SMeterMetaInfo { ...@@ -53,9 +53,10 @@ typedef struct SMeterMetaInfo {
* 2. keep the vnode index for multi-vnode insertion * 2. keep the vnode index for multi-vnode insertion
*/ */
int32_t vnodeIndex; int32_t vnodeIndex;
char name[TSDB_METER_ID_LEN + 1]; // table(super table) name char name[TSDB_METER_ID_LEN + 1]; // table(super table) name
int16_t numOfTags; // total required tags in query, including groupby tags char aliasName[TSDB_METER_ID_LEN + 1]; // alias name
int16_t tagColumnIndex[TSDB_MAX_TAGS]; // clause + tag projection int16_t numOfTags; // total required tags in query, including groupby tags
int16_t tagColumnIndex[TSDB_MAX_TAGS]; // clause + tag projection
} SMeterMetaInfo; } SMeterMetaInfo;
/* the structure for sql function in select clause */ /* the structure for sql function in select clause */
......
...@@ -366,7 +366,7 @@ void tVariantListDestroy(tVariantList *pList) { ...@@ -366,7 +366,7 @@ void tVariantListDestroy(tVariantList *pList) {
free(pList); free(pList);
} }
tVariantList *tVariantListAppendToken(tVariantList *pList, SSQLToken *pAliasToken, uint8_t sortOrder) { tVariantList *tVariantListAppendToken(tVariantList *pList, SSQLToken *pToken, uint8_t sortOrder) {
if (pList == NULL) { if (pList == NULL) {
pList = calloc(1, sizeof(tVariantList)); pList = calloc(1, sizeof(tVariantList));
} }
...@@ -375,9 +375,9 @@ tVariantList *tVariantListAppendToken(tVariantList *pList, SSQLToken *pAliasToke ...@@ -375,9 +375,9 @@ tVariantList *tVariantListAppendToken(tVariantList *pList, SSQLToken *pAliasToke
return pList; return pList;
} }
if (pAliasToken) { if (pToken) {
tVariant t = {0}; tVariant t = {0};
tVariantCreate(&t, pAliasToken); tVariantCreate(&t, pToken);
tVariantListItem *pItem = &pList->a[pList->nExpr++]; tVariantListItem *pItem = &pList->a[pList->nExpr++];
memcpy(pItem, &t, sizeof(tVariant)); memcpy(pItem, &t, sizeof(tVariant));
......
...@@ -406,8 +406,10 @@ as(X) ::= . { X.n = 0; } ...@@ -406,8 +406,10 @@ as(X) ::= . { X.n = 0; }
from(A) ::= FROM tablelist(X). {A = X;} from(A) ::= FROM tablelist(X). {A = X;}
%type tablelist {tVariantList*} %type tablelist {tVariantList*}
tablelist(A) ::= ids(X) cpxName(Y). { toTSDBType(X.type); X.n += Y.n; A = tVariantListAppendToken(NULL, &X, -1);} tablelist(A) ::= ids(X) cpxName(Y). { toTSDBType(X.type); X.n += Y.n; A = tVariantListAppendToken(NULL, &X, -1); A = tVariantListAppendToken(A, &X, -1);}
tablelist(A) ::= tablelist(Y) COMMA ids(X) cpxName(Z). { toTSDBType(X.type); X.n += Z.n; A = tVariantListAppendToken(Y, &X, -1); } tablelist(A) ::= ids(X) cpxName(Y) ids(Z). { toTSDBType(X.type); X.n += Y.n; A = tVariantListAppendToken(NULL, &X, -1); A = tVariantListAppendToken(A, &Z, -1);}
tablelist(A) ::= tablelist(Y) COMMA ids(X) cpxName(Z). { toTSDBType(X.type); X.n += Z.n; A = tVariantListAppendToken(Y, &X, -1); A = tVariantListAppendToken(A, &X, -1); }
tablelist(A) ::= tablelist(Y) COMMA ids(X) cpxName(Z) ids(F). { toTSDBType(X.type); X.n += Z.n; A = tVariantListAppendToken(Y, &X, -1); A = tVariantListAppendToken(A, &F, -1); }
// The value of interval should be the form of "number+[a,s,m,h,d,n,y]" or "now" // The value of interval should be the form of "number+[a,s,m,h,d,n,y]" or "now"
%type tmvar {SSQLToken} %type tmvar {SSQLToken}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册