-
Notifications
You must be signed in to change notification settings - Fork 247
Chore: Code hygiene - warn-numeric-widen #2588
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
base: main
Are you sure you want to change the base?
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 |
|---|---|---|
|
|
@@ -416,15 +416,15 @@ abstract class ParquetReadSuite extends CometTestBase { | |
| opt match { | ||
| case Some(i) => | ||
| record.add(0, i % 2 == 0) | ||
| record.add(1, i.toByte) | ||
| record.add(2, i.toShort) | ||
| record.add(1, i.toByte.toInt) | ||
|
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. its probably can be directly casted to int? 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. I believe overflow behaviour will be different and lead to unexpected and incorrect results |
||
| record.add(2, i.toShort.toInt) | ||
| record.add(3, i) | ||
| record.add(4, i.toLong) | ||
| record.add(5, i.toFloat) | ||
| record.add(6, i.toDouble) | ||
| record.add(7, i.toString * 48) | ||
| record.add(8, (-i).toByte) | ||
| record.add(9, (-i).toShort) | ||
| record.add(8, (-i).toByte.toInt) | ||
| record.add(9, (-i).toShort.toInt) | ||
| record.add(10, -i) | ||
| record.add(11, (-i).toLong) | ||
| record.add(12, i.toString) | ||
|
|
@@ -639,8 +639,8 @@ abstract class ParquetReadSuite extends CometTestBase { | |
| opt match { | ||
| case Some(i) => | ||
| record.add(0, i % 2 == 0) | ||
| record.add(1, i.toByte) | ||
| record.add(2, i.toShort) | ||
| record.add(1, i.toByte.toInt) | ||
| record.add(2, i.toShort.toInt) | ||
| record.add(3, i) | ||
| record.add(4, i.toLong) | ||
| record.add(5, i.toFloat) | ||
|
|
@@ -1575,15 +1575,15 @@ abstract class ParquetReadSuite extends CometTestBase { | |
| opt match { | ||
| case Some(i) => | ||
| record.add(0, i % 2 == 0) | ||
| record.add(1, i.toByte) | ||
| record.add(2, i.toShort) | ||
| record.add(1, i.toByte.toInt) | ||
| record.add(2, i.toShort.toInt) | ||
| record.add(3, i) | ||
| record.add(4, i.toLong) | ||
| record.add(5, i.toFloat) | ||
| record.add(6, i.toDouble) | ||
| record.add(7, i.toString * 48) | ||
| record.add(8, (-i).toByte) | ||
| record.add(9, (-i).toShort) | ||
| record.add(8, (-i).toByte.toInt) | ||
| record.add(9, (-i).toShort.toInt) | ||
| record.add(10, -i) | ||
| record.add(11, (-i).toLong) | ||
| record.add(12, i.toString) | ||
|
|
@@ -1672,7 +1672,7 @@ abstract class ParquetReadSuite extends CometTestBase { | |
| val record = new SimpleGroup(schema) | ||
| opt match { | ||
| case Some(i) => | ||
| record.add(0, i.toShort) | ||
| record.add(0, i.toShort.toInt) | ||
| record.add(1, i) | ||
| record.add(2, i.toLong) | ||
| case _ => | ||
|
|
@@ -1765,7 +1765,7 @@ abstract class ParquetReadSuite extends CometTestBase { | |
| } | ||
|
|
||
| private def withId(id: Int) = | ||
| new MetadataBuilder().putLong(ParquetUtils.FIELD_ID_METADATA_KEY, id).build() | ||
| new MetadataBuilder().putLong(ParquetUtils.FIELD_ID_METADATA_KEY, id.toLong).build() | ||
|
|
||
| // Based on Spark ParquetIOSuite.test("vectorized reader: array of nested struct") | ||
| test("array of nested struct with and without field id") { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,7 @@ package org.apache.spark.sql | |
|
|
||
| import java.util.concurrent.atomic.AtomicInteger | ||
|
|
||
| import scala.annotation.nowarn | ||
| import scala.concurrent.duration._ | ||
| import scala.reflect.ClassTag | ||
| import scala.reflect.runtime.universe.TypeTag | ||
|
|
@@ -425,6 +426,7 @@ abstract class CometTestBase | |
| case None => f(spark.read.format("parquet").load(path)) | ||
| } | ||
|
|
||
| @nowarn("cat=deprecation") | ||
| protected def createParquetWriter( | ||
| schema: MessageType, | ||
| path: Path, | ||
|
|
@@ -434,7 +436,6 @@ abstract class CometTestBase | |
| pageRowCountLimit: Int = ParquetProperties.DEFAULT_PAGE_ROW_COUNT_LIMIT, | ||
| rowGroupSize: Long = 1024 * 1024L): ParquetWriter[Group] = { | ||
| val hadoopConf = spark.sessionState.newHadoopConf() | ||
|
|
||
| ExampleParquetWriter | ||
| .builder(path) | ||
| .withDictionaryEncoding(dictionaryEnabled) | ||
|
|
@@ -557,15 +558,15 @@ abstract class CometTestBase | |
| opt match { | ||
| case Some(i) => | ||
| record.add(0, i % 2 == 0) | ||
| record.add(1, i.toByte) | ||
| record.add(2, i.toShort) | ||
| record.add(1, i.toByte.toInt) | ||
|
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. same, can be probably converted directly |
||
| record.add(2, i.toShort.toInt) | ||
| record.add(3, i) | ||
| record.add(4, i.toLong) | ||
| record.add(5, i.toFloat) | ||
| record.add(6, i.toDouble) | ||
| record.add(7, i.toString * 48) | ||
| record.add(8, (-i).toByte) | ||
| record.add(9, (-i).toShort) | ||
| record.add(8, (-i).toByte.toInt) | ||
| record.add(9, (-i).toShort.toInt) | ||
| record.add(10, -i) | ||
| record.add(11, (-i).toLong) | ||
| record.add(12, i.toString) | ||
|
|
@@ -586,15 +587,15 @@ abstract class CometTestBase | |
| val i = rand.nextLong() | ||
| val record = new SimpleGroup(schema) | ||
| record.add(0, i % 2 == 0) | ||
| record.add(1, i.toByte) | ||
| record.add(2, i.toShort) | ||
| record.add(1, i.toByte.toInt) | ||
| record.add(2, i.toShort.toInt) | ||
| record.add(3, i.toInt) | ||
| record.add(4, i) | ||
| record.add(5, java.lang.Float.intBitsToFloat(i.toInt)) | ||
| record.add(6, java.lang.Double.longBitsToDouble(i)) | ||
| record.add(7, i.toString * 24) | ||
| record.add(8, (-i).toByte) | ||
| record.add(9, (-i).toShort) | ||
| record.add(8, (-i).toByte.toInt) | ||
| record.add(9, (-i).toShort.toInt) | ||
| record.add(10, (-i).toInt) | ||
| record.add(11, -i) | ||
| record.add(12, i.toString) | ||
|
|
@@ -643,7 +644,7 @@ abstract class CometTestBase | |
| if (rand.nextBoolean()) { | ||
| None | ||
| } else { | ||
| Some(getValue(i, div)) | ||
| Some(getValue(i.toLong, div.toLong)) | ||
| } | ||
| } | ||
| expected.foreach { opt => | ||
|
|
@@ -697,7 +698,7 @@ abstract class CometTestBase | |
| if (rand.nextBoolean()) { | ||
| None | ||
| } else { | ||
| Some(getValue(i, div)) | ||
| Some(getValue(i.toLong, div.toLong)) | ||
| } | ||
| } | ||
| expected.foreach { opt => | ||
|
|
@@ -875,7 +876,7 @@ abstract class CometTestBase | |
| val div = if (dictionaryEnabled) 10 else n // maps value to a small range for dict to kick in | ||
|
|
||
| val expected = (0 until n).map { i => | ||
| Some(getValue(i, div)) | ||
| Some(getValue(i.toLong, div.toLong)) | ||
| } | ||
| expected.foreach { opt => | ||
| val timestampFormats = List( | ||
|
|
@@ -923,7 +924,7 @@ abstract class CometTestBase | |
| def makeDecimalRDD(num: Int, decimal: DecimalType, useDictionary: Boolean): DataFrame = { | ||
| val div = if (useDictionary) 5 else num // narrow the space to make it dictionary encoded | ||
| spark | ||
| .range(num) | ||
| .range(num.toLong) | ||
| .map(_ % div) | ||
| // Parquet doesn't allow column names with spaces, have to add an alias here. | ||
| // Minus 500 here so that negative decimals are also tested. | ||
|
|
@@ -1103,8 +1104,8 @@ abstract class CometTestBase | |
| val record = new SimpleGroup(schema) | ||
| opt match { | ||
| case Some(i) => | ||
| record.add(0, i.toByte) | ||
| record.add(1, i.toShort) | ||
| record.add(0, i.toByte.toInt) | ||
|
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. same |
||
| record.add(1, i.toShort.toInt) | ||
| record.add(2, i) | ||
| record.add(3, i.toLong) | ||
| record.add(4, rand.nextFloat()) | ||
|
|
||
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.
Are these intended changes down here?