Skip to content
Merged
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 @@ -37,4 +37,20 @@ class BlazeQuerySuite extends org.apache.spark.sql.QueryTest with BaseBlazeSQLSu
}
}

test("test filter with year function") {
withTable("t1") {
sql("create table t1 using parquet as select '2024-12-18' as event_time")
checkAnswer(
sql(
"""
|select year, count(*)
|from (select event_time, year(event_time) as year from t1) t
|where year <= 2024
|group by year
|""".stripMargin),
Seq(Row(2024, 1))
)
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -873,9 +873,9 @@ object NativeConverters extends Logging {
case XxHash64(children, 42L) =>
buildExtScalarFunction("XxHash64", children, LongType)

case Year(child) => buildExtScalarFunction("Year", child :: Nil, DateType)
case Month(child) => buildExtScalarFunction("Month", child :: Nil, DateType)
case DayOfMonth(child) => buildExtScalarFunction("Day", child :: Nil, DateType)
case Year(child) => buildExtScalarFunction("Year", child :: Nil, IntegerType)
case Month(child) => buildExtScalarFunction("Month", child :: Nil, IntegerType)
case DayOfMonth(child) => buildExtScalarFunction("Day", child :: Nil, IntegerType)

// startswith is converted to scalar function in pruning-expr mode
case StartsWith(expr, Literal(prefix, StringType)) if isPruningExpr =>
Expand Down