nerdexam
Snowflake

DEA-C02 · Question #136

A Data Engineer has created two SQL User-Defined Functions (UDFs) with the same name: The following function call is made: select plus5(to_date('2024-01-25')); What will be the output of this call?

The correct answer is D. The SQL compilation error: error line 1 at position 7 Invalid argument types. Option D is correct because the two overloaded plus5 UDFs are defined to accept specific types (typically one for NUMBER and one for VARCHAR), and to_date('2024-01-25') returns a DATE - a type that matches neither UDF signature, so the SQL engine cannot resolve which function…

Data Transformation

Question

A Data Engineer has created two SQL User-Defined Functions (UDFs) with the same name:

The following function call is made:

select plus5(to_date(‘2024-01-25’)); What will be the output of this call?

Exhibit

DEA-C02 question #136 exhibit

Options

  • A2024-01-30
  • B2024-01-255
  • C2024-01-25'5'
  • DThe SQL compilation error: error line 1 at position 7 Invalid argument types

How the community answered

(38 responses)
  • A
    3% (1)
  • B
    8% (3)
  • C
    16% (6)
  • D
    74% (28)

Explanation

Option D is correct because the two overloaded plus5 UDFs are defined to accept specific types (typically one for NUMBER and one for VARCHAR), and to_date('2024-01-25') returns a DATE - a type that matches neither UDF signature, so the SQL engine cannot resolve which function to call and throws a compilation error at parse time. Option A (2024-01-30) is tempting but wrong because it assumes a date-aware UDF exists that adds 5 days; no such signature is defined. Options B and C represent impossible string-concatenation artifacts that no valid UDF logic would produce, making them easy eliminations. The key insight for exam takers: UDF overloading resolution is strict - the engine matches by argument type, and passing a DATE where only NUMBER or VARCHAR signatures exist causes a compile-time failure, not a runtime one, so the query never even executes. Remember this with the phrase "wrong type, won't even try" - SQL won't attempt implicit DATE conversion to resolve an ambiguous overload.

Topics

#User-Defined Functions (UDFs)#Function Overloading#Data Types#SQL Compilation Errors

Community Discussion

No community discussion yet for this question.

Full DEA-C02 Practice