Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
johanl-db committed Dec 18, 2023
1 parent a4e8048 commit cb1487e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,8 @@ public void readValues(
WritableColumnVector values,
VectorizedValuesReader valuesReader) {
for (int i = 0; i < total; ++i) {
values.putLong(offset + i, DateTimeUtils.daysToMicros(valuesReader.readInteger(), ZoneOffset.UTC));
long days = DateTimeUtils.daysToMicros(valuesReader.readInteger(), ZoneOffset.UTC);
values.putLong(offset + i, days);
}
}

Expand All @@ -353,7 +354,8 @@ public void readValue(
int offset,
WritableColumnVector values,
VectorizedValuesReader valuesReader) {
values.putLong(offset, DateTimeUtils.daysToMicros(valuesReader.readInteger(), ZoneOffset.UTC));
long days = DateTimeUtils.daysToMicros(valuesReader.readInteger(), ZoneOffset.UTC);
values.putLong(offset, days);
}

@Override
Expand Down Expand Up @@ -406,7 +408,8 @@ public void decodeSingleDictionaryId(
WritableColumnVector values,
WritableColumnVector dictionaryIds,
Dictionary dictionary) {
int rebasedDays = rebaseDays(dictionary.decodeToInt(dictionaryIds.getDictId(offset)), failIfRebase);
int rebasedDays =
rebaseDays(dictionary.decodeToInt(dictionaryIds.getDictId(offset)), failIfRebase);
values.putLong(offset, DateTimeUtils.daysToMicros(rebasedDays, ZoneOffset.UTC));
}
}
Expand Down Expand Up @@ -949,7 +952,8 @@ public void decodeSingleDictionaryId(
WritableColumnVector values,
WritableColumnVector dictionaryIds,
Dictionary dictionary) {
BigInteger value = BigInteger.valueOf(dictionary.decodeToInt(dictionaryIds.getDictId(offset)));
BigInteger value =
BigInteger.valueOf(dictionary.decodeToInt(dictionaryIds.getDictId(offset)));
values.putByteArray(offset, value.toByteArray());
}
}
Expand Down Expand Up @@ -987,7 +991,8 @@ public void decodeSingleDictionaryId(
WritableColumnVector values,
WritableColumnVector dictionaryIds,
Dictionary dictionary) {
BigInteger value = BigInteger.valueOf(dictionary.decodeToLong(dictionaryIds.getDictId(offset)));
BigInteger value =
BigInteger.valueOf(dictionary.decodeToLong(dictionaryIds.getDictId(offset)));
values.putByteArray(offset, value.toByteArray());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,15 @@ private boolean isLazyDecodingSupported(PrimitiveType.PrimitiveTypeName typeName
case INT32 -> {
boolean needsUpcast = sparkType == LongType || sparkType == TimestampNTZType ||
!DecimalType.is32BitDecimalType(sparkType);
boolean needsRebase = logicalTypeAnnotation instanceof DateLogicalTypeAnnotation && !"CORRECTED".equals(datetimeRebaseMode);
boolean needsRebase = logicalTypeAnnotation instanceof DateLogicalTypeAnnotation &&
!"CORRECTED".equals(datetimeRebaseMode);
yield !needsUpcast && !needsRebase && !needsDecimalScaleRebase(sparkType);
}
case INT64 -> {
boolean needsUpcast = !DecimalType.is64BitDecimalType(sparkType) ||
updaterFactory.isTimestampTypeMatched(TimeUnit.MILLIS);
boolean needsRebase = updaterFactory.isTimestampTypeMatched(TimeUnit.MICROS) && !"CORRECTED".equals(datetimeRebaseMode);
boolean needsRebase = updaterFactory.isTimestampTypeMatched(TimeUnit.MICROS) &&
!"CORRECTED".equals(datetimeRebaseMode);
yield !needsUpcast && !needsRebase && !needsDecimalScaleRebase(sparkType);
}
case FLOAT -> sparkType == FloatType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ import java.io.File
import org.apache.hadoop.fs.Path
import org.apache.parquet.format.converter.ParquetMetadataConverter
import org.apache.parquet.hadoop.{ParquetFileReader, ParquetOutputFormat}

import org.apache.spark.SparkException
import org.apache.spark.sql.{DataFrame, QueryTest, Row}
import org.apache.spark.sql.execution.adaptive.AdaptiveSparkPlanHelper
import org.apache.spark.sql.execution.datasources.SchemaColumnConvertNotSupportedException
import org.apache.spark.sql.functions.col
import org.apache.spark.sql.{DataFrame, QueryTest, Row}
import org.apache.spark.sql.internal.SQLConf
import org.apache.spark.sql.test.SharedSparkSession
import org.apache.spark.sql.types._
Expand Down Expand Up @@ -139,7 +140,7 @@ class ParquetTypeWideningSuite
}

for {
case (values: Seq[String], fromType: DataType, toType: DataType) <- Seq(
(values: Seq[String], fromType: DataType, toType: DataType) <- Seq(
(Seq("1", "2", Short.MinValue.toString), ShortType, IntegerType),
// Int->Short isn't a widening conversion but Parquet stores both as INT32 so it just works.
(Seq("1", "2", Short.MinValue.toString), IntegerType, ShortType),
Expand All @@ -152,7 +153,7 @@ class ParquetTypeWideningSuite
}

for {
case (values: Seq[String], fromType: DataType, toType: DataType) <- Seq(
(values: Seq[String], fromType: DataType, toType: DataType) <- Seq(
(Seq("1", "2", Int.MinValue.toString), LongType, IntegerType),
// Test different timestamp types
(Seq("2020-01-01", "2020-01-02", "1312-02-27"), TimestampNTZType, DateType),
Expand Down

0 comments on commit cb1487e

Please sign in to comment.