Skip to content

fix: make table function arg coercion non-fatal, add raw_exprs accessor#23059

Open
sandy-sachin7 wants to merge 1 commit into
apache:mainfrom
sandy-sachin7:fix-22952-avoid-breaking-changes-table-function-args
Open

fix: make table function arg coercion non-fatal, add raw_exprs accessor#23059
sandy-sachin7 wants to merge 1 commit into
apache:mainfrom
sandy-sachin7:fix-22952-avoid-breaking-changes-table-function-args

Conversation

@sandy-sachin7

Copy link
Copy Markdown

Which issue does this PR close?

Rationale for this change

The type coercion and simplification applied to table function arguments in get_table_function_source can fail for custom table function expressions (e.g., tbf(a='x', b='x')), breaking user-facing SQL. The error propagates before the table function implementation ever sees the arguments.

What changes are included in this PR?

  1. Non-fatal coercion/simplification (session_state.rs): If coerce() or simplify() fails for a particular argument, fall back to the original raw expression instead of propagating the error. Existing built-in functions continue to get successfully coerced/simplified arguments as before.

  2. raw_exprs() accessor (table.rs): Added to TableFunctionArgs so that table function implementations can access the original, unprocessed arguments when needed. Added new_with_raw() constructor for this purpose.

Are these changes tested?

Covered by existing tests:

  • test_udtf_type_coercion - type coercion still works when it can succeed
  • test_simple_read_csv_udtf - basic UDTF functionality intact
  • generate_series tests - simplification path still works
  • type_coercion sqllogictests pass

Are there any user-facing changes?

Yes - custom table function implementations can now use args.raw_exprs() to access original expression arguments. No breaking changes to existing APIs.

Closes apache#22952

Changes:
- Make type coercion and simplification of table function arguments
  non-fatal: if coercion or simplification fails for a particular
  argument, fall back to the original raw expression instead of
  propagating the error.
- Add raw_exprs() accessor to TableFunctionArgs so that table function
  implementations can access the original, unprocessed arguments.
- Add new_with_raw() constructor for TableFunctionArgs when separate
  processed and raw expressions need to be passed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

catalog Related to the catalog crate core Core DataFusion crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Avoid breaking changes for table function args

1 participant