Skip to content

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

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 <[email protected]>
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

1 participant