Skip to content

Commit

Permalink
[Examples] sort the results
Browse files Browse the repository at this point in the history
  • Loading branch information
weiqingy committed May 26, 2017
1 parent 6c76f57 commit 24df2ed
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,12 @@ object JoinTablesFrom2Clusters {
val df2 = withCatalog(cat2, conf2)
val s1 = df1.filter($"col0" <= "row120" && $"col0" > "row090").select("col0", "col2")
val s2 = df2.filter($"col0" <= "row150" && $"col0" > "row100").select("col0", "col5")
val result = s1.join(s2, Seq("col0")).cache
val result = s1.join(s2, Seq("col0"))

result.show() // should be row101 to row120, as following:
result.sort($"col0".asc, $"col2", $"col5").show() // should be row101 to row120, as following:
/*+------+-----+----+
| col0| col2|col5|
+------+-----+----+
|row120|120.0| 120|
|row101|101.0| 101|
|row102|102.0| 102|
|row103|103.0| 103|
Expand All @@ -157,10 +156,9 @@ object JoinTablesFrom2Clusters {
|row117|117.0| 117|
|row118|118.0| 118|
|row119|119.0| 119|
|row120|120.0| 120|
+------+-----+----+ */

println(result.count()) // should be 20

sc.stop()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,10 @@ object LRJobAccessing2Clusters {
val s2 = df2.filter($"col0" <= "row150" && $"col0" > "row100").select("col0", "col5")
val result = s1.join(s2, Seq("col0"))

result.show() // should be row101 to row120, as following:
result.sort($"col0".asc, $"col2", $"col5").show() // should be row101 to row120, as following:
/*+------+-----+----+
| col0| col2|col5|
+------+-----+----+
|row120|120.0| 120|
|row101|101.0| 101|
|row102|102.0| 102|
|row103|103.0| 103|
Expand All @@ -161,10 +160,9 @@ object LRJobAccessing2Clusters {
|row117|117.0| 117|
|row118|118.0| 118|
|row119|119.0| 119|
|row120|120.0| 120|
+------+-----+----+ */

println(result.count()) // should be 20

Thread.sleep(sleepTime)
}
sc.stop()
Expand Down

0 comments on commit 24df2ed

Please sign in to comment.