-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-38351][TESTS] Don't use deprecate symbol API in test classes #35560
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
Conversation
srowen
left a comment
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.
Yeah I think we did this for non-test code earlier. It should be OK as it is functionally identical and avoids a 2.13 deprecation warning.
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.
Was this an intended change?
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.
This is because I've created the branch for this PR from the branch of #35556. I will remove this commit from here.
|
@dongjoon-hyun @HyukjinKwon What is your opinion ? Would you merge such PR ? How big should the PR be ? Fix all issues of this type in the whole or module by module ? |
|
Heh, no right answer, but I'd say fix < 200 files at a time? maybe that gets to all test code? that would be a fine scope |
|
Can one of the admins verify this patch? |
|
Is this all the occurences in test? this could be an OK unit to merge |
|
For making it easy to upgrade to Scala 3, another option would be to import |
|
Does that just suppress the warning? I think just consistently using Symbol() is easier IMHO; there may not be that much left to change. |
|
Yeah, I thought it's better to replace them but there were some objections to do it in the previous PR. So, I just suggest another possible solution. |
|
I wasn't aware of #31569. There some people said that it might be better to migrate to
|
|
Does |
|
Sorry! Muscle memory ... I meant |
|
If you want to rebase this and mark it ready for review, I think it could be OK. A good scope might be all occurrences in tests? |
|
I will create a JIRA ticket and update the PR soon! |
Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
The recommended way is to use Symbol("name").
Fix deprecation warnings only in the test suites
Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
|
The build fails due to : But executing import org.apache.spark.sql.catalyst.expressions.{InSet, Literal, NamedExpression}
-import org.apache.spark.sql.catalyst.util.DateTimeTestUtils.{outstandingTimezonesIds, outstandingZoneIds}
+import org.apache.spark.sql.catalyst.util.DateTimeTestUtils.{
+ outstandingTimezonesIds,
+ outstandingZoneIds
+}
import org.apache.spark.sql.catalyst.util.DateTimeUtils
import org.apache.spark.sql.execution.ProjectExec
import org.apache.spark.sql.functions._
@@ -43,83 +46,54 @@ class ColumnExpressionSuite extends QueryTest with SharedSparkSession {
import testImplicits._
private lazy val booleanData = {
- spark.createDataFrame(sparkContext.parallelize(
- Row(false, false) ::
- Row(false, true) ::
- Row(true, false) ::
- Row(true, true) :: Nil),
+ spark.createDataFrame(
+ sparkContext.parallelize(
+ Row(false, false) ::
+ Row(false, true) ::
+ Row(true, false) ::
+ Row(true, true) :: Nil),It might take me a while to format manually just the related code. |
Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
|
Yeah don't bother with scalafmt here, just fix the long lines if there are only a few instances |
E.g.: [error] /__w/spark/spark/sql/core/src/test/scala/org/apache/spark/sql/streaming/StreamingJoinSuite.scala:927: File line length exceeds 100 characters [error] /__w/spark/spark/sql/core/src/test/scala/org/apache/spark/sql/streaming/StreamingJoinSuite.scala:928: File line length exceeds 100 characters ./dev/scalafmt formats other unrelated lines too, so it is not really usable Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
|
@srowen The PR is ready for review! |
|
Merged to master |
|
Just to see our preference, given |
|
Is that the same thing? $".." is shorthand for a Column, not Scala Symbol |
|
Right, but what else we use Symbol except representing Column? I might be missing something, but from what I've seen from test codes, majority of usage has been the same for $"...". |
|
Hm, I think you have a point. We definitely need Symbol in some parts of the Scala code, but I think they're rare and limited to parts that reason about closures, etc. For columns, yeah, in hindsight I agree. Eh, hm, martin this might be my fault here. It may be smarter to turn all of those changes into $"..." after all if they're all really column refs. I totally missed that. We could do it in a follow up or revert this or whatever's easy, if you're willing. |
|
Follow-up fix sounds good to me. Easier to work based on this since we now just need to try finding |
|
Agreed! I will work on this soon! |
|
Do we still have any tests for |
|
@jiangxb1987 Yes, there are still usages of |
|
@martin-g any chance you have some time to take another look at this? |
|
I promise to do it real soon! I have something else to finish first! |
…tests
### What changes were proposed in this pull request?
Replace symbols like 'abc and Symbol("abc") (where possible) with the more verbose $"abc" in the test code.
### Why are the changes needed?
This is a follow-up of #35560
Building with Scala 2.13 produces a lot of warnings like the following ones:
```
[warn] /home/runner/work/spark/spark/sql/core/src/test/scala/org/apache/spark/sql/execution/BaseScriptTransformationSuite.scala:562:11: [deprecation | origin= | version=2.13.0] symbol literal is deprecated; use Symbol("d") instead
[warn] 'd.cast("string"),
[warn] ^
[warn] /home/runner/work/spark/spark/sql/core/src/test/scala/org/apache/spark/sql/execution/BaseScriptTransformationSuite.scala:563:11: [deprecation | origin= | version=2.13.0] symbol literal is deprecated; use Symbol("e") instead
[warn] 'e.cast("string")).collect())
```
This should make it easier to upgrade to Scala 3 later.
### Does this PR introduce _any_ user-facing change?
No! The PR touches only test classes!
### How was this patch tested?
The build at CI must be green!
Closes #35976 from martin-g/spark-38661-replace-symbol-with-dollarSign.
Lead-authored-by: Martin Tzvetanov Grigorov <[email protected]>
Co-authored-by: Martin Grigorov <[email protected]>
Signed-off-by: Sean Owen <[email protected]>
What changes were proposed in this pull request?
Replace symbols like
'abcwith the more verbose `Symbol("abc") in the test code.Why are the changes needed?
Building with Scala 2.13 produces a lot of warnings like the following ones:
This should make it easier to upgrade to Scala 3 later.
Does this PR introduce any user-facing change?
No! The PR touches only test classes!
How was this patch tested?
The build at CI must be green!