Merge pull request #29914 from taosdata/feat/TS-5613-3.0
feat:[TS-5613]support bool in cast
This commit is contained in:
commit
7494432770
|
@ -1523,29 +1523,29 @@ TEST(clientCase, timezone_Test) {
|
|||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||
ASSERT_NE(pConn, nullptr);
|
||||
|
||||
TAOS_RES* pRes = taos_query(pConn, "drop database if exists db1");
|
||||
TAOS_RES* pRes = taos_query(pConn, "drop database if exists db_timezone");
|
||||
ASSERT_EQ(taos_errno(pRes), TSDB_CODE_SUCCESS);
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "create database db1");
|
||||
pRes = taos_query(pConn, "create database db_timezone");
|
||||
ASSERT_EQ(taos_errno(pRes), TSDB_CODE_SUCCESS);
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "create table db1.t1 (ts timestamp, v int)");
|
||||
pRes = taos_query(pConn, "create table db_timezone.t1 (ts timestamp, v int)");
|
||||
while (taos_errno(pRes) == TSDB_CODE_MND_DB_IN_CREATING || taos_errno(pRes) == TSDB_CODE_MND_DB_IN_DROPPING) {
|
||||
taosMsleep(2000);
|
||||
pRes = taos_query(pConn, "create table db1.t1 (ts timestamp, v int)");
|
||||
pRes = taos_query(pConn, "create table db_timezone.t1 (ts timestamp, v int)");
|
||||
}
|
||||
ASSERT_EQ(taos_errno(pRes), TSDB_CODE_SUCCESS);
|
||||
taos_free_result(pRes);
|
||||
|
||||
char sql[256] = {0};
|
||||
(void)sprintf(sql, "insert into db1.t1 values('2023-09-16 17:00:00', 1)");
|
||||
(void)sprintf(sql, "insert into db_timezone.t1 values('2023-09-16 17:00:00', 1)");
|
||||
pRes = taos_query(pConn, sql);
|
||||
ASSERT_EQ(taos_errno(pRes), TSDB_CODE_SUCCESS);
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "select * from db1.t1 where ts == '2023-09-16 17:00:00'");
|
||||
pRes = taos_query(pConn, "select * from db_timezone.t1 where ts == '2023-09-16 17:00:00'");
|
||||
ASSERT_EQ(taos_errno(pRes), TSDB_CODE_SUCCESS);
|
||||
|
||||
TAOS_ROW pRow = NULL;
|
||||
|
@ -1571,7 +1571,7 @@ TEST(clientCase, timezone_Test) {
|
|||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||
ASSERT_NE(pConn, nullptr);
|
||||
|
||||
TAOS_RES* pRes = taos_query(pConn, "select * from db1.t1 where ts == '2023-09-16 01:00:00'");
|
||||
TAOS_RES* pRes = taos_query(pConn, "select * from db_timezone.t1 where ts == '2023-09-16 01:00:00'");
|
||||
ASSERT_EQ(taos_errno(pRes), TSDB_CODE_SUCCESS);
|
||||
|
||||
TAOS_ROW pRow = NULL;
|
||||
|
@ -1588,7 +1588,7 @@ TEST(clientCase, timezone_Test) {
|
|||
taos_free_result(pRes);
|
||||
|
||||
char sql[256] = {0};
|
||||
(void)sprintf(sql, "insert into db1.t1 values('2023-09-16 17:00:01', 1)");
|
||||
(void)sprintf(sql, "insert into db_timezone.t1 values('2023-09-16 17:00:01', 1)");
|
||||
pRes = taos_query(pConn, sql);
|
||||
ASSERT_EQ(taos_errno(pRes), TSDB_CODE_SUCCESS);
|
||||
|
||||
|
@ -1604,7 +1604,7 @@ TEST(clientCase, timezone_Test) {
|
|||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||
ASSERT_NE(pConn, nullptr);
|
||||
|
||||
TAOS_RES* pRes = taos_query(pConn, "select * from db1.t1 where ts == '2023-09-16 09:00:00'");
|
||||
TAOS_RES* pRes = taos_query(pConn, "select * from db_timezone.t1 where ts == '2023-09-16 09:00:00'");
|
||||
ASSERT_EQ(taos_errno(pRes), TSDB_CODE_SUCCESS);
|
||||
|
||||
TAOS_ROW pRow = NULL;
|
||||
|
@ -1620,7 +1620,7 @@ TEST(clientCase, timezone_Test) {
|
|||
taos_free_result(pRes);
|
||||
|
||||
{
|
||||
TAOS_RES* pRes = taos_query(pConn, "select * from db1.t1 where ts == '2023-09-17 01:00:01'");
|
||||
TAOS_RES* pRes = taos_query(pConn, "select * from db_timezone.t1 where ts == '2023-09-17 01:00:01'");
|
||||
ASSERT_EQ(taos_errno(pRes), TSDB_CODE_SUCCESS);
|
||||
|
||||
TAOS_ROW pRow = NULL;
|
||||
|
|
|
@ -50,10 +50,14 @@
|
|||
%left AND.
|
||||
%left UNION ALL MINUS EXCEPT INTERSECT.
|
||||
%left NK_BITAND NK_BITOR NK_LSHIFT NK_RSHIFT.
|
||||
%left NK_LT NK_GT NK_LE NK_GE NK_EQ NK_NE LIKE MATCH NMATCH REGEXP CONTAINS BETWEEN IS IN.
|
||||
%left NK_PLUS NK_MINUS.
|
||||
%left NK_STAR NK_SLASH NK_REM.
|
||||
%left NK_CONCAT.
|
||||
|
||||
%right NOT.
|
||||
%left NK_ARROW.
|
||||
|
||||
%right INNER LEFT RIGHT FULL OUTER SEMI ANTI ASOF WINDOW JOIN ON WINDOW_OFFSET JLIMIT.
|
||||
|
||||
/************************************************ create/alter account *****************************************/
|
||||
|
@ -1285,9 +1289,9 @@ function_expression(A) ::= function_name(B) NK_LP expression_list(C) NK_RP(D).
|
|||
function_expression(A) ::= star_func(B) NK_LP star_func_para_list(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, C)); }
|
||||
function_expression(A) ::= cols_func(B) NK_LP cols_func_para_list(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, C)); }
|
||||
function_expression(A) ::=
|
||||
CAST(B) NK_LP expr_or_subquery(C) AS type_name(D) NK_RP(E). { A = createRawExprNodeExt(pCxt, &B, &E, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, C), D)); }
|
||||
CAST(B) NK_LP common_expression(C) AS type_name(D) NK_RP(E). { A = createRawExprNodeExt(pCxt, &B, &E, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, C), D)); }
|
||||
function_expression(A) ::=
|
||||
CAST(B) NK_LP expr_or_subquery(C) AS type_name_default_len(D) NK_RP(E). { A = createRawExprNodeExt(pCxt, &B, &E, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, C), D)); }
|
||||
CAST(B) NK_LP common_expression(C) AS type_name_default_len(D) NK_RP(E). { A = createRawExprNodeExt(pCxt, &B, &E, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, C), D)); }
|
||||
function_expression(A) ::=
|
||||
POSITION(B) NK_LP expr_or_subquery(C) IN expr_or_subquery(D) NK_RP(E). { A = createRawExprNodeExt(pCxt, &B, &E, createPositionFunctionNode(pCxt, releaseRawExprNode(pCxt, C), releaseRawExprNode(pCxt, D))); }
|
||||
function_expression(A) ::=
|
||||
|
|
|
@ -55,6 +55,19 @@ class TDTestCase:
|
|||
tdLog.debug("res2: %s" % str(res2))
|
||||
assert(len(res1) == len(res2) and res1[0][0] == res2[4][0])
|
||||
|
||||
# test ts-5613
|
||||
sql = "select cast(2<>3 as int) from t"
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,1)
|
||||
|
||||
sql = "select cast(2 not in(3) as int) from t"
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,1)
|
||||
|
||||
sql = "select cast(2 is NULL as int) from t"
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,0)
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
|
|
Loading…
Reference in New Issue