Bug: Fix "Widening conversion from `TypeA` to `TypeB` is deprecated because it loses precision"
Status: Resolved | Priority: Major | Resolution: Fixed
Created: 27/Oct/23 03:24
Affects Version/s: 4.0.0

{code:java}
error] /Users/yangjie01/SourceCode/git/spark-mine-sbt/core/src/main/scala/org/apache/spark/scheduler/TaskSetManager.scala:1199:67: Widening conversion from Long to Double is deprecated because it loses precision. Write `.toDouble` instead. [quickfixable]
[error] Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=deprecation, site=org.apache.spark.scheduler.TaskSetManager.checkSpeculatableTasks.threshold
[error]       val threshold = max(speculationMultiplier * medianDuration, minTimeToSpeculation)
[error]                                                                   ^
[error] /Users/yangjie01/SourceCode/git/spark-mine-sbt/core/src/main/scala/org/apache/spark/scheduler/TaskSetManager.scala:1207:60: Widening conversion from Long to Double is deprecated because it loses precision. Write `.toDouble` instead. [quickfixable]
[error] Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=deprecation, site=org.apache.spark.scheduler.TaskSetManager.checkSpeculatableTasks
[error]       foundTasks = checkAndSubmitSpeculatableTasks(timeMs, threshold, customizedThreshold = true)
[error]                                                            ^
[error] /Users/yangjie01/SourceCode/git/spark-mine-sbt/connector/connect/common/src/main/scala/org/apache/spark/sql/connect/client/arrow/ArrowVectorReader.scala:137:48: Widening conversion from Int to Float is deprecated because it loses precision. Write `.toFloat` instead. [quickfixable]
[error] Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=deprecation, site=org.apache.spark.sql.connect.client.arrow.IntVectorReader.getFloat
[error]   override def getFloat(i: Int): Float = getInt(i)
[error]                                                ^
[error] /Users/yangjie01/SourceCode/git/spark-mine-sbt/connector/connect/common/src/main/scala/org/apache/spark/sql/connect/client/arrow/ArrowVectorReader.scala:146:49: Widening conversion from Long to Float is deprecated because it loses precision. Write `.toFloat` instead. [quickfixable]
[error] Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=deprecation, site=org.apache.spark.sql.connect.client.arrow.BigIntVectorReader.getFloat
[error]   override def getFloat(i: Int): Float = getLong(i)
[error]                                                 ^
[error] /Users/yangjie01/SourceCode/git/spark-mine-sbt/connector/connect/common/src/main/scala/org/apache/spark/sql/connect/client/arrow/ArrowVectorReader.scala:147:51: Widening conversion from Long to Double is deprecated because it loses precision. Write `.toDouble` instead. [quickfixable]
[error] Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=deprecation, site=org.apache.spark.sql.connect.client.arrow.BigIntVectorReader.getDouble
[error]   override def getDouble(i: Int): Double = getLong(i)
[error]                                                   ^ {code}
 

 
The example of the compilation warning is as above, there are probably over 100 similar cases that need to be fixed.