Skip to content

Commit

Permalink
[SPARK-42876][SQL] DataType's physicalDataType should be private[sql]
Browse files Browse the repository at this point in the history
### What changes were proposed in this pull request?

`physicalDataType` should not be a public API but be private[sql].

### Why are the changes needed?

This is to limit API scope to not expose unnecessary API to be public.

### Does this PR introduce _any_ user-facing change?

No since we have not released Spark 3.4.0 yet.

### How was this patch tested?

N/A

Closes #40499 from amaliujia/change_scope_of_physical_data_type.

Authored-by: Rui Wang <rui.wang@databricks.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
(cherry picked from commit c9a530e)
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
  • Loading branch information
amaliujia authored and cloud-fan committed Mar 21, 2023
1 parent ed797bb commit 8cffa5c
Show file tree
Hide file tree
Showing 23 changed files with 24 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ case class ArrayType(elementType: DataType, containsNull: Boolean) extends DataT
*/
override def defaultSize: Int = 1 * elementType.defaultSize

override def physicalDataType: PhysicalDataType =
private[sql] override def physicalDataType: PhysicalDataType =
PhysicalArrayType(elementType, containsNull)

override def simpleString: String = s"array<${elementType.simpleString}>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class BinaryType private() extends AtomicType {
*/
override def defaultSize: Int = 100

override def physicalDataType: PhysicalDataType = PhysicalBinaryType
private[sql] override def physicalDataType: PhysicalDataType = PhysicalBinaryType

private[spark] override def asNullable: BinaryType = this
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class BooleanType private() extends AtomicType {
*/
override def defaultSize: Int = 1

override def physicalDataType: PhysicalDataType = PhysicalBooleanType
private[sql] override def physicalDataType: PhysicalDataType = PhysicalBooleanType

private[spark] override def asNullable: BooleanType = this
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ByteType private() extends IntegralType {
*/
override def defaultSize: Int = 1

override def physicalDataType: PhysicalDataType = PhysicalByteType
private[sql] override def physicalDataType: PhysicalDataType = PhysicalByteType

override def simpleString: String = "tinyint"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class CalendarIntervalType private() extends DataType {

override def defaultSize: Int = 16

override def physicalDataType: PhysicalDataType = PhysicalCalendarIntervalType
private[sql] override def physicalDataType: PhysicalDataType = PhysicalCalendarIntervalType

override def typeName: String = "interval"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ case class CharType(length: Int) extends AtomicType {
private[sql] val ordering = implicitly[Ordering[InternalType]]

override def defaultSize: Int = length
override def physicalDataType: PhysicalDataType = PhysicalStringType
private[sql] override def physicalDataType: PhysicalDataType = PhysicalStringType
override def typeName: String = s"char($length)"
override def toString: String = s"CharType($length)"
private[spark] override def asNullable: CharType = this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ abstract class DataType extends AbstractDataType {

override private[sql] def acceptsType(other: DataType): Boolean = sameType(other)

def physicalDataType: PhysicalDataType = UninitializedPhysicalType
private[sql] def physicalDataType: PhysicalDataType = UninitializedPhysicalType
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class DateType private() extends DatetimeType {
*/
override def defaultSize: Int = 4

override def physicalDataType: PhysicalDataType = PhysicalIntegerType
private[sql] override def physicalDataType: PhysicalDataType = PhysicalIntegerType

private[spark] override def asNullable: DateType = this
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ case class DayTimeIntervalType(startField: Byte, endField: Byte) extends AnsiInt
*/
override def defaultSize: Int = 8

override def physicalDataType: PhysicalDataType = PhysicalLongType
private[sql] override def physicalDataType: PhysicalDataType = PhysicalLongType

private[spark] override def asNullable: DayTimeIntervalType = this

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ case class DecimalType(precision: Int, scale: Int) extends FractionalType {
*/
override def defaultSize: Int = if (precision <= Decimal.MAX_LONG_DIGITS) 8 else 16

override def physicalDataType: PhysicalDataType = PhysicalDecimalType(precision, scale)
private[sql] override def physicalDataType: PhysicalDataType =
PhysicalDecimalType(precision, scale)

override def simpleString: String = s"decimal($precision,$scale)"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class DoubleType private() extends FractionalType {
*/
override def defaultSize: Int = 8

override def physicalDataType: PhysicalDataType = PhysicalDoubleType
private[sql] override def physicalDataType: PhysicalDataType = PhysicalDoubleType

private[spark] override def asNullable: DoubleType = this
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class FloatType private() extends FractionalType {
*/
override def defaultSize: Int = 4

override def physicalDataType: PhysicalDataType = PhysicalFloatType
private[sql] override def physicalDataType: PhysicalDataType = PhysicalFloatType

private[spark] override def asNullable: FloatType = this
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class IntegerType private() extends IntegralType {
*/
override def defaultSize: Int = 4

override def physicalDataType: PhysicalDataType = PhysicalIntegerType
private[sql] override def physicalDataType: PhysicalDataType = PhysicalIntegerType

override def simpleString: String = "int"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class LongType private() extends IntegralType {
*/
override def defaultSize: Int = 8

override def physicalDataType: PhysicalDataType = PhysicalLongType
private[sql] override def physicalDataType: PhysicalDataType = PhysicalLongType

override def simpleString: String = "bigint"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ case class MapType(
*/
override def defaultSize: Int = 1 * (keyType.defaultSize + valueType.defaultSize)

override def physicalDataType: PhysicalDataType =
private[sql] override def physicalDataType: PhysicalDataType =
PhysicalMapType(keyType, valueType, valueContainsNull)

override def simpleString: String = s"map<${keyType.simpleString},${valueType.simpleString}>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class NullType private() extends DataType {
// Defined with a private constructor so the companion object is the only possible instantiation.
override def defaultSize: Int = 1

override def physicalDataType: PhysicalDataType = PhysicalNullType
private[sql] override def physicalDataType: PhysicalDataType = PhysicalNullType

private[spark] override def asNullable: NullType = this

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ShortType private() extends IntegralType {
*/
override def defaultSize: Int = 2

override def physicalDataType: PhysicalDataType = PhysicalShortType
private[sql] override def physicalDataType: PhysicalDataType = PhysicalShortType

override def simpleString: String = "smallint"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class StringType private() extends AtomicType {
*/
override def defaultSize: Int = 20

override def physicalDataType: PhysicalDataType = PhysicalStringType
private[sql] override def physicalDataType: PhysicalDataType = PhysicalStringType

private[spark] override def asNullable: StringType = this
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ case class StructType(fields: Array[StructField]) extends DataType with Seq[Stru
*/
override def defaultSize: Int = fields.map(_.dataType.defaultSize).sum

override def physicalDataType: PhysicalDataType = PhysicalStructType(fields)
private[sql] override def physicalDataType: PhysicalDataType = PhysicalStructType(fields)

override def simpleString: String = {
val fieldTypes = fields.view.map(field => s"${field.name}:${field.dataType.simpleString}").toSeq
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class TimestampNTZType private() extends DatetimeType {
*/
override def defaultSize: Int = 8

override def physicalDataType: PhysicalDataType = PhysicalLongType
private[sql] override def physicalDataType: PhysicalDataType = PhysicalLongType

override def typeName: String = "timestamp_ntz"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class TimestampType private() extends DatetimeType {
*/
override def defaultSize: Int = 8

override def physicalDataType: PhysicalDataType = PhysicalLongType
private[sql] override def physicalDataType: PhysicalDataType = PhysicalLongType

private[spark] override def asNullable: TimestampType = this
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ case class VarcharType(length: Int) extends AtomicType {
require(length >= 0, "The length of varchar type cannot be negative.")

private[sql] type InternalType = UTF8String
override def physicalDataType: PhysicalDataType = PhysicalStringType
private[sql] override def physicalDataType: PhysicalDataType = PhysicalStringType
@transient private[sql] lazy val tag = typeTag[InternalType]
private[sql] val ordering = implicitly[Ordering[InternalType]]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ case class YearMonthIntervalType(startField: Byte, endField: Byte) extends AnsiI
*/
override def defaultSize: Int = 4

override def physicalDataType: PhysicalDataType = PhysicalIntegerType
private[sql] override def physicalDataType: PhysicalDataType = PhysicalIntegerType

private[spark] override def asNullable: YearMonthIntervalType = this

Expand Down

0 comments on commit 8cffa5c

Please sign in to comment.