
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect


$dbPrefix = ta_bib_db
$tbPrefix = ta_bib_tb
$mtPrefix = ta_bib_mt
$tbNum = 10
$rowNum = 20
$totalNum = 200

print =============== step1
$i = 0
$db = $dbPrefix . $i
$mt = $mtPrefix . $i

sql drop database if exists $db 

sql create database $db vgroups 1
sql use $db

print ======== test bigint
sql create table if not exists st( ts timestamp, order_id bigint) tags (account_id bigint)

sql create table t1 using st tags(111)
sql create table t2 using st tags(222)

sql insert into t1(ts, order_id) values(1648791213001, 1)
sql insert into t2(ts, order_id) values(1648791213002, 2)
sql select  account_id,count(*) from st where account_id = 111  group by account_id

sql drop table t1

sql create table t1 using st tags(111)

sql insert into t1(ts, order_id) values(1648791213001, 1)
sql insert into t2(ts, order_id) values(1648791213002, 2)

sql select account_id,count(*) from st where account_id = 111  group by account_id

if $rows != 1 then 
  return -1
endi

print ======== test varchar  

sql drop stable st

sql create table if not exists st( ts timestamp, order_id bigint) tags (account_id binary(16))

sql create table t1 using st tags("aac")
sql create table t2 using st tags("abc")

sql insert into t1(ts, order_id) values(1648791213001, 1)
sql insert into t2(ts, order_id) values(1648791213002, 2)
sql select  account_id,count(*) from st where account_id = "aac"  group by account_id

sql drop table t1

sql create table t1 using st tags("aac")

sql insert into t1(ts, order_id) values(1648791213001, 1)
sql insert into t2(ts, order_id) values(1648791213002, 2)

sql select account_id,count(*) from st where account_id = "aac"  group by account_id

if $rows != 1 then
  return -1
endi

print ====== test empty table
sql drop table t1

sql select account_id,count(*) from st where account_id = "aac"  group by account_id
if $rows != 0 then
  return -1
endi

 
sql drop database $db

