The GitHub Actions job "Required Checks" on texera.git/main has succeeded.
Run started by GitHub user github-merge-queue[bot] (triggered by 
github-merge-queue[bot]).

Head commit for run:
e1d676d10f723e251aadf9b3fb6f2147a6a1dd82 / Kary Zheng 
<[email protected]>
feat: keep a table's declared columns when it has no rows (#8766)

### What changes were proposed in this PR?

A port or result with no rows lost its columns in two places, both
because the column names were read off the first row.

- **Python engine.** A port that finished with no rows reached a Python
table operator as a table with no columns, so any operator naming one of
its columns raised `KeyError`: Sort, the visualization operators, and
any user-written `UDFTableOperator`. `Operator` gains an `input_schemas`
mapping that `DataProcessor` fills with the finishing port's declared
schema, and `TableOperator.on_finish` hands the operator those columns
with no rows under them. `Table.empty_of` builds that frame through
Arrow, so each column keeps the dtype it would have had with rows in it.
- **Result panel.** A result with no rows showed "Empty result set"
instead of its columns. `ExecutionResultService` now reports the stored
schema when a page has no rows, and the result table builds its header
from that schema when the whole result is empty. An empty page past the
end of a non-empty result still leaves the table already shown in place.

### Any related issues, documentation, discussions?

Closes #8735, which settled on this design (option 3) and asked for the
frontend to show a table with no records. The engine half was first
proposed in #8488.

### How was this PR tested?

-
`TestTableOperator.test_on_finish_with_no_rows_keeps_the_declared_columns`
and
`TestMainLoop.test_second_input_port_with_no_rows_finishes_as_itself`.
Both fail when the operator is handed the old columnless table. The rest
of `amber/src/test/python` passes, except the tests under
`core/storage/iceberg`, which need a running Postgres and Iceberg REST
catalog.
- `ExecutionResultServiceSpec` gains a case for a stored result with no
rows, and the past-the-end case now expects the stored schema. All 41
pass.
- `ResultTableFrameComponent` gains two cases: the header of an empty
result, and an empty page of a non-empty result keeping its table. All
53 pass.
- Manually: Text Input → Filter matching nothing → Sort. The run
completes, and Sort's result panel shows the `line` header with no rows.

Before and after. The first pair is the result panel of a Filter that
matches nothing. The second adds Sort after it, which used to fail with
`KeyError: 'line'`.

<img width="2056" height="1045" alt="8766-empty-result-table"
src="https://github.com/user-attachments/assets/3adba4b5-3ee4-40cc-ae1a-908f5dca2db1";
/>
<img width="2056" height="1045" alt="8766-sort-after-empty-filter"
src="https://github.com/user-attachments/assets/a547f04b-3633-4dc1-ad02-a1510805094d";
/>

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

Generated-by: Claude Code (Claude Opus 5.5)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

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

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

With regards,
GitHub Actions via GitBox

Reply via email to