forked from apache/spark
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SPARK-5904][SQL] DataFrame Java API test suites.
Added a new test suite to make sure Java DF programs can use varargs properly. Also moved all suites into test.org.apache.spark package to make sure the suites also test for method visibility. Author: Reynold Xin <[email protected]> Closes apache#4751 from rxin/df-tests and squashes the following commits: 1e8b8e4 [Reynold Xin] Fixed imports and renamed JavaAPISuite. a6ca53b [Reynold Xin] [SPARK-5904][SQL] DataFrame Java API test suites.
- Loading branch information
Showing
7 changed files
with
108 additions
and
143 deletions.
There are no files selected for viewing
120 changes: 0 additions & 120 deletions
120
sql/core/src/test/java/org/apache/spark/sql/api/java/JavaDsl.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
sql/core/src/test/java/test/org/apache/spark/sql/JavaDataFrameSuite.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package test.org.apache.spark.sql; | ||
|
||
import org.junit.After; | ||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import org.apache.spark.sql.*; | ||
import org.apache.spark.sql.test.TestSQLContext$; | ||
import static org.apache.spark.sql.functions.*; | ||
|
||
|
||
public class JavaDataFrameSuite { | ||
private transient SQLContext context; | ||
|
||
@Before | ||
public void setUp() { | ||
// Trigger static initializer of TestData | ||
TestData$.MODULE$.testData(); | ||
context = TestSQLContext$.MODULE$; | ||
} | ||
|
||
@After | ||
public void tearDown() { | ||
context = null; | ||
} | ||
|
||
@Test | ||
public void testExecution() { | ||
DataFrame df = context.table("testData").filter("key = 1"); | ||
Assert.assertEquals(df.select("key").collect()[0].get(0), 1); | ||
} | ||
|
||
/** | ||
* See SPARK-5904. Abstract vararg methods defined in Scala do not work in Java. | ||
*/ | ||
@Test | ||
public void testVarargMethods() { | ||
DataFrame df = context.table("testData"); | ||
|
||
df.toDF("key1", "value1"); | ||
|
||
df.select("key", "value"); | ||
df.select(col("key"), col("value")); | ||
df.selectExpr("key", "value + 1"); | ||
|
||
df.sort("key", "value"); | ||
df.sort(col("key"), col("value")); | ||
df.orderBy("key", "value"); | ||
df.orderBy(col("key"), col("value")); | ||
|
||
df.groupBy("key", "value").agg(col("key"), col("value"), sum("value")); | ||
df.groupBy(col("key"), col("value")).agg(col("key"), col("value"), sum("value")); | ||
df.agg(first("key"), sum("value")); | ||
|
||
df.groupBy().avg("key"); | ||
df.groupBy().mean("key"); | ||
df.groupBy().max("key"); | ||
df.groupBy().min("key"); | ||
df.groupBy().sum("key"); | ||
|
||
// Varargs in column expressions | ||
df.groupBy().agg(countDistinct("key", "value")); | ||
df.groupBy().agg(countDistinct(col("key"), col("value"))); | ||
df.select(coalesce(col("key"))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters