The GitHub Actions job "Backport Approval Check" on 
texera.git/gh-readonly-queue/main/pr-8769-23c0e5a1882de7c564cdbe093d5a89649a47e1b4
 has succeeded.
Run started by GitHub user Xiao-zhen-Liu (triggered by Xiao-zhen-Liu).

Head commit for run:
5945cc81858e33db3d5280e9913e089f2035b3a6 / Suryaa Charan 
<[email protected]>
feat(pyamber): clear errors for return-instead-of-yield and output mismatches 
(#8769)

### What changes were proposed in this PR?

Clear messages for the common Python UDF mistakes that show up while the
workflow runs:

- **`return` instead of `yield`** in `process_tuple`, `process_batch`,
`process_table` or `produce` now says `process_table must yield results,
not return them. Replace return x with yield x.` Before, users saw
`pampy.MatchError: '_' not provided` or `'NoneType' object is not
iterable`. Returning a list still works.
- **`__init__` without `super().__init__()`** on a table or batch UDF no
longer crashes with `'_TableOperator__table_data'`. The buffers are
created on first use, the same way `Operator` already creates its
template decoder.
- **A DataFrame in a non-binary column** now says which column, and to
yield the DataFrame itself or make the column binary. A DataFrame in a
BINARY column is pickled as before.
- **Output columns that don't match** keep the original message and
point to "Retain input columns" and "Extra output column(s)" (or
"Columns" for a 1-out Python UDF).

Before and after, in the Console:

| Before | After |
|---|---|
|<img width="800" height="288" alt="runtime-before"
src="https://github.com/user-attachments/assets/7f854ffe-f5eb-4013-8fe4-9eb3a9e740ff";
/> | <img width="800" height="288" alt="runtime-after"
src="https://github.com/user-attachments/assets/fbaec933-683f-4dd2-b603-5d988b4f338d";
/> |

### Any related issues, documentation, discussions?

Part of #8736. Split out of #8737.

### How was this PR tested?

New tests in `test_operator.py` (each `return` case, a returned list
still working, table and batch UDFs with and without
`super().__init__()`) and `test_data_processor.py` (`process_tuple` and
`on_finish` returning a value, a DataFrame in BINARY, LARGE_BINARY and
STRING columns, a missing or misspelled column next to a DataFrame, a
wrong column type).

```
cd amber
pytest -m "not integration" src/test/python/core/models/test_operator.py 
src/test/python/core/runnables/test_data_processor.py
pytest -m "not integration"
ruff check src/main/python src/test/python && ruff format --check 
src/main/python src/test/python
```

The screenshots are from a local Texera built from this branch.

### Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Claude Opus 5.5)

---------

Co-authored-by: suryaacharan <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>

Report URL: https://github.com/apache/texera/actions/runs/38791363662

With regards,
GitHub Actions via GitBox

Reply via email to