Skip to content

Commit 181ec2f

Browse files
davidanthoffclaude
andcommitted
Follow the outer side of two-input nodes through an abstract type
get_source and _collect_nodes! needed a method per node type that combines two sources, because those carry `outer`/`inner` rather than `source`. With outer joins, seven set operators and zip arriving, that is eleven more pairs of near-identical methods. Introduce QueryableBinary instead, and subtype QueryableJoin and QueryableGroupJoin under it. The tree walk now has one method covering every two-input node, and a new one only has to pick the right supertype. QueryableBinary <: Queryable and the concrete types are unchanged, so `node isa QueryableJoin` and anything dispatching on Queryable still behave exactly as before. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent f79f16f commit 181ec2f

4 files changed

Lines changed: 16 additions & 14 deletions

File tree

src/query_tree.jl

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
"""
22
get_source(q::Queryable)
33
4-
Follow the `.source` (or `.outer`) chain to the root `QueryableSource`.
4+
Follow the `.source` (or, for two-input nodes, `.outer`) chain to the root
5+
`QueryableSource`.
56
"""
67
function get_source(q::QueryableSource)
78
return q
89
end
910

10-
function get_source(q::QueryableJoin)
11-
return get_source(q.outer)
12-
end
13-
14-
function get_source(q::QueryableGroupJoin)
11+
function get_source(q::QueryableBinary)
1512
return get_source(q.outer)
1613
end
1714

@@ -34,12 +31,7 @@ function _collect_nodes!(nodes, q::QueryableSource)
3431
push!(nodes, q)
3532
end
3633

37-
function _collect_nodes!(nodes, q::QueryableJoin)
38-
push!(nodes, q)
39-
_collect_nodes!(nodes, q.outer)
40-
end
41-
42-
function _collect_nodes!(nodes, q::QueryableGroupJoin)
34+
function _collect_nodes!(nodes, q::QueryableBinary)
4335
push!(nodes, q)
4436
_collect_nodes!(nodes, q.outer)
4537
end

src/queryable/queryable.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
abstract type Queryable end
22

3+
"""
4+
QueryableBinary <: Queryable
5+
6+
Nodes that combine two sources — joins, set operations, `zip`. They carry
7+
`outer` and `inner` fields, and the tree walk follows `outer`, so the query
8+
plan reads as a chain hanging off the primary input with the secondary input
9+
attached at the node.
10+
"""
11+
abstract type QueryableBinary <: Queryable end
12+
313
QueryOperators.query(x::Queryable) = x
414

515
IteratorInterfaceExtensions.isiterable(x::Queryable) = true

src/queryable/queryable_groupjoin.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
struct QueryableGroupJoin <: Queryable
1+
struct QueryableGroupJoin <: QueryableBinary
22
outer
33
inner
44
outerKeySelector_func

src/queryable/queryable_join.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
struct QueryableJoin <: Queryable
1+
struct QueryableJoin <: QueryableBinary
22
outer
33
inner
44
outerKeySelector_func

0 commit comments

Comments
 (0)