diff --git a/src/client/inc/tsclient.h b/src/client/inc/tsclient.h index 42878cf520905af6ceb0dce0897cfbdb57c8bfb8..c2957842bf20c58e9f87e041f9d778069c75ac30 100644 --- a/src/client/inc/tsclient.h +++ b/src/client/inc/tsclient.h @@ -53,9 +53,10 @@ typedef struct SMeterMetaInfo { * 2. keep the vnode index for multi-vnode insertion */ int32_t vnodeIndex; - char name[TSDB_METER_ID_LEN + 1]; // table(super table) name - int16_t numOfTags; // total required tags in query, including groupby tags - int16_t tagColumnIndex[TSDB_MAX_TAGS]; // clause + tag projection + char name[TSDB_METER_ID_LEN + 1]; // table(super table) name + char aliasName[TSDB_METER_ID_LEN + 1]; // alias name + int16_t numOfTags; // total required tags in query, including groupby tags + int16_t tagColumnIndex[TSDB_MAX_TAGS]; // clause + tag projection } SMeterMetaInfo; /* the structure for sql function in select clause */ diff --git a/src/client/src/tscSQLParserImpl.c b/src/client/src/tscSQLParserImpl.c index 52a68a9a16670a6cacd7ac01b36503a629b849f3..44001fb31267150326e051c6e56ad52f4ad432f0 100644 --- a/src/client/src/tscSQLParserImpl.c +++ b/src/client/src/tscSQLParserImpl.c @@ -366,7 +366,7 @@ void tVariantListDestroy(tVariantList *pList) { free(pList); } -tVariantList *tVariantListAppendToken(tVariantList *pList, SSQLToken *pAliasToken, uint8_t sortOrder) { +tVariantList *tVariantListAppendToken(tVariantList *pList, SSQLToken *pToken, uint8_t sortOrder) { if (pList == NULL) { pList = calloc(1, sizeof(tVariantList)); } @@ -375,9 +375,9 @@ tVariantList *tVariantListAppendToken(tVariantList *pList, SSQLToken *pAliasToke return pList; } - if (pAliasToken) { + if (pToken) { tVariant t = {0}; - tVariantCreate(&t, pAliasToken); + tVariantCreate(&t, pToken); tVariantListItem *pItem = &pList->a[pList->nExpr++]; memcpy(pItem, &t, sizeof(tVariant)); diff --git a/src/inc/sql.y b/src/inc/sql.y index 2b7e0b628cb0cf951db287722036523749e0fdd8..db94ec62a85f4640d5b0c5c21bf0e9224413aa29 100644 --- a/src/inc/sql.y +++ b/src/inc/sql.y @@ -406,8 +406,10 @@ as(X) ::= . { X.n = 0; } from(A) ::= FROM tablelist(X). {A = X;} %type tablelist {tVariantList*} -tablelist(A) ::= ids(X) cpxName(Y). { toTSDBType(X.type); X.n += Y.n; A = tVariantListAppendToken(NULL, &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). { toTSDBType(X.type); X.n += Y.n; A = tVariantListAppendToken(NULL, &X, -1); A = tVariantListAppendToken(A, &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" %type tmvar {SSQLToken}