Skip to content

Commit 0852655

Browse files
committed
[SPARK-8119] changed from ExpectsInputTypes to implicit casts
1 parent ec87c69 commit 0852655

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

python/pyspark/sql/functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ def dayInYear(col):
723723
Extract the day of the year of a given date as integer.
724724
>>> df0 = sqlContext.createDataFrame([('2015-04-08',)], ['a'])
725725
>>> df0.select(dayInYear('a').alias('day')).collect()
726-
[Row(day=128)]
726+
[Row(day=98)]
727727
"""
728728
sc = SparkContext._active_spark_context
729729
return Column(sc._jvm.functions.day(col))

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeFunctions.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ case class CurrentTimestamp() extends LeafExpression {
6161
}
6262
}
6363

64-
case class Hour(child: Expression) extends UnaryExpression with ExpectsInputTypes {
64+
case class Hour(child: Expression) extends UnaryExpression with ImplicitCastInputTypes {
6565

6666
override def inputTypes: Seq[AbstractDataType] = Seq(TimestampType)
6767

@@ -82,7 +82,7 @@ case class Hour(child: Expression) extends UnaryExpression with ExpectsInputType
8282
}
8383
}
8484

85-
case class Minute(child: Expression) extends UnaryExpression with ExpectsInputTypes {
85+
case class Minute(child: Expression) extends UnaryExpression with ImplicitCastInputTypes {
8686

8787
override def inputTypes: Seq[AbstractDataType] = Seq(TimestampType)
8888

@@ -103,7 +103,7 @@ case class Minute(child: Expression) extends UnaryExpression with ExpectsInputTy
103103
}
104104
}
105105

106-
case class Second(child: Expression) extends UnaryExpression with ExpectsInputTypes {
106+
case class Second(child: Expression) extends UnaryExpression with ImplicitCastInputTypes {
107107

108108
override def inputTypes: Seq[AbstractDataType] = Seq(TimestampType)
109109

@@ -120,7 +120,7 @@ case class Second(child: Expression) extends UnaryExpression with ExpectsInputTy
120120
}
121121
}
122122

123-
abstract class DateFormatExpression extends UnaryExpression with ExpectsInputTypes {
123+
abstract class DateFormatExpression extends UnaryExpression with ImplicitCastInputTypes {
124124
self: Product =>
125125

126126
val daysIn400Years: Int = 146097
@@ -310,7 +310,7 @@ case class Month(child: Expression) extends DateFormatExpression {
310310
}
311311
}
312312

313-
case class Day(child: Expression) extends DateFormatExpression with ExpectsInputTypes {
313+
case class Day(child: Expression) extends DateFormatExpression with ImplicitCastInputTypes {
314314

315315
override def dataType: DataType = IntegerType
316316

@@ -373,7 +373,7 @@ case class Day(child: Expression) extends DateFormatExpression with ExpectsInput
373373

374374
}
375375

376-
case class WeekOfYear(child: Expression) extends UnaryExpression with ExpectsInputTypes {
376+
case class WeekOfYear(child: Expression) extends UnaryExpression with ImplicitCastInputTypes {
377377

378378
override def dataType: DataType = IntegerType
379379

@@ -398,7 +398,7 @@ case class WeekOfYear(child: Expression) extends UnaryExpression with ExpectsInp
398398
}
399399

400400
case class DateFormatClass(left: Expression, right: Expression) extends BinaryExpression
401-
with ExpectsInputTypes {
401+
with ImplicitCastInputTypes {
402402

403403
override def dataType: DataType = StringType
404404

sql/core/src/test/scala/org/apache/spark/sql/DatetimeExpressionsSuite.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,11 @@ class DatetimeExpressionsSuite extends QueryTest {
123123

124124
checkAnswer(
125125
df.select(dayInYear("a"), dayInYear("b"), dayInYear("c")),
126-
Row(128, 128, 128))
126+
Row(98, 98, 98))
127127

128128
checkAnswer(
129129
df.selectExpr("dayInYear(a)", "dayInYear(b)", "dayInYear(c)"),
130-
Row(128, 128, 128))
130+
Row(98, 98, 98))
131131
}
132132

133133
test("hour") {

0 commit comments

Comments
 (0)