This is a way to do it in Scala:
val df = sc.parallelize(Seq(("a","b","c",1),("a","b","c",2),("x","xb","xc",3),("y","yb","yc",4),("x","xb","xc",5))).toDF("email","first_name","last_name","order_id")
df.registerTempTable("df")
sqlContext.sql("select * from (select email, count(*) as order_count from df group by email ) d1 join df d2 on d1.email = d2.email")
In Java, considering that you already have your DataFrame created, it's actually the same code :
DataFrame results = sqlContext.sql("select * from (select email, count(*) as order_count from df group by email ) d1 join df d2 on d1.email = d2.email");
Nevertheless, and even thought this is straight-forward solution but I consider it as a bad practice because your code will be hard to maintain and evolve. A cleaner solution would be :
DataFrame email_count = df.groupBy("email").count();
DataFrame results2 = email_count.join(df, email_count.col("email").equalTo(df.col("email"))).drop(df.col("email"));