-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-30412][SQL][TESTS] Eliminate warnings in Java tests regarding to deprecated Spark SQL API #27081
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-30412][SQL][TESTS] Eliminate warnings in Java tests regarding to deprecated Spark SQL API #27081
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,43 +25,50 @@ | |
|
|
||
| import org.apache.spark.sql.Dataset; | ||
| import org.apache.spark.sql.KeyValueGroupedDataset; | ||
| import org.apache.spark.sql.expressions.javalang.typed; | ||
|
|
||
| /** | ||
| * Suite that replicates tests in JavaDatasetAggregatorSuite using lambda syntax. | ||
| */ | ||
| public class Java8DatasetAggregatorSuite extends JavaDatasetAggregatorSuiteBase { | ||
| @SuppressWarnings("deprecation") | ||
| @Test | ||
| public void testTypedAggregationAverage() { | ||
| KeyValueGroupedDataset<String, Tuple2<String, Integer>> grouped = generateGroupedDataset(); | ||
| Dataset<Tuple2<String, Double>> agged = grouped.agg(typed.avg(v -> (double)(v._2() * 2))); | ||
| Dataset<Tuple2<String, Double>> agged = grouped.agg( | ||
| org.apache.spark.sql.expressions.javalang.typed.avg(v -> (double)(v._2() * 2))); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't think it's a good idea to use full class name. you may use rename a class on import
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The purpose of using full path to deprecated methods is to put any references to deprecated class under the annotation |
||
| Assert.assertEquals( | ||
| Arrays.asList(new Tuple2<>("a", 3.0), new Tuple2<>("b", 6.0)), | ||
| agged.collectAsList()); | ||
| } | ||
|
|
||
| @SuppressWarnings("deprecation") | ||
| @Test | ||
| public void testTypedAggregationCount() { | ||
| KeyValueGroupedDataset<String, Tuple2<String, Integer>> grouped = generateGroupedDataset(); | ||
| Dataset<Tuple2<String, Long>> agged = grouped.agg(typed.count(v -> v)); | ||
| Dataset<Tuple2<String, Long>> agged = grouped.agg( | ||
| org.apache.spark.sql.expressions.javalang.typed.count(v -> v)); | ||
| Assert.assertEquals( | ||
| Arrays.asList(new Tuple2<>("a", 2L), new Tuple2<>("b", 1L)), | ||
| agged.collectAsList()); | ||
| } | ||
|
|
||
| @SuppressWarnings("deprecation") | ||
| @Test | ||
| public void testTypedAggregationSumDouble() { | ||
| KeyValueGroupedDataset<String, Tuple2<String, Integer>> grouped = generateGroupedDataset(); | ||
| Dataset<Tuple2<String, Double>> agged = grouped.agg(typed.sum(v -> (double)v._2())); | ||
| Dataset<Tuple2<String, Double>> agged = grouped.agg( | ||
| org.apache.spark.sql.expressions.javalang.typed.sum(v -> (double)v._2())); | ||
| Assert.assertEquals( | ||
| Arrays.asList(new Tuple2<>("a", 3.0), new Tuple2<>("b", 3.0)), | ||
| agged.collectAsList()); | ||
| } | ||
|
|
||
| @SuppressWarnings("deprecation") | ||
| @Test | ||
| public void testTypedAggregationSumLong() { | ||
| KeyValueGroupedDataset<String, Tuple2<String, Integer>> grouped = generateGroupedDataset(); | ||
| Dataset<Tuple2<String, Long>> agged = grouped.agg(typed.sumLong(v -> (long)v._2())); | ||
| Dataset<Tuple2<String, Long>> agged = grouped.agg( | ||
| org.apache.spark.sql.expressions.javalang.typed.sumLong(v -> (long)v._2())); | ||
| Assert.assertEquals( | ||
| Arrays.asList(new Tuple2<>("a", 3L), new Tuple2<>("b", 3L)), | ||
| agged.collectAsList()); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggest to use rename a class on import, e.g. import org.apache.spark.sql.expressions.javalang.{typed => javaTyped}
instead of use full class name in rest of code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is Java not Scala. What do you propose doesn't work here.