Skip to content

pg_lake_table: allow debug plan output for restriction nodes - #486

Open
marknefedov wants to merge 4 commits into
Snowflake-Labs:mainfrom
marknefedov:fix/issue-106-debug-node-output
Open

pg_lake_table: allow debug plan output for restriction nodes#486
marknefedov wants to merge 4 commits into
Snowflake-Labs:mainfrom
marknefedov:fix/issue-106-debug-node-output

Conversation

@marknefedov

@marknefedov marknefedov commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Problem

PostgreSQL diagnostic node printing walks the private data attached to planned
scan nodes. Both pg_lake scan paths store PlannerRelationRestriction
extensible nodes in that private data:

  • full-query pushdown stores them in CustomScan.custom_private
  • the FDW path stores them in ForeignScan.fdw_private

PostgreSQL calls the registered nodeOut callback when it prints either plan.
That callback previously raised ERROR: out not implemented, so the diagnostic
configuration reported in #106 (pg_ctl ... -o "-d 5") could make an otherwise
valid lake-table query fail during planning.

Solution

Add a dedicated output function for PlannerRelationRestriction.

The callback follows PostgreSQL's node-output convention and emits both private
fields:

  • rte
  • baseRestrictionList

PostgreSQL continues to emit the extensible-node type and name itself. The
private fields are delegated to outNode, so nested RangeTblEntry and
RestrictInfo nodes, as well as NULL or empty lists, use PostgreSQL's existing
formatting behavior.

nodeRead remains unsupported because this node is transient planner
bookkeeping and pg_lake does not deserialize it from text. The
DEFINE_NODE_METHODS macro now selects Out##type, requiring each future
pg_lake extensible-node type to define its own output behavior.

Regression coverage

The new test enables debug_print_plan, routes its LOG output to the client,
and exercises:

  • Custom Scan (Query Pushdown) with full-query pushdown enabled
  • Foreign Scan with full-query pushdown disabled
  • an empty restriction list
  • a non-empty restriction list produced by a WHERE clause

For every case, the test verifies the expected scan type, successful execution,
and diagnostic output containing PlannerRelationRestriction, rte, and
baseRestrictionList.

Validation

  • PostgreSQL 18 pgindent --check --diff
  • Black 25.9.0
  • focused compilation against PostgreSQL 16, 17, and 18 headers
  • PostgreSQL 18 build and install of pg_lake_table.so
  • focused pytest:
    test_relation_restriction.py::test_debug_print_plan_with_lake_table

Fixes #106.

Mark Nefedov added 2 commits July 26, 2026 14:44
Signed-off-by: Mark Nefedov <mvnefedov@avito.ru>
Signed-off-by: Mark Nefedov <mvnefedov@avito.ru>
Comment thread pg_lake_table/src/planner/extensible_nodes.c
@marknefedov
marknefedov marked this pull request as draft July 27, 2026 10:28
Mark Nefedov added 2 commits July 27, 2026 14:29
Signed-off-by: Mark Nefedov <mvnefedov@avito.ru>
Signed-off-by: Mark Nefedov <mvnefedov@avito.ru>
@marknefedov
marknefedov marked this pull request as ready for review July 27, 2026 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"ERROR: out not implemented" when -o "-d 5" option is used with pg_ctl

2 participants