[AURON #1586]Implement native function of make_date(86) #1586#1587
[AURON #1586]Implement native function of make_date(86) #1586#1587guixiaowen wants to merge 1 commit intoapache:masterfrom
Conversation
| Factorial=65; | ||
| Hex=66; | ||
| Power=67; | ||
|
|
| """.stripMargin | ||
|
|
||
| val df = sql(functions) | ||
| checkAnswer(df, Seq(Row("2025-03-01"))) |
There was a problem hiding this comment.
Spark’s make_date(year, month, day) returns a DateType (invalid inputs return NULL when ANSI is disabled). The current test uses checkAnswer(df, Seq(Row("2025-03-01"))) to assert a string literal; a more robust approach is to assert the type—e.g., expect Date.valueOf("2025-03-01"), or at least verify df.schema.fields(0).dataType == DateType.
https://spark.apache.org/docs/latest/api/sql/index.html#make_date
There was a problem hiding this comment.
Cover invalid inputs and NULL semantics (suggest adding test cases)
Additional cases: make_date(2019, 13, 1) -> NULL, make_date(2019, 2, 30) -> NULL, and any argument being NULL -> NULL. These are consistent with the official/Databricks documentation.
There was a problem hiding this comment.
Nit:
Avoid using aliases that have the same names as Spark functions. It’s better to write:
select '2025' as `year`, '03' as `month`, '01' as `day`
instead of:
select '2025' as year, '03' as month, '01' as day
| ScalarFunction::NullIf => f::core::nullif(), | ||
| ScalarFunction::DatePart => f::datetime::date_part(), | ||
| ScalarFunction::DateTrunc => f::datetime::date_trunc(), | ||
|
|
Which issue does this PR close?
Closes #.
Rationale for this change
What changes are included in this PR?
Are there any user-facing changes?
How was this patch tested?