Skip to content

Add support for query() table function (issue #210)#293

Open
nicolas-geysse wants to merge 1456 commits intocwida:mainfrom
theseedship:fix/issue-210-query-table-function
Open

Add support for query() table function (issue #210)#293
nicolas-geysse wants to merge 1456 commits intocwida:mainfrom
theseedship:fix/issue-210-query-table-function

Conversation

@nicolas-geysse
Copy link

Summary

  • Enables DuckPGQ to work with DuckDB's query() table function
  • Fixes serialization issues in PathElement, SubPath, and MatchExpression
  • Removes unused state management code

Problem

The previous architecture stored MatchExpression in DuckPGQState with an integer index. When query() re-parsed the SQL, the context was different and the expression was lost:

-- This failed before the fix
FROM query('FROM GRAPH_TABLE (pg MATCH (a:Person) COLUMNS (a.id)) tmp');

Solution

Serialize MatchExpression to BLOB directly at parse time in TransformMatch, making the expression self-contained with no dependency on external state. Deserialize from BLOB in MatchBindReplace.

Changes

  • TransformMatch: serialize MatchExpression to BLOB at parse time
  • MatchBindReplace: deserialize MatchExpression from BLOB
  • Fix serialization: PathElement/SubPath now call base class and use property IDs 200+
  • Add BOUND_EXPRESSION case in ParsedExpression deserialization
  • Fix MatchExpression serialization: call base class, use IDs 200-204
  • Cleanup: remove unused transform_expression/match_index from DuckPGQState
  • Add test for query() table function

Test plan

  • All existing tests pass (126 test cases)
  • New test file test/sql/query_table_function.test passes
  • Test with basic GRAPH_TABLE in query()
  • Test with path patterns in query()

Fixes #210

🤖 Generated with Claude Code

Dtenwolde and others added 30 commits January 28, 2025 09:52
…on-weakly-connected-component

Rework WCC implementation
…when-match-used-in-subquery

Fix segmentation fault when match was used inside subquery
[still fixing some issues with aliases]
…for-get_csr_v-and-get_csr_e

Fix segmentation faults in csr v and e functions
Improve template bootstraper script
Dtenwolde and others added 29 commits July 22, 2025 10:10
This reverts commit b1edaff.
Fix issues related to v1.4.1 release
This fix enables DuckPGQ to work with DuckDB's query() table function:
```sql
FROM query('FROM GRAPH_TABLE (pg MATCH (a:Person) COLUMNS (a.id)) tmp');
```

## Problem
The previous architecture stored MatchExpression in DuckPGQState with an
integer index. When query() re-parsed the SQL, the context was different
and the expression was lost.

## Solution
Serialize MatchExpression to BLOB directly at parse time in TransformMatch,
making the expression self-contained with no dependency on external state.
Deserialize from BLOB in MatchBindReplace.

## Changes
- TransformMatch: serialize MatchExpression to BLOB at parse time
- MatchBindReplace: deserialize MatchExpression from BLOB
- Fix PathElement/SubPath serialization (call base class, use IDs 200+)
- Add BOUND_EXPRESSION case in ParsedExpression deserialization
- Fix MatchExpression serialization (call base class, use IDs 200-204)
- Remove unused transform_expression/match_index from DuckPGQState
- Add test for query() table function

Fixes cwida#210

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.

Unable to use duckpgq in DuckDB its query table function