@@ -558,62 +558,67 @@ class HiveQuerySuite extends HiveComparisonTest {
558
558
val testKey = " spark.sql.key.usedfortestonly"
559
559
val testVal = " test.val.0"
560
560
val nonexistentKey = " nonexistent"
561
-
561
+ val KV = " ([^=]+)=([^=]*)" .r
562
+ def collectResults (rdd : SchemaRDD ): Set [(String , String )] =
563
+ rdd.collect().map {
564
+ case Row (key : String , value : String ) => key -> value
565
+ case Row (KV (key, value)) => key -> value
566
+ }.toSet
562
567
clear()
563
568
564
569
// "set" itself returns all config variables currently specified in SQLConf.
565
570
// TODO: Should we be listing the default here always? probably...
566
571
assert(sql(" SET" ).collect().size == 0 )
567
572
568
- assertResult(Array ( s " $ testKey= $ testVal" )) {
569
- sql( s " SET $testKey= $testVal" ).collect().map(_.getString( 0 ))
573
+ assertResult(Set ( testKey -> testVal)) {
574
+ collectResults(hql( s " SET $testKey= $testVal" ))
570
575
}
571
576
572
577
assert(hiveconf.get(testKey, " " ) == testVal)
573
- assertResult(Array ( s " $ testKey= $ testVal" )) {
574
- sql( s " SET $testKey = $testVal " ).collect().map(_.getString( 0 ))
578
+ assertResult(Set ( testKey -> testVal)) {
579
+ collectResults(hql( " SET" ))
575
580
}
576
581
577
582
sql(s " SET ${testKey + testKey}= ${testVal + testVal}" )
578
583
assert(hiveconf.get(testKey + testKey, " " ) == testVal + testVal)
579
- assertResult(Array ( s " $ testKey= $ testVal" , s " ${ testKey + testKey} = ${ testVal + testVal} " )) {
580
- sql( s " SET " ).collect().map(_.getString( 0 ))
584
+ assertResult(Set ( testKey -> testVal, ( testKey + testKey) -> ( testVal + testVal) )) {
585
+ collectResults(hql( " SET" ))
581
586
}
582
587
583
588
// "set key"
584
- assertResult(Array ( s " $ testKey= $ testVal" )) {
585
- sql( s " SET $testKey" ).collect().map(_.getString( 0 ))
589
+ assertResult(Set ( testKey -> testVal)) {
590
+ collectResults(hql( s " SET $testKey" ))
586
591
}
587
592
588
- assertResult(Array ( s " $ nonexistentKey= <undefined>" )) {
589
- sql( s " SET $nonexistentKey" ).collect().map(_.getString( 0 ))
593
+ assertResult(Set ( nonexistentKey -> " <undefined>" )) {
594
+ collectResults(hql( s " SET $nonexistentKey" ))
590
595
}
591
596
592
597
// Assert that sql() should have the same effects as sql() by repeating the above using sql().
593
598
clear()
594
599
assert(sql(" SET" ).collect().size == 0 )
595
600
596
- assertResult(Array ( s " $ testKey= $ testVal" )) {
597
- sql(s " SET $testKey= $testVal" ).collect().map(_.getString( 0 ))
601
+ assertResult(Set ( testKey -> testVal)) {
602
+ collectResults( sql(s " SET $testKey= $testVal" ))
598
603
}
599
604
600
605
assert(hiveconf.get(testKey, " " ) == testVal)
601
- assertResult(Array ( s " $ testKey= $ testVal" )) {
602
- sql(" SET" ).collect().map(_.getString( 0 ))
606
+ assertResult(Set ( testKey -> testVal)) {
607
+ collectResults( sql(" SET" ))
603
608
}
604
609
605
610
sql(s " SET ${testKey + testKey}= ${testVal + testVal}" )
606
611
assert(hiveconf.get(testKey + testKey, " " ) == testVal + testVal)
607
- assertResult(Array ( s " $ testKey= $ testVal" , s " ${ testKey + testKey} = ${ testVal + testVal} " )) {
608
- sql(" SET" ).collect().map(_.getString( 0 ))
612
+ assertResult(Set ( testKey -> testVal, ( testKey + testKey) -> ( testVal + testVal) )) {
613
+ collectResults( sql(" SET" ))
609
614
}
610
615
611
- assertResult(Array ( s " $ testKey= $ testVal" )) {
612
- sql(s " SET $testKey" ).collect().map(_.getString( 0 ))
616
+ assertResult(Set ( testKey -> testVal)) {
617
+ collectResults( sql(s " SET $testKey" ))
613
618
}
614
619
615
- assertResult(Array ( s " $ nonexistentKey= <undefined>" )) {
616
- sql(s " SET $nonexistentKey" ).collect().map(_.getString( 0 ))
620
+ assertResult(Set ( nonexistentKey -> " <undefined>" )) {
621
+ collectResults( sql(s " SET $nonexistentKey" ))
617
622
}
618
623
619
624
clear()
0 commit comments