Skip to content

duckdb: enable csr_rel_ traversal and fix join push-down naming - #67

Merged
adsharma merged 2 commits into
mainfrom
duckdb-csr-rel-traversal
Aug 28, 2026
Merged

duckdb: enable csr_rel_ traversal and fix join push-down naming#67
adsharma merged 2 commits into
mainfrom
duckdb-csr-rel-traversal

Conversation

@adsharma

Copy link
Copy Markdown
Contributor

Supersedes #31 (closed, not reopenable).

Enables MATCH traversal over csr_rel_* foreign rel tables:

  • DuckDBScanBindData now carries real typed columns (VariableExpressions) plus optional src/dst scan column positions. For csr_rel_* tables (internalIDContract=true) the positions are recorded so ForeignRelTable::scanInternal can wrap foreign-key values directly as node offsets (internalID_t{offset=fkValue, tableID}) — the csr_rel_ prefix promises offset-compatible FKs. rel_* tables keep the fail-fast contract.
  • Fixes a move-out bug where columnTypes was moved into DuckDBTableScanInfo before the bind-data columns were built (cause of the result-converter segfault).
  • Stores the attached-database name (not the schema-qualified catalog name) in shadow node entries and rel group entries, and sets rel group storage to "<db>.<table>", matching pg_client: ForeignJoinPushDownOptimizer uses these for its same-database check and SQL construction, enabling MATCH traversal push-down to a single duckdb SQL join.
  • ForeignJoinPushDownOptimizer (main repo): normalizes rel foreignDatabaseName to the db(TYPE) node-name format so the same-database check passes for both DDL-created and extension-registered name shapes.
  • resolveTableStorage (main repo): falls through to main-path resolution for non-LBUG attached DBs instead of throwing.
  • Build fix: sqlite/postgres attach paths pass the attached dbName to the new DuckDBCatalog constructor parameter.

Test: csr_rel_user_blocks_user traversal returns 2 rows via SQL push-down; rel_/csr_rel_ LOAD FROM and node-count cases unchanged.

Depends on LadybugDB/ladybug#844 (ForeignRelTable::scanInternal contract + optimizer fixes).

- DuckDBScanBindData carries real typed columns plus optional src/dst
  scan column positions; csr_rel_* tables (internalIDContract=true)
  record them so ForeignRelTable::scanInternal can wrap FK values as
  node offsets. rel_* tables keep the fail-fast contract.
- Fix the move-out bug where columnTypes was moved into
  DuckDBTableScanInfo before the bind-data columns were built.
- Store the attached-database name (not the schema-qualified catalog
  name) in shadow node entries and rel group entries, and set rel group
  storage to "<db>.<table>", matching pg_client: the
  ForeignJoinPushDownOptimizer uses these for its same-database check
  and SQL construction, enabling MATCH traversal push-down to duckdb.
- sqlite/postgres: pass the attached dbName to DuckDBCatalog (fixes
  build after the constructor change).
- Test: csr_rel_user_blocks_user traversal returns 2 rows via SQL
  push-down.
…talog attach

- Reorder DuckDBCatalog member declarations/init list to match (fixes
  -Wreorder-ctor).
- unity_catalog attach path was missed by the new attachedDbName ctor
  parameter; pass it so unity_catalog builds again.
@adsharma
adsharma merged commit bbd6077 into main Aug 28, 2026
2 checks passed
@adsharma
adsharma deleted the duckdb-csr-rel-traversal branch August 28, 2026 04:33
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.

1 participant