Skip to content

[AURON #1586]Implement native function of make_date(86) #1586#1587

Closed
guixiaowen wants to merge 1 commit intoapache:masterfrom
guixiaowen:add_make_date
Closed

[AURON #1586]Implement native function of make_date(86) #1586#1587
guixiaowen wants to merge 1 commit intoapache:masterfrom
guixiaowen:add_make_date

Conversation

@guixiaowen
Copy link
Contributor

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?

Factorial=65;
Hex=66;
Power=67;

Copy link
Contributor

Choose a reason for hiding this comment

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

Avoid blank lines.

""".stripMargin

val df = sql(functions)
checkAnswer(df, Seq(Row("2025-03-01")))
Copy link
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

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(),

Copy link
Contributor

Choose a reason for hiding this comment

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

Avoid blank lines.

@guixiaowen guixiaowen marked this pull request as draft November 2, 2025 11:58
@guixiaowen guixiaowen closed this Nov 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants