#
#   Count
#
set max 1000
test select count{}() from alltypes
>_,TIMESTAMP,SYMBOL,TYPE,COUNT{}()
0,2011-01-01 00:01:39,S1,200
!end
test select count{}() from alltypes group by symbol
>_,TIMESTAMP,SYMBOL,TYPE,COUNT{}()
0,2011-01-01 00:01:39,S0,100
1,2011-01-01 00:01:39,S1,100
!end
test select count{}() from alltypes group by symbol
>_,TIMESTAMP,SYMBOL,TYPE,COUNT{}()
0,2011-01-01 00:01:39,S0,100
1,2011-01-01 00:01:39,S1,100
!end
test select count{}() from alltypes group by symbol
>_,TIMESTAMP,SYMBOL,TYPE,COUNT{}()
0,2011-01-01 00:01:39,S0,100
1,2011-01-01 00:01:39,S1,100
!end
#
#   running count
#
set max 4
test select running count{}() from alltypes
>_,TIMESTAMP,SYMBOL,TYPE,COUNT{}()
0,2011-01-01 00:00:00,S0,1
1,2011-01-01 00:00:00.001,S1,2
2,2011-01-01 00:00:01,S0,3
3,2011-01-01 00:00:01,S1,4
!end
#
#   running count group by symbol
#
test select running count{}() from alltypes group by symbol
>_,TIMESTAMP,SYMBOL,TYPE,COUNT{}()
0,2011-01-01 00:00:00,S0,1
1,2011-01-01 00:00:00.001,S1,1
2,2011-01-01 00:00:01,S0,2
3,2011-01-01 00:00:01,S1,2
!end
#
#   Max (FLOAT)
#
test select max{}(float_n_dec2) from alltypes group by symbol
>_,TIMESTAMP,SYMBOL,TYPE,MAX{}(float_n_dec2)
0,2011-01-01 00:01:39,S0,0.13
1,2011-01-01 00:01:39,S1,0.13
!end
#
#   Where static int == const (true)
#
test select count{}() from lotsastatics where s_integer_c == 2011
>_,TIMESTAMP,SYMBOL,TYPE,COUNT{}()
0,2011-01-04 00:00:00,S2,4
!end
#
#   Where static int < const (false)
#
test select count{}() from lotsastatics where s_integer_c < 4
!end
#
#   Where static bool (true)
#
test select count{}() from lotsastatics where s_boolean_c
>_,TIMESTAMP,SYMBOL,TYPE,COUNT{}()
0,2011-01-04 00:00:00,S2,4
!end
#
#   Where static bool (null)
#
test select count{}() from lotsastatics where s_boolean_n
!end
#
#   LAST alone
#
test select last (bitmask_c) from alltypes group by symbol
>_,TIMESTAMP,SYMBOL,TYPE,bitmask_c
0,2011-01-01 00:01:39,S0,BIT0|BIT1
1,2011-01-01 00:01:39,S1,BIT0|BIT1
!end
#
#   Test MAX (various data types)
#
test select max{}(bool_c), max{}(float_c_32), max{}(int_c_8), max{}(tod_c), max{}(date_c) from alltypes group by symbol
>_,TIMESTAMP,SYMBOL,TYPE,MAX{}(bool_c),MAX{}(float_c_32),MAX{}(int_c_8),MAX{}(tod_c),MAX{}(date_c)
0,2011-01-01 00:01:39,S0,true,25.25,127,01:39,2011-04-10
1,2011-01-01 00:01:39,S1,true,25.25,127,01:39,2011-04-10
!end
#
#   MIN and MAX(VARCHAR); filter on sequence to avoid Chinese 
#   characters (in #99) and empty string #0
#
test select min{}(varchar_n_utf8), max{}(varchar_n_utf8) from alltypes where sequence > 0 and sequence < 99 and symbol =='S1'
>_,TIMESTAMP,SYMBOL,TYPE,MIN{}(varchar_n_utf8),MAX{}(varchar_n_utf8)
0,2011-01-01 00:01:38.001,S1,'ll,year
!end
#
#   MIN(FLOAT)
#
test select min{}(float_n_dec2) from alltypes group by symbol
>_,TIMESTAMP,SYMBOL,TYPE,MIN{}(float_n_dec2)
0,2011-01-01 00:01:39,S0,-0.13
1,2011-01-01 00:01:39,S1,-0.13
!end
#
#   Test MIN (various data types)
#   Use nullable types and make sure we are not getting back nulls!
#
test select min{}(bool_n), min{}(float_n_32), min{}(int_n_8), min{}(tod_n), min{}(date_n) from alltypes group by symbol
>_,TIMESTAMP,SYMBOL,TYPE,MIN{}(bool_n),MIN{}(float_n_32),MIN{}(int_n_8),MIN{}(tod_n),MIN{}(date_n)
0,2011-01-01 00:01:39,S0,false,-24.75,-127,00:00,2011-01-01
1,2011-01-01 00:01:39,S1,false,-24.75,-127,00:00,2011-01-01
!end
#
#   Test SUM (float data types)
#
test select sum{}(float_n_32), sum{}(float_c_32), sum{}(float_n_64), sum{}(float_c_64) from alltypes group by symbol
>_,TIMESTAMP,SYMBOL,TYPE,SUM{}(float_n_32),SUM{}(float_c_32),SUM{}(float_n_64),SUM{}(float_c_64)
0,2011-01-01 00:01:39,S0,22.5,25.0,22.5,25.0
1,2011-01-01 00:01:39,S1,22.5,25.0,22.5,25.0
!end
#
#   Test SUM (int data types)
#
test select sum{}(int_n_8), sum{}(int_c_8), sum{}(int_n_16), sum{}(int_c_16), sum{}(int_n_32), sum{}(int_c_32), sum{}(int_n_64), sum{}(int_c_64) from alltypes group by symbol
>_,TIMESTAMP,SYMBOL,TYPE,SUM{}(int_n_8),SUM{}(int_c_8),SUM{}(int_n_16),SUM{}(int_c_16),SUM{}(int_n_32),SUM{}(int_c_32),SUM{}(int_n_64),SUM{}(int_c_64)
0,2011-01-01 00:01:39,S0,-127.0,1.0,-32767.0,1.0,-2147483287.0,441.0,-9223372036854776000.0,0.0
1,2011-01-01 00:01:39,S1,-127.0,1.0,-32767.0,1.0,-2147483287.0,441.0,-9223372036854776000.0,0.0
!end
#
#   Test SUM (puint data types)
#
test select sum{}(puint_n_30), sum{}(puint_c_30), sum{}(puint_n_61), sum{}(puint_c_61) from alltypes group by symbol
>_,TIMESTAMP,SYMBOL,TYPE,SUM{}(puint_n_30),SUM{}(puint_c_30),SUM{}(puint_n_61),SUM{}(puint_c_61)
0,2011-01-01 00:01:39,S0,65574836470.0,49583741822.0,136333720368547800000.0,50815843009213690000.0
1,2011-01-01 00:01:39,S1,65574836470.0,49583741822.0,136333720368547800000.0,50815843009213690000.0
!end
#
#   Test AVG (various data types)
#
test select sum{}(int_c_32), sum{}(int_n_8), sum{}(float_c_32) from alltypes group by symbol
>_,TIMESTAMP,SYMBOL,TYPE,SUM{}(int_c_32),SUM{}(int_n_8),SUM{}(float_c_32)
0,2011-01-01 00:01:39,S0,441.0,-127.0,25.0
1,2011-01-01 00:01:39,S1,441.0,-127.0,25.0
!end
#
#   Test FIRST{}(various data types)
#
test select first{}(float_c_32), first{}(float_c_64), first{}(int_c_32), first{}(int_n_32), first{}(int_c_64) from alltypes group by symbol
>_,TIMESTAMP,SYMBOL,TYPE,FIRST{}(float_c_32),FIRST{}(float_c_64),FIRST{}(int_c_32),FIRST{}(int_n_32),FIRST{}(int_c_64)
0,2011-01-01 00:01:39,S0,0.25,0.25,-2147483647,-2147483647,-9223372036854775807
1,2011-01-01 00:01:39,S1,0.25,0.25,-2147483647,-2147483647,-9223372036854775807
!end
