Skip to content

Commit c83dd99

Browse files
committed
IntAutoDefineNode -> PaddingNode
1 parent a27cd78 commit c83dd99

File tree

3 files changed

+43
-43
lines changed

3 files changed

+43
-43
lines changed

src/link.jl

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,6 @@ function dismantle(n::GroupNode, ctx)
121121
Group(over = over′, by = by′, name = n.name, label_map = n.label_map)
122122
end
123123

124-
function dismantle(n::IntAutoDefineNode, ctx)
125-
over′ = dismantle(n.over, ctx)
126-
IntAutoDefine(over = over′)
127-
end
128-
129124
function dismantle(n::IterateNode, ctx)
130125
over′ = dismantle(n.over, ctx)
131126
iterator′ = dismantle(n.iterator, ctx)
@@ -157,6 +152,11 @@ function dismantle(n::OrderNode, ctx)
157152
Order(over = over′, by = by′)
158153
end
159154

155+
function dismantle(n::PaddingNode, ctx)
156+
over′ = dismantle(n.over, ctx)
157+
Padding(over = over′)
158+
end
159+
160160
function dismantle(n::PartitionNode, ctx)
161161
over′ = dismantle(n.over, ctx)
162162
by′ = dismantle_scalar(n.by, ctx)
@@ -308,19 +308,12 @@ function link(n::GroupNode, ctx)
308308
end
309309
over = n.over
310310
if !isempty(n.by)
311-
over = IntAutoDefine(over = over)
311+
over = Padding(over = over)
312312
end
313313
over′ = Linked(refs, 0, over = link(over, ctx, refs))
314314
Group(over = over′, by = n.by, name = n.name, label_map = n.label_map)
315315
end
316316

317-
function link(n::IntAutoDefineNode, ctx)
318-
refs = SQLNode[]
319-
gather!(ctx.refs, ctx, refs)
320-
over′ = Linked(refs, 0, over = link(n.over, ctx, refs))
321-
IntAutoDefine(over = over′)
322-
end
323-
324317
function link(n::IterateNode, ctx)
325318
iterator′ = n.iterator
326319
defs = copy(ctx.defs)
@@ -349,7 +342,7 @@ function link(n::IterateNode, ctx)
349342
iterator′ = Linked(refs, over = iterator′)
350343
over′ = Linked(refs, over = link(n.over, ctx, refs))
351344
n′ = Linked(refs, over = Iterate(over = over′, iterator = iterator′))
352-
IntAutoDefine(over = n′)
345+
Padding(over = n′)
353346
end
354347

355348
function route(r::JoinRouter, ref::SQLNode)
@@ -412,6 +405,13 @@ function link(n::OrderNode, ctx)
412405
Order(over = over′, by = n.by)
413406
end
414407

408+
function link(n::PaddingNode, ctx)
409+
refs = SQLNode[]
410+
gather!(ctx.refs, ctx, refs)
411+
over′ = Linked(refs, 0, over = link(n.over, ctx, refs))
412+
Padding(over = over′)
413+
end
414+
415415
function link(n::PartitionNode, ctx)
416416
refs = SQLNode[]
417417
imm_refs = SQLNode[]

src/nodes/internal.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -263,19 +263,19 @@ function PrettyPrinting.quoteof(n::IntJoinNode, ctx::QuoteContext)
263263
ex
264264
end
265265

266-
# Calculates the keys of a Group node.
267-
mutable struct IntAutoDefineNode <: TabularNode
266+
# Calculates the keys of a Group node. Also used by Iterate.
267+
mutable struct PaddingNode <: TabularNode
268268
over::Union{SQLNode, Nothing}
269269

270-
IntAutoDefineNode(; over = nothing) =
270+
PaddingNode(; over = nothing) =
271271
new(over)
272272
end
273273

274-
IntAutoDefine(args...; kws...) =
275-
IntAutoDefineNode(args...; kws...) |> SQLNode
274+
Padding(args...; kws...) =
275+
PaddingNode(args...; kws...) |> SQLNode
276276

277-
function PrettyPrinting.quoteof(n::IntAutoDefineNode, ctx::QuoteContext)
278-
ex = Expr(:call, nameof(IntAutoDefine))
277+
function PrettyPrinting.quoteof(n::PaddingNode, ctx::QuoteContext)
278+
ex = Expr(:call, nameof(Padding))
279279
if n.over !== nothing
280280
ex = Expr(:call, :|>, quoteof(n.over, ctx), ex)
281281
end

src/translate.jl

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -635,28 +635,6 @@ function assemble(n::GroupNode, ctx)
635635
return Assemblage(base.name, c, cols = cols, repl = repl)
636636
end
637637

638-
function assemble(n::IntAutoDefineNode, ctx)
639-
base = assemble(n.over, ctx)
640-
if isempty(ctx.refs)
641-
return base
642-
end
643-
if !@dissect(base.clause, SELECT() || UNION())
644-
base_alias = nothing
645-
c = base.clause
646-
else
647-
base_alias = allocate_alias(ctx, base)
648-
c = FROM(AS(over = complete(base), name = base_alias))
649-
end
650-
subs = make_subs(base, base_alias)
651-
repl = Dict{SQLNode, Symbol}()
652-
trns = Pair{SQLNode, SQLClause}[]
653-
for ref in ctx.refs
654-
push!(trns, ref => translate(ref, ctx, subs))
655-
end
656-
repl, cols = make_repl_cols(trns)
657-
Assemblage(base.name, c, cols = cols, repl = repl)
658-
end
659-
660638
function assemble(n::IntJoinNode, ctx)
661639
left = assemble(n.over, ctx)
662640
if @dissect(left.clause, tail := FROM() || JOIN())
@@ -834,6 +812,28 @@ function assemble(n::OrderNode, ctx)
834812
Assemblage(base.name, c, cols = cols, repl = repl)
835813
end
836814

815+
function assemble(n::PaddingNode, ctx)
816+
base = assemble(n.over, ctx)
817+
if isempty(ctx.refs)
818+
return base
819+
end
820+
if !@dissect(base.clause, SELECT() || UNION())
821+
base_alias = nothing
822+
c = base.clause
823+
else
824+
base_alias = allocate_alias(ctx, base)
825+
c = FROM(AS(over = complete(base), name = base_alias))
826+
end
827+
subs = make_subs(base, base_alias)
828+
repl = Dict{SQLNode, Symbol}()
829+
trns = Pair{SQLNode, SQLClause}[]
830+
for ref in ctx.refs
831+
push!(trns, ref => translate(ref, ctx, subs))
832+
end
833+
repl, cols = make_repl_cols(trns)
834+
Assemblage(base.name, c, cols = cols, repl = repl)
835+
end
836+
837837
function assemble(n::PartitionNode, ctx)
838838
base = assemble(n.over, ctx)
839839
if @dissect(base.clause, tail := nothing || FROM() || JOIN() || WHERE() || GROUP() || HAVING())

0 commit comments

Comments
 (0)