@@ -74,6 +74,12 @@ class HiveClientSuite(version: String)
7474 }
7575 }
7676
77+ private def analyzeIn (expr : Expression ): Expression = expr match {
78+ case In (CreateNamedStruct (children), list) => In (InValues (children), list)
79+ case In (v, list) => In (InValues (Seq (v)), list)
80+ case other => other
81+ }
82+
7783 override def beforeAll () {
7884 super .beforeAll()
7985 client = init(true )
@@ -156,23 +162,23 @@ class HiveClientSuite(version: String)
156162
157163 test(" getPartitionsByFilter: ds in (20170102, 20170103) (using IN expression)" ) {
158164 testMetastorePartitionFiltering(
159- attr(" ds" ).in(20170102 , 20170103 ),
165+ analyzeIn( attr(" ds" ).in(20170102 , 20170103 ) ),
160166 20170102 to 20170103 ,
161167 0 to 23 ,
162168 " aa" :: " ab" :: " ba" :: " bb" :: Nil )
163169 }
164170
165171 test(" getPartitionsByFilter: cast(ds as long) in (20170102L, 20170103L) (using IN expression)" ) {
166172 testMetastorePartitionFiltering(
167- attr(" ds" ).cast(LongType ).in(20170102L , 20170103L ),
173+ analyzeIn( attr(" ds" ).cast(LongType ).in(20170102L , 20170103L ) ),
168174 20170102 to 20170103 ,
169175 0 to 23 ,
170176 " aa" :: " ab" :: " ba" :: " bb" :: Nil )
171177 }
172178
173179 test(" getPartitionsByFilter: ds in (20170102, 20170103) (using INSET expression)" ) {
174180 testMetastorePartitionFiltering(
175- attr(" ds" ).in(20170102 , 20170103 ),
181+ analyzeIn( attr(" ds" ).in(20170102 , 20170103 ) ),
176182 20170102 to 20170103 ,
177183 0 to 23 ,
178184 " aa" :: " ab" :: " ba" :: " bb" :: Nil , {
@@ -184,7 +190,7 @@ class HiveClientSuite(version: String)
184190 test(" getPartitionsByFilter: cast(ds as long) in (20170102L, 20170103L) (using INSET expression)" )
185191 {
186192 testMetastorePartitionFiltering(
187- attr(" ds" ).cast(LongType ).in(20170102L , 20170103L ),
193+ analyzeIn( attr(" ds" ).cast(LongType ).in(20170102L , 20170103L ) ),
188194 20170102 to 20170103 ,
189195 0 to 23 ,
190196 " aa" :: " ab" :: " ba" :: " bb" :: Nil , {
@@ -195,15 +201,15 @@ class HiveClientSuite(version: String)
195201
196202 test(" getPartitionsByFilter: chunk in ('ab', 'ba') (using IN expression)" ) {
197203 testMetastorePartitionFiltering(
198- attr(" chunk" ).in(" ab" , " ba" ),
204+ analyzeIn( attr(" chunk" ).in(" ab" , " ba" ) ),
199205 20170101 to 20170103 ,
200206 0 to 23 ,
201207 " ab" :: " ba" :: Nil )
202208 }
203209
204210 test(" getPartitionsByFilter: chunk in ('ab', 'ba') (using INSET expression)" ) {
205211 testMetastorePartitionFiltering(
206- attr(" chunk" ).in(" ab" , " ba" ),
212+ analyzeIn( attr(" chunk" ).in(" ab" , " ba" ) ),
207213 20170101 to 20170103 ,
208214 0 to 23 ,
209215 " ab" :: " ba" :: Nil , {
@@ -231,7 +237,7 @@ class HiveClientSuite(version: String)
231237 " chunk in ('ab', 'ba') and ((ds=20170101 and h>=8) or (ds=20170102 and h<8))" ) {
232238 val day1 = (20170101 to 20170101 , 8 to 23 , Seq (" ab" , " ba" ))
233239 val day2 = (20170102 to 20170102 , 0 to 7 , Seq (" ab" , " ba" ))
234- testMetastorePartitionFiltering(attr(" chunk" ).in(" ab" , " ba" ) &&
240+ testMetastorePartitionFiltering(analyzeIn( attr(" chunk" ).in(" ab" , " ba" ) ) &&
235241 ((attr(" ds" ) === 20170101 && attr(" h" ) >= 8 ) || (attr(" ds" ) === 20170102 && attr(" h" ) < 8 )),
236242 day1 :: day2 :: Nil )
237243 }
0 commit comments