Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ case class StringColumnStat(statRow: InternalRow) {
// The indices here must be consistent with `ColumnStatStruct.stringColumnStat`.
val numNulls: Long = statRow.getLong(0)
val avgColLen: Double = statRow.getDouble(1)
val maxColLen: Long = statRow.getLong(2)
val maxColLen: Long = statRow.getInt(2)
val ndv: Long = statRow.getLong(3)
}

case class BinaryColumnStat(statRow: InternalRow) {
// The indices here must be consistent with `ColumnStatStruct.binaryColumnStat`.
val numNulls: Long = statRow.getLong(0)
val avgColLen: Double = statRow.getDouble(1)
val maxColLen: Long = statRow.getLong(2)
val maxColLen: Long = statRow.getInt(2)
}

case class BooleanColumnStat(statRow: InternalRow) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class StatisticsColumnSuite extends StatisticsTest {
val colStat = ColumnStat(InternalRow(
values.count(_.isEmpty).toLong,
nonNullValues.map(_.length).sum / nonNullValues.length.toDouble,
nonNullValues.map(_.length).max.toLong,
nonNullValues.map(_.length).max.toInt,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it even need toInt? I would presume it's already an int, but not sure.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question, but at least it documents the type

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can keep toInt, it explicitly shows the type.

nonNullValues.distinct.length.toLong))
(f, colStat)
}
Expand All @@ -165,7 +165,7 @@ class StatisticsColumnSuite extends StatisticsTest {
val colStat = ColumnStat(InternalRow(
values.count(_.isEmpty).toLong,
nonNullValues.map(_.length).sum / nonNullValues.length.toDouble,
nonNullValues.map(_.length).max.toLong))
nonNullValues.map(_.length).max.toInt))
(f, colStat)
}
checkColStats(df, expectedColStatsSeq)
Expand Down Expand Up @@ -255,10 +255,10 @@ class StatisticsColumnSuite extends StatisticsTest {
doubleSeq.distinct.length.toLong))
case StringType =>
ColumnStat(InternalRow(0L, stringSeq.map(_.length).sum / stringSeq.length.toDouble,
stringSeq.map(_.length).max.toLong, stringSeq.distinct.length.toLong))
stringSeq.map(_.length).max.toInt, stringSeq.distinct.length.toLong))
case BinaryType =>
ColumnStat(InternalRow(0L, binarySeq.map(_.length).sum / binarySeq.length.toDouble,
binarySeq.map(_.length).max.toLong))
binarySeq.map(_.length).max.toInt))
case BooleanType =>
ColumnStat(InternalRow(0L, booleanSeq.count(_.equals(true)).toLong,
booleanSeq.count(_.equals(false)).toLong))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ class StatisticsSuite extends QueryTest with TestHiveSingleton with SQLTestUtils
ColumnStat(InternalRow(0L, intSeq.max, intSeq.min, intSeq.distinct.length.toLong))
case StringType =>
ColumnStat(InternalRow(0L, stringSeq.map(_.length).sum / stringSeq.length.toDouble,
stringSeq.map(_.length).max.toLong, stringSeq.distinct.length.toLong))
stringSeq.map(_.length).max.toInt, stringSeq.distinct.length.toLong))
case BooleanType =>
ColumnStat(InternalRow(0L, booleanSeq.count(_.equals(true)).toLong,
booleanSeq.count(_.equals(false)).toLong))
Expand Down