@@ -34,20 +34,25 @@ mod tests {
3434 // write some data to get a set of rows destined for the WAL, and an updated catalog:
3535 let rows = writer
3636 . write_lp_to_rows (
37- "\
38- cpu,region=us-east,host=a usage=100\n \
39- cpu,region=us-east,host=b usage=100\n \
40- cpu,region=us-west,host=c usage=100\n \
41- cpu,region=us-west,host=d usage=100\n \
42- cpu,region=ca-east,host=e usage=100\n \
43- cpu,region=ca-east,host=f usage=100\n \
44- cpu,region=ca-cent,host=g usage=100\n \
45- cpu,region=ca-cent,host=h usage=100\n \
46- cpu,region=eu-east,host=i usage=100\n \
47- cpu,region=eu-east,host=j usage=100\n \
48- cpu,region=eu-cent,host=k usage=100\n \
49- cpu,region=eu-cent,host=l usage=100\n \
50- ",
37+ r#"\
38+ cpu,region=us-east,host=a usage=100
39+ cpu,region=us-east,host=b usage=100
40+ cpu,region=us-west,host=c usage=100
41+ cpu,region=us-west,host=d usage=100
42+ cpu,region=ca-east,host=e usage=100
43+ cpu,region=ca-east,host=f usage=100
44+ cpu,region=ca-cent,host=g usage=100
45+ cpu,region=ca-cent,host=h usage=100
46+ cpu,region=eu-east,host=i usage=100
47+ cpu,region=eu-east,host=j usage=100
48+ cpu,region=eu-cent,host=k usage=100
49+ cpu,region=eu-cent,host=l usage=100
50+ cpu,region=us-east usage=200
51+ cpu,region=us-west usage=200
52+ cpu,region=ca-cent usage=200
53+ cpu,host=m usage=300
54+ cpu,host=n usage=300
55+ "# ,
5156 0 ,
5257 )
5358 . await ;
@@ -97,6 +102,9 @@ mod tests {
97102 "+---------+------+" ,
98103 "| region | host |" ,
99104 "+---------+------+" ,
105+ "| | m |" ,
106+ "| | n |" ,
107+ "| ca-cent | |" ,
100108 "| ca-cent | g |" ,
101109 "| ca-cent | h |" ,
102110 "| ca-east | e |" ,
@@ -105,8 +113,10 @@ mod tests {
105113 "| eu-cent | l |" ,
106114 "| eu-east | i |" ,
107115 "| eu-east | j |" ,
116+ "| us-east | |" ,
108117 "| us-east | a |" ,
109118 "| us-east | b |" ,
119+ "| us-west | |" ,
110120 "| us-west | c |" ,
111121 "| us-west | d |" ,
112122 "+---------+------+" ,
@@ -122,6 +132,7 @@ mod tests {
122132 "+---------+------+" ,
123133 "| region | host |" ,
124134 "+---------+------+" ,
135+ "| ca-cent | |" ,
125136 "| ca-cent | g |" ,
126137 "| ca-cent | h |" ,
127138 "| ca-east | e |" ,
@@ -144,6 +155,21 @@ mod tests {
144155 "+---------+------+" ,
145156 ] ,
146157 } ,
158+ TestCase {
159+ desc : "in predicate on region and not in host" ,
160+ predicates : create_predicate_map ( & [
161+ ( region_col_id, Predicate :: new_in ( [ "ca-cent" , "ca-east" ] ) ) ,
162+ ( host_col_id, Predicate :: new_not_in ( [ "g" , "e" , "h" ] ) ) ,
163+ ] ) ,
164+ expected : & [
165+ "+---------+------+" ,
166+ "| region | host |" ,
167+ "+---------+------+" ,
168+ "| ca-cent | |" ,
169+ "| ca-east | f |" ,
170+ "+---------+------+" ,
171+ ] ,
172+ } ,
147173 TestCase {
148174 desc : "not in predicate on region" ,
149175 predicates : create_predicate_map ( & [ (
@@ -154,12 +180,16 @@ mod tests {
154180 "+---------+------+" ,
155181 "| region | host |" ,
156182 "+---------+------+" ,
183+ "| | m |" ,
184+ "| | n |" ,
157185 "| eu-cent | k |" ,
158186 "| eu-cent | l |" ,
159187 "| eu-east | i |" ,
160188 "| eu-east | j |" ,
189+ "| us-east | |" ,
161190 "| us-east | a |" ,
162191 "| us-east | b |" ,
192+ "| us-west | |" ,
163193 "| us-west | c |" ,
164194 "| us-west | d |" ,
165195 "+---------+------+" ,
@@ -169,16 +199,19 @@ mod tests {
169199 desc : "not in predicate on region and host" ,
170200 predicates : create_predicate_map ( & [
171201 ( region_col_id, Predicate :: new_not_in ( [ "ca-cent" , "ca-east" ] ) ) ,
172- ( host_col_id, Predicate :: new_not_in ( [ "j" , "k" ] ) ) ,
202+ ( host_col_id, Predicate :: new_not_in ( [ "j" , "k" , "m" ] ) ) ,
173203 ] ) ,
174204 expected : & [
175205 "+---------+------+" ,
176206 "| region | host |" ,
177207 "+---------+------+" ,
208+ "| | n |" ,
178209 "| eu-cent | l |" ,
179210 "| eu-east | i |" ,
211+ "| us-east | |" ,
180212 "| us-east | a |" ,
181213 "| us-east | b |" ,
214+ "| us-west | |" ,
182215 "| us-west | c |" ,
183216 "| us-west | d |" ,
184217 "+---------+------+" ,
@@ -936,10 +969,8 @@ mod tests {
936969 ) ;
937970 }
938971
939- // NB: This test was added as part of https://github.com/influxdata/influxdb/issues/25564
940- // If we choose to support nulls in the distinct cache then this test will fail
941972 #[ test_log:: test( tokio:: test) ]
942- async fn test_row_with_nulls_ignored ( ) {
973+ async fn test_row_with_nulls_not_ignored ( ) {
943974 let writer = TestWriter :: new ( ) . await ;
944975 let time_provider = Arc :: new ( MockProvider :: new ( Time :: from_timestamp_nanos ( 0 ) ) ) ;
945976 let cat = writer. catalog ( ) ;
@@ -994,26 +1025,32 @@ mod tests {
9941025 DistinctCacheFunction :: new ( writer. db_schema ( ) . id , Arc :: clone ( & distinct_cache_provider) ) ;
9951026 ctx. register_udtf ( DISTINCT_CACHE_UDTF_NAME , Arc :: new ( distinct_func) ) ;
9961027
997- let results = ctx
998- . sql ( "select * from distinct_cache('bar')" )
999- . await
1000- . unwrap ( )
1001- . collect ( )
1002- . await
1003- . unwrap ( ) ;
1028+ // Verify all values are returned with no predicate
1029+ {
1030+ let results = ctx
1031+ . sql ( "select * from distinct_cache('bar')" )
1032+ . await
1033+ . unwrap ( )
1034+ . collect ( )
1035+ . await
1036+ . unwrap ( ) ;
10041037
1005- assert_batches_eq ! (
1006- [
1007- "+----+----+----+" ,
1008- "| t1 | t2 | t3 |" ,
1009- "+----+----+----+" ,
1010- "| A | A | A |" ,
1011- "| A | A | B |" ,
1012- "| A | B | B |" ,
1013- "+----+----+----+" ,
1014- ] ,
1015- & results
1016- ) ;
1038+ assert_batches_eq ! (
1039+ [
1040+ "+----+----+----+" ,
1041+ "| t1 | t2 | t3 |" ,
1042+ "+----+----+----+" ,
1043+ "| | B | B |" ,
1044+ "| A | A | A |" ,
1045+ "| A | A | B |" ,
1046+ "| A | B | B |" ,
1047+ "| B | | B |" ,
1048+ "| B | A | |" ,
1049+ "+----+----+----+" ,
1050+ ] ,
1051+ & results
1052+ ) ;
1053+ }
10171054 }
10181055
10191056 #[ test_log:: test( tokio:: test) ]
0 commit comments