Skip to content

Validate arguments for datetime, string, and math UDFs #3512

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

yuancu
Copy link
Contributor

@yuancu yuancu commented Apr 3, 2025

Description

Created a custom validator to validate the arguments of UDFs

TODOs:

Covered functions

String

  • REPLACE
  • ASCII
  • LENGTH
  • LOWER
  • LTRIM
  • REVERSE
  • RTRIM
  • UPPER
  • TRIM
  • CONCAT_WS
  • SUBSTRING
  • SUBSTR
  • LOCATE
  • POSITION
  • STRCMP
  • LEFT
  • RIGHT
  • CONCAT

Math

  • ABS
  • ACOS
  • ASIN
  • COS
  • COT
  • DEGREES
  • EXP
  • FLOOR
  • LN
  • LOG2
  • LOG10
  • RADIANS
  • SIGN
  • SIN
  • SQRT
  • CBRT
  • ATAN
  • LOG
  • ATAN2
  • MOD
  • POW
  • POWER
  • CEIL
  • CEILING
  • CONV
  • CRC32
  • E
  • PI
  • RAND
  • ROUND

Date / time

  • ADDDATE
  • SUBDATE
  • DATE_ADD
  • DATE_SUB
  • ADDTIME
  • SUBTIME
  • DATEDIFF
  • CONVERT_TZ
  • CURDATE
  • CURRENT_DATE
  • CURRENT_TIME
  • LOCALTIMESTAMP
  • LOCALTIME
  • CURRENT_TIMESTAMP
  • NOW
  • CURTIME
  • UTC_DATE
  • UTC_TIME
  • UTC_TIMESTAMP
  • DAY
  • DAY_OF_WEEK
  • DAYOFWEEK
  • DAY_OF_YEAR
  • DAYOFYEAR
  • DAYNAME
  • DAYOFMONTH
  • DAY_OF_MONTH
  • MONTHNAME
  • QUARTER
  • TO_DAYS
  • YEAR
  • DATE
  • HOUR
  • HOUR_OF_DAY
  • LAST_DAY
  • MICROSECOND
  • MINUTE
  • MINUTE_OF_DAY
  • MINUTE_OF_HOUR
  • MONTH
  • MONTH_OF_YEAR
  • SECOND
  • SECOND_OF_MINUTE
  • WEEKDAY
  • TIME
  • TIME_TO_SEC
  • MAKEDATE
  • MAKETIME
  • EXTRACT
  • FROM_DAYS
  • SEC_TO_TIME
  • FROM_UNIXTIME
  • GET_FORMAT
  • STR_TO_DATE
  • DATETIME
  • SYSDATE
  • DATE_FORMAT
  • TIME_FORMAT
  • PERIOD_ADD
  • PERIOD_DIFF
  • TIMESTAMP
  • TIMESTAMPADD
  • TIMESTAMPDIFF
  • TIMEDIFF
  • TO_SECONDS
  • UNIX_TIMESTAMP
  • WEEK
  • WEEK_OF_YEAR
  • YEARWEEK

Related Issues

Relevant to issue #3400
Complement missing argument validation for PR #3473

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • New functionality has javadoc added.
  • New functionality has a user manual doc added.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@yuancu yuancu changed the title Validate arguments Validate arguments for datetime, string, and math UDFs Apr 3, 2025
@yuancu
Copy link
Contributor Author

yuancu commented Apr 3, 2025

The prompted error message when arguments are incompatible lacks expected argument types.
For example, when UNIX_TIMESTAMP get 2 TIME as argument, it will prompt Function UNIX_TIMESTAMP got incompatible arguments: (TIME, TIME), whereas in v2 it prompts unix_timestamp function expected {[],[DATE],[DATETIME],[TIMESTAMP],[DOUBLE]}, but get [TIME,TIME].

@LantaoJin Do you think this suffices since we may deprecate this argument validator in favor of a more organized one like that in v2.x, or do you think we'd better align with the error message in v2.

@opensearch-trigger-bot
Copy link
Contributor

This PR is stalled because it has been open for 30 days with no activity.

@seankao-az seankao-az added the calcite calcite migration releated label May 13, 2025
@yuancu yuancu closed this May 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
calcite calcite migration releated
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants