Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UDF Diff. #2

Open
wants to merge 482 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
482 commits
Select commit Hold shift + click to select a range
8576cc6
working on recursive not segfaulting
tanujnay112 Jul 10, 2020
7b0f964
checkpoint
tanujnay112 Jul 11, 2020
f5083d2
where on ctescan works
tanujnay112 Jul 12, 2020
9994c85
where on ctescan works
tanujnay112 Jul 12, 2020
1304e2e
gotta do frontline parser now
tanujnay112 Jul 12, 2020
8846687
libpgquery parses iterative
tanujnay112 Jul 12, 2020
c84144d
iterative done??
tanujnay112 Jul 12, 2020
89759f5
wrote sqltable::copy
tanujnay112 Jul 15, 2020
83280e6
reverted accumulate for now
tanujnay112 Jul 15, 2020
b2d833c
fixed copy table signature
tanujnay112 Jul 16, 2020
c363ca5
reverted index_util fix
tanujnay112 Jul 16, 2020
9a4d932
made and added ctetype enum
tanujnay112 Jul 16, 2020
0198e94
weird assertion failure
tanujnay112 Jul 17, 2020
d43a0fd
i legitimately hate this code but ok
tanujnay112 Jul 17, 2020
66ddc45
change to for loop header
tanujnay112 Jul 17, 2020
40fb1c5
Accumulate doesn't work just yet
soumilm Jul 17, 2020
0e1dca5
WITH RECURSIVE works now yay
soumilm Jul 17, 2020
637e847
Iterative and Recursive Queries work now!
soumilm Jul 18, 2020
c4bb9de
fixed copy table
tanujnay112 Jul 17, 2020
b82f594
multiple ctes work
tanujnay112 Jul 18, 2020
6a385e2
merged master
tanujnay112 Jul 18, 2020
e30a138
cleaned up leader translator and also broke base case into separate p…
tanujnay112 Jul 19, 2020
2c17f13
fixed nested cte's
tanujnay112 Jul 21, 2020
3fe5525
Handle CTEs with no aliases
soumilm Jul 19, 2020
1d7d9e8
time to remake translators
tanujnay112 Jul 29, 2020
01ccfca
simple cte's work serially now
tanujnay112 Jul 31, 2020
581cb41
predicate works serially
tanujnay112 Jul 31, 2020
ab336d3
cte table schema actually appears in the plan nodes now
tanujnay112 Aug 1, 2020
db63942
temp oids
tanujnay112 Aug 2, 2020
9cc2c0f
ok we are back to iterate and recursive, check with m/p about some th…
tanujnay112 Aug 3, 2020
3b3f6ba
Merge branch 'with_iterative_cte' into abstractify
tanujnay112 Aug 4, 2020
901dc82
we are synched up now
tanujnay112 Aug 4, 2020
d1b292f
more stuff
tanujnay112 Aug 10, 2020
6f8e2ed
Fixed the SELECT * bug with multiple CTEs (...again)
soumilm Aug 10, 2020
48f7d4d
optimizer fix + some clang-tidy
tanujnay112 Aug 11, 2020
a229ff0
more bug fixes, removed bulk hardcoded stuff in input column deriver
tanujnay112 Aug 11, 2020
d917680
Merge pull request #6 from soumilm/iterative_tpl2
tanujnay112 Aug 11, 2020
ff7b6fa
nvm.
tanujnay112 Aug 11, 2020
4fb4533
Merge branch 'abstractify' of https://github.com/tanujnay112/terrier …
tanujnay112 Aug 11, 2020
69b5fe0
clang-tidy
tanujnay112 Aug 12, 2020
09460aa
format
tanujnay112 Aug 12, 2020
58a07d4
lint
tanujnay112 Aug 12, 2020
7daa477
plugged some more holes
tanujnay112 Aug 13, 2020
26ae658
refactored how * works a bit
tanujnay112 Aug 13, 2020
45a581d
Fixed table_name.* type queries
soumilm Aug 13, 2020
81814a5
Fix SELECT * bugs for nested CTEs
soumilm Aug 13, 2020
e365977
Fixed another minor bug
soumilm Aug 14, 2020
f4408c9
Merge pull request #7 from soumilm/iterative_tpl2
tanujnay112 Aug 14, 2020
ce51bb8
added a todo
tanujnay112 Aug 14, 2020
33c8a33
Merge branch 'abstractify' of https://github.com/tanujnay112/terrier …
tanujnay112 Aug 14, 2020
b886182
updated...
tanujnay112 Aug 14, 2020
bf25e75
added trace files
tanujnay112 Aug 14, 2020
7a49e23
broke down trace files
tanujnay112 Aug 14, 2020
93cbad6
SELECT * queries now correctly populate a table
soumilm Aug 15, 2020
17ab8cf
Fixed binder issues for cross products
soumilm Aug 15, 2020
2d5503b
CTEs with aliases should work now
soumilm Aug 18, 2020
a6422a8
duplicate alias refactor, time to clean up..?
tanujnay112 Aug 19, 2020
569fe1f
some cleanup
tanujnay112 Aug 19, 2020
11540f4
Fixed binder issues for cross products
soumilm Aug 15, 2020
7018fbd
CTEs with aliases should work now
tanujnay112 Aug 19, 2020
d33a6b6
progress on self join
tanujnay112 Aug 19, 2020
c14baef
self joins work
tanujnay112 Aug 19, 2020
b4d392a
fixed WITH EMPLOYEE AS (SELECT NAME,SALARY,AGE FROM COMPANY) SELECT *…
tanujnay112 Aug 19, 2020
7b29a2e
strings work
tanujnay112 Aug 19, 2020
1b2f71a
whoops broke inductive cte's for a bit
tanujnay112 Aug 19, 2020
3550248
more patchups
tanujnay112 Aug 19, 2020
9ad82a2
more patchups
tanujnay112 Aug 19, 2020
f756801
tests
soumilm Aug 19, 2020
f783916
SELECT * queries now correctly populate a table
soumilm Aug 15, 2020
765b250
tests
soumilm Aug 19, 2020
4ccebae
Rebasing is hard
soumilm Aug 19, 2020
a23ea73
Synced up with abstractify for real
soumilm Aug 19, 2020
68043a5
ok things work again
tanujnay112 Aug 20, 2020
1742e86
formatted
tanujnay112 Aug 20, 2020
12c878c
some clang-tidy
tanujnay112 Aug 20, 2020
69b8ab2
imported tests from soumil
tanujnay112 Aug 20, 2020
853ab74
Merge branch 'abstractify' into iterative_tpl2
soumilm Aug 20, 2020
dc3394e
whoops it didn't compile last time
tanujnay112 Aug 20, 2020
1ac70f9
Fixed ordering of tables in SELECT * queries involving multiple tables
soumilm Aug 20, 2020
669a61f
Fixed column ordering in SELECT * queries from CTEs
soumilm Aug 21, 2020
19fc8eb
Merge branch 'abstractify' into iterative_tpl2
soumilm Aug 21, 2020
f590d3c
clang-tidy
tanujnay112 Aug 21, 2020
a5b3039
Updated CTE tests for self-joins
soumilm Aug 21, 2020
4693a5d
Merge branch 'iterative_tpl2' of github.com:soumilm/terrier into iter…
soumilm Aug 21, 2020
3972395
Merge branch 'abstractify' into iterative_tpl2
soumilm Aug 21, 2020
082843d
Merge pull request #8 from soumilm/iterative_tpl2
tanujnay112 Aug 21, 2020
610ca81
rename..?
tanujnay112 Aug 21, 2020
58ead3f
some documentation
tanujnay112 Aug 22, 2020
7c4f8ae
finished doxygen
tanujnay112 Aug 23, 2020
7aac970
unittest compiles
tanujnay112 Aug 23, 2020
dbbd8c2
test fixes
tanujnay112 Aug 23, 2020
372d222
whoops
tanujnay112 Aug 23, 2020
7a5cefc
Merge branch 'master' into abstractify
tanujnay112 Aug 24, 2020
797a856
Fixed check-lint issues
soumilm Aug 24, 2020
0c07afe
took away extraneous rewrite rule with qderived on top of tablefreescan
tanujnay112 Aug 24, 2020
a5471ca
more missing #includes
tanujnay112 Aug 24, 2020
670562c
pipeline fixes
tanujnay112 Aug 24, 2020
6d6d774
Merge branch 'master' into abstractify
tanujnay112 Aug 24, 2020
50e6941
took out unnecessary bytecodes
tanujnay112 Aug 24, 2020
0f27a72
Merge branch 'abstractify' of https://github.com/tanujnay112/terrier …
tanujnay112 Aug 24, 2020
340e72e
fixed up alias hashing
tanujnay112 Aug 25, 2020
85fc5cb
fixed bad merge in parallelism check
tanujnay112 Aug 25, 2020
e41f364
removed printing
tanujnay112 Aug 25, 2020
62b2cb5
format....
tanujnay112 Aug 25, 2020
56a48d3
we converted all tests to trace files, we don't need this compiler test
tanujnay112 Aug 25, 2020
c942207
updated tpl files
tanujnay112 Aug 25, 2020
b1ca5cc
whoops my bad
tanujnay112 Aug 25, 2020
231f800
binder clangtidy
tanujnay112 Aug 25, 2020
3fc82f0
Fixed some memory leak issues
soumilm Aug 25, 2020
549de8a
Merge remote-tracking branch 'origin' into abstractify
soumilm Aug 27, 2020
80782b3
Fixed compilation issues due to strong typedef commit
soumilm Aug 27, 2020
e8c0ad8
Whoops missed a file
soumilm Aug 27, 2020
f154c36
just have to unjankify the parser now
tanujnay112 Aug 27, 2020
182506e
parser hack + codegen declared variable identifier tracking fixes
tanujnay112 Aug 29, 2020
f21333d
Merge branch 'master' into abstractify
tanujnay112 Aug 30, 2020
bf51d08
Ran make format
soumilm Aug 31, 2020
c2508c4
a few things ready to benchmark now: 1) made inserts allocate a new v…
tanujnay112 Sep 4, 2020
96f38c5
timer
tanujnay112 Sep 4, 2020
79744dd
break stmt in limit
tanujnay112 Sep 5, 2020
239a64d
uh select count(*) ... limit 1 works
tanujnay112 Sep 5, 2020
bd88bfc
llvm engine fix for passed in parameters that are addresses
tanujnay112 Sep 5, 2020
6842807
insert into select *
tanujnay112 Sep 6, 2020
1951abc
insert should be faster
tanujnay112 Sep 6, 2020
3b75358
got delete to take the fact that @inttosql returns an actual integer …
tanujnay112 Sep 6, 2020
662c6c4
Removed dead code and unecessary includes in several places; added so…
soumilm Sep 6, 2020
b2048ee
Improved comments and removed magic numbers
soumilm Sep 6, 2020
ed7b298
Killed more dead code
soumilm Sep 6, 2020
b9d61da
Addressed some PR review comments
soumilm Sep 7, 2020
e0e434f
Removed some dead code
soumilm Sep 8, 2020
1e0db48
vague type in test tpl file caused issues
tanujnay112 Sep 8, 2020
7ed2913
Modified TPL files to use testCatalogLookup
soumilm Sep 8, 2020
e134ac2
Merge branch 'master' into abstractify
tanujnay112 Sep 10, 2020
303ddca
don't print on insert
tanujnay112 Sep 12, 2020
aad6565
outputbuffer is concurrency safe but unoptimized
tanujnay112 Sep 13, 2020
459e06d
Merge branch 'master' into abstractify
tanujnay112 Sep 13, 2020
26adc69
why is parallel slower
tanujnay112 Sep 13, 2020
8600adc
#pause
tanujnay112 Sep 13, 2020
f40a92a
doxygen
tanujnay112 Sep 13, 2020
46fe683
format
tanujnay112 Sep 13, 2020
e896ef8
Merge branch 'master' into abstractify
mbutrovich Sep 17, 2020
2d6067b
checkpoint?
tanujnay112 Sep 17, 2020
068e64d
Fixed check-lint issues
soumilm Sep 22, 2020
c3adc95
Fixed clang-tidy issues
soumilm Sep 25, 2020
b0e6260
Merge branch 'master' into abstractify
soumilm Sep 25, 2020
9028b9b
checkpoint need to work on calling th efunctions now
tanujnay112 Oct 8, 2020
9af225e
fixed int size casting issues
tanujnay112 Oct 8, 2020
d67aa93
forgot to revert llvm engine debugging changes
tanujnay112 Oct 8, 2020
fcf117c
Merge branch 'master' into abstractify
tanujnay112 Oct 8, 2020
d17baac
forgot to revert llvm engine debugging changes
tanujnay112 Oct 8, 2020
dce15ff
Merge branch 'abstractify' of https://github.com/tanujnay112/terrier …
tanujnay112 Oct 8, 2020
9648ccd
Merge branch 'master' into abstractify
tanujnay112 Oct 11, 2020
36f9e6c
chk
tanujnay112 Oct 12, 2020
49d3493
compiles! now to make reference types work
tanujnay112 Oct 12, 2020
e2a5c3f
weird call.tpl bug
tanujnay112 Oct 12, 2020
9fa8c54
Merge branch 'master' into abstractify
tanujnay112 Oct 13, 2020
83627ba
need to separate lambda struct and function types
tanujnay112 Oct 15, 2020
39dd4b2
Addressed PR comments
soumilm Oct 18, 2020
b5d1b15
works in compiled mode
tanujnay112 Oct 18, 2020
7c07d83
Merge branch 'master' into abstractify
tanujnay112 Oct 18, 2020
a8ab360
trying to get this to work with extended scopes
tanujnay112 Oct 19, 2020
a698b86
added better documentation
tanujnay112 Oct 19, 2020
1e7950b
Merge branch 'master' into abstractify
tanujnay112 Oct 20, 2020
1646aec
Merge branch 'master' into abstractify
lmwnshn Oct 20, 2020
e6511c5
Merge branch 'master' into abstractify
tanujnay112 Oct 20, 2020
e525dcd
Merge branch 'master' into abstractify
tanujnay112 Oct 20, 2020
3d7fa29
gonna start making lambda parameterized type?
tanujnay112 Oct 25, 2020
e5278f7
can pass lambdas around now
tanujnay112 Oct 26, 2020
7e1b217
checkpoint, just need to fix undefined vars issues
tanujnay112 Oct 30, 2020
95f9e4b
Merge branch 'abstractify' into master
tanujnay112 Oct 30, 2020
f218c73
conflicts resolved and passes tests
tanujnay112 Nov 2, 2020
fe9747b
added patch and addressed more comments
tanujnay112 Nov 2, 2020
d3c6293
format
tanujnay112 Nov 2, 2020
a13cefe
addressed padding issues in pipeline.h
tanujnay112 Nov 2, 2020
7f961f5
Merge branch 'master' into abstractify
tanujnay112 Nov 2, 2020
13ffd29
got rid of some stray changes
tanujnay112 Nov 2, 2020
dbbb081
Merge branch 'abstractify' of https://github.com/tanujnay112/terrier …
tanujnay112 Nov 2, 2020
9e0179a
sema issues during calling
tanujnay112 Nov 2, 2020
170f991
doxygen
tanujnay112 Nov 2, 2020
f619cb5
oops
tanujnay112 Nov 2, 2020
6f5f788
cat_on_keyboard.jpeg
tanujnay112 Nov 2, 2020
0e71b48
checkpoint
tanujnay112 Nov 2, 2020
22e9820
reorded fields in pipeline.h to remove padding
tanujnay112 Nov 2, 2020
3e85895
Merge branch 'master' into abstractify
tanujnay112 Nov 2, 2020
45e0e1b
clang-tidy
tanujnay112 Nov 3, 2020
f1ef40a
Merge branch 'abstractify' of https://github.com/tanujnay112/terrier …
tanujnay112 Nov 3, 2020
6ea1f91
compilation fix..
tanujnay112 Nov 3, 2020
96069c7
compilation fix..
tanujnay112 Nov 3, 2020
e2e1702
checkpoint, structs get cloned properly
tanujnay112 Nov 3, 2020
9f7f373
parser_test fix
tanujnay112 Nov 3, 2020
cd24d54
Merge branch 'master' into abstractify
tanujnay112 Nov 3, 2020
4306336
changed temp oid macro to templatized function
tanujnay112 Nov 4, 2020
286b724
Merge branch 'abstractify' of https://github.com/tanujnay112/terrier …
tanujnay112 Nov 4, 2020
4b74cf2
sorted nested table columns
tanujnay112 Nov 4, 2020
87940aa
ok this is it i swear
tanujnay112 Nov 4, 2020
a256450
sql statements work (gotta work on parallelizable queries/compound tu…
tanujnay112 Nov 4, 2020
4d30902
formatted
tanujnay112 Nov 4, 2020
1b2336e
checkpoint
tanujnay112 Nov 5, 2020
1375bf6
parser+binder for laterals
tanujnay112 Nov 7, 2020
af6de72
checkpoint
tanujnay112 Nov 8, 2020
4d2e2fe
fixed unnecessary parser addition
tanujnay112 Nov 8, 2020
b093b28
this is much better, gotta remove the lateral_contexts_ stuff
tanujnay112 Nov 8, 2020
fc373de
simple aliased laterals work now
tanujnay112 Nov 9, 2020
453828a
brought back binding for recursive
tanujnay112 Nov 9, 2020
c5e79d2
about to write union all
tanujnay112 Nov 10, 2020
b72ebd0
select 1,2 union all 3,4 works
tanujnay112 Nov 11, 2020
e8bba4c
cte's work ahain i think
tanujnay112 Nov 11, 2020
eb2ecb4
select 1 union all select 2 union all select 3 works
tanujnay112 Nov 12, 2020
f2fd5bc
debugging cte...
tanujnay112 Nov 12, 2020
f5774ba
cte's work again
tanujnay112 Nov 12, 2020
8f7dc0a
joins where you only select columns from one side work (added impleme…
tanujnay112 Nov 14, 2020
f249b09
gonna try splitting pipelines
tanujnay112 Nov 14, 2020
72e3305
got pve's to work in udf sql stmts
tanujnay112 Nov 15, 2020
fa115b8
Merge remote-tracking branch 'tanuj/laterals' into tpl_lambdas
tanujnay112 Nov 15, 2020
436540b
currently merging into noisepage laterals
tanujnay112 Nov 15, 2020
b07a9cd
pve's in UDF sql stmts work again lffgggggggg
tanujnay112 Nov 16, 2020
8ea141e
compiled lateral
tanujnay112 Nov 22, 2020
66aef21
checkpoint
tanujnay112 Nov 23, 2020
f0d3f26
compilation works
tanujnay112 Nov 23, 2020
f8f9272
checkpoint?
tanujnay112 Nov 24, 2020
f8a4763
checkpoint, everything compiles
tanujnay112 Nov 24, 2020
782842e
this is much better, gotta remove the lateral_contexts_ stuff
tanujnay112 Nov 26, 2020
eedaf89
nested for loops work
tanujnay112 Nov 27, 2020
4b9b6bc
ready to test, made adjustments to tvi initialization
tanujnay112 Dec 5, 2020
281fe5c
benchmark 2?
tanujnay112 Dec 13, 2020
0414577
typo
tanujnay112 Dec 13, 2020
1fee380
benchmark 2 UDF file
tanujnay112 Dec 13, 2020
1ab4a68
adjustment
tanujnay112 Dec 13, 2020
493abc8
removing some prints
tanujnay112 Dec 13, 2020
504235b
removing some prints
tanujnay112 Dec 13, 2020
b767a7c
added inlining capabilities
tanujnay112 Dec 15, 2020
0cd77a3
reverted initial udfbenchmark
tanujnay112 Dec 15, 2020
e760184
another adjustment to benchmark
tanujnay112 Dec 15, 2020
258253d
these.. are.. the breaks
tanujnay112 Dec 15, 2020
426f357
no network
tanujnay112 Dec 15, 2020
758ae4b
savepoint
tanujnay112 Dec 17, 2020
5190ef0
things pass around by ref now in bcgen
tanujnay112 Dec 19, 2020
fcc49d9
prepping for margin bench
tanujnay112 Dec 19, 2020
0a56db8
setting up for another L2 round
tanujnay112 Dec 21, 2020
15586c9
turning off packet writing
tanujnay112 Dec 21, 2020
754f11b
lowered printing
tanujnay112 Dec 21, 2020
6f94cdc
limits work now, llvm errors on lambda captures gone
tanujnay112 Dec 22, 2020
118271d
gotta fix limits and redobuffers now on temp tables
tanujnay112 Dec 22, 2020
268e3dc
markov.tpl works fully, just gotta work on limit stuff now
tanujnay112 Dec 23, 2020
d4bf4b6
no printing
tanujnay112 Dec 24, 2020
cdda32a
record type
tanujnay112 Dec 27, 2020
654b391
cursor loop hacky fix for not including exec ctx in captures
tanujnay112 Jan 5, 2021
f91049c
looks like udf params are kinda busted, need to have the query own th…
tanujnay112 Jan 6, 2021
e6ec602
updated benchmark
tanujnay112 Jan 6, 2021
e666c40
final
tanujnay112 Feb 10, 2021
4873ad2
Merge branch 'laterals' into master
tanujnay112 Feb 10, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion benchmark/benchmark_util/benchmark_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.
//
// Modified from the Apache Arrow project for the Terrier project.
// Modified from the Apache Arrow project for the Noisepage project.

#include "benchmark/benchmark.h"
#include "benchmark_util/benchmark_config.h"
Expand Down
421 changes: 421 additions & 0 deletions sample_tpl/L2Norm.tpl

Large diffs are not rendered by default.

48 changes: 22 additions & 26 deletions sample_tpl/agg.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ struct State {
count: int32
}

struct OutputStruct {
out0: Integer
}

struct Agg {
key: Integer
count: CountStarAggregate
Expand Down Expand Up @@ -35,51 +39,43 @@ fun updateAgg(agg: *Agg, vpi: *VectorProjectionIterator) -> nil {
@aggAdvance(&agg.count, &input)
}

fun pipeline_1(execCtx: *ExecutionContext, state: *State) -> nil {
fun pipeline_1(execCtx: *ExecutionContext, state: *State, lam : lambda [(Integer)->nil] ) -> nil {
var ht = &state.table
var tvi: TableVectorIterator
var table_oid = @testCatalogLookup(execCtx, "test_1", "")
var col_oids: [2]uint32
col_oids[0] = @testCatalogLookup(execCtx, "test_1", "colA")
col_oids[1] = @testCatalogLookup(execCtx, "test_1", "colB")
col_oids[0] = @testCatalogLookup(execCtx, "test_1", "cola")
col_oids[1] = @testCatalogLookup(execCtx, "test_1", "colb")
for (@tableIterInit(&tvi, execCtx, table_oid, col_oids); @tableIterAdvance(&tvi); ) {
var vec = @tableIterGetVPI(&tvi)
for (; @vpiHasNext(vec); @vpiAdvance(vec)) {
var hash_val = @hash(@vpiGetInt(vec, 1))
var agg = @ptrCast(*Agg, @aggHTLookup(ht, hash_val, keyCheck, vec))
if (agg == nil) {
agg = @ptrCast(*Agg, @aggHTInsert(ht, hash_val))
constructAgg(agg, vec)
} else {
updateAgg(agg, vec)
}
var output_row: OutputStruct
output_row.out0 = @vpiGetIntNull(vec, 0)
lam(output_row.out0)
}
}
@tableIterClose(&tvi)
}

fun pipeline_2(state: *State) -> nil {
var aht_iter: AHTIterator
var iter = &aht_iter
for (@aggHTIterInit(iter, &state.table); @aggHTIterHasNext(iter); @aggHTIterNext(iter)) {
var agg = @ptrCast(*Agg, @aggHTIterGetRow(iter))
state.count = state.count + 1
}
@aggHTIterClose(iter)
}

fun execQuery(execCtx: *ExecutionContext, qs: *State) -> nil {
pipeline_1(execCtx, qs)
pipeline_2(qs)
fun execQuery(execCtx: *ExecutionContext, qs: *State, lam : lambda [(Integer)->nil] ) -> nil {
pipeline_1(execCtx, qs, lam)
}

fun main(execCtx: *ExecutionContext) -> int32 {
var count : Integer
count = @intToSql(0)
var lam = lambda [count] (x : Integer) -> nil {
count = count + 1
}
var state: State

setUpState(execCtx, &state)
execQuery(execCtx, &state)
execQuery(execCtx, &state, lam)
tearDownState(&state)

var ret = state.count
return ret
if(count > 0) {
return 1
}
return 0
}
43 changes: 39 additions & 4 deletions sample_tpl/call.tpl
Original file line number Diff line number Diff line change
@@ -1,8 +1,43 @@
// Expected output: 70

fun f(x: int) -> int { return x * 7 }
fun f(z : Date ) -> Date { return z }

fun main() -> int {
var x = 10
return f(x)
fun main(exec : *ExecutionContext) -> int32 {
var y = 11
var lam = lambda [y] (z: Integer ) -> nil {
y = y + z
}
lam(10)


var d = @dateToSql(1999, 2, 11)
//f(lam, d)
var k : Date
//var h = &k
//*h = d
//k = f(d)
lam(d)
if(@datePart(y, @intToSql(21)) == @intToSql(1999)){
// good
return 1
}
return 0
}

fun pipeline1(QueryState *q) {
TableIterator tvi;
for(@tableIteratorAdvance(&tvi)){
@hashTableInsert(q.join_ht, @getTupleValue(&tvi, 3)))
}
}

fun pipeline2(QueryState *q) {
TableIterator tvi;
for(@tableIteratorAdvance(&tvi)){
var o_custkey = @getTupleValue(&tvi, 1)
if(@hashTableKeyExists(q.join_ht, o_custkey)){
var out = @outputBufferAlloc(q.output_buff)
out.col1 = o_custkey + 1
}
}
}
58 changes: 58 additions & 0 deletions sample_tpl/cte_scan_temp_table_insert.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Expected output: 11 (number of output rows)
// SQL: INSERT INTO temp_table SELECT colA FROM test_1 WHERE colA BETWEEN 495 AND 505; SELECT * FROM temp_table;

fun main(execCtx: *ExecutionContext) -> int32 {
var TEMP_OID_MASK: uint64 = 2147483648 // 2^31

// Init inserter
var col_types: [1]uint32
col_types[0] = 4 // colA
var temp_col_oids: [1]uint32
temp_col_oids[0] = TEMP_OID_MASK | 1 // colA
var cte_scan_iterator: CteScanIterator
@cteScanInit(&cte_scan_iterator, execCtx, TEMP_OID_MASK, temp_col_oids, col_types)

var col_oids: [1]uint32
col_oids[0] = @testCatalogLookup(execCtx, "test_1", "colA")

// Iterate through rows with colA between 495 and 505
// Init index iterator
var index : IndexIterator
var index_oid : int32
var test_oid : int32
test_oid = @testCatalogLookup(execCtx, "test_1", "")
index_oid = @testCatalogIndexLookup(execCtx, "index_1")
@indexIteratorInit(&index, execCtx, 1, test_oid, index_oid, col_oids)
// Set iteration bounds
var lo_index_pr = @indexIteratorGetLoPR(&index)
var hi_index_pr = @indexIteratorGetHiPR(&index)
@prSetInt(lo_index_pr, 0, @intToSql(495)) // Set colA in lo
@prSetInt(hi_index_pr, 0, @intToSql(505)) // Set colA in hi
for (@indexIteratorScanAscending(&index, 0, 0); @indexIteratorAdvance(&index);) {
// Materialize the current match.
var table_pr = @indexIteratorGetTablePR(&index)
var colA = @prGetInt(table_pr, 0)
var slot = @indexIteratorGetSlot(&index)

// Insert into temp table
var insert_temp_table_pr = @cteScanGetInsertTempTablePR(&cte_scan_iterator)
@prSetInt(insert_temp_table_pr, 0, colA)
var insert_temp_table_slot = @cteScanTableInsert(&cte_scan_iterator)
}
@indexIteratorFree(&index)

var ret = 0
var tvi: TableVectorIterator
@tableIterInit(&tvi, execCtx, TEMP_OID_MASK, temp_col_oids)
for (@tableIterAdvance(&tvi)) {
var vpi = @tableIterGetVPI(&tvi)
for (; @vpiHasNext(vpi); @vpiAdvance(vpi)) {
var cola = @vpiGetInt(vpi, 0)
ret = ret + 1
}
@vpiReset(vpi)
}
@tableIterClose(&tvi)
@cteScanFree(&cte_scan_iterator)
return ret
}
65 changes: 65 additions & 0 deletions sample_tpl/ind_cte_scan_temp_table_insert.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Expected output: 20 (number of output rows)
// Perform the following
// INSERT INTO temp_table SELECT colA FROM test_1 WHERE colA BETWEEN 1 AND 20;
// Call temp_table Accumulate()

fun main(exec_ctx: *ExecutionContext) -> int32 {
// Initialize CTE Scan Iterator
var TEMP_OID_MASK: uint64 = 2147483648 // 2^31
var col_types: [1]uint32
col_types[0] = 4

var temp_col_oids: [1]uint32
temp_col_oids[0] = TEMP_OID_MASK | 1 // colA

var cte_scan: IndCteScanIterator
@indCteScanInit(&cte_scan, exec_ctx, TEMP_OID_MASK, temp_col_oids, col_types, false)

var col_oids: [1]uint32
col_oids[0] = @testCatalogLookup(exec_ctx, "test_1", "colA")

// Iterate from 1 -> 20
var index_iter : IndexIterator
var index_oid : int32
var test_oid : int32
test_oid = @testCatalogLookup(exec_ctx, "test_1", "")
index_oid = @testCatalogIndexLookup(exec_ctx, "index_1")
@indexIteratorInit(&index_iter, exec_ctx, 1, test_oid, index_oid, col_oids)
var lo_pr = @indexIteratorGetLoPR(&index_iter)
var hi_pr = @indexIteratorGetHiPR(&index_iter)
@prSetInt(lo_pr, 0, @intToSql(1))
@prSetInt(hi_pr, 0, @intToSql(20))

// Insert values 1, 2, ... 20 into temp table
for (@indexIteratorScanAscending(&index_iter, 0, 0); @indexIteratorAdvance(&index_iter); ) {
// Get entry
var cur_pr = @indexIteratorGetTablePR(&index_iter)
var cur_val = @prGetInt(cur_pr, 0)
var slot = @indexIteratorGetSlot(&index_iter)

// Insert entry
var insert_pr = @indCteScanGetInsertTempTablePR(&cte_scan)
@prSetInt(insert_pr, 0, cur_val)
var insert_temp_table_slot = @indCteScanTableInsert(&cte_scan)
}
var acc_bool = @indCteScanAccumulate(&cte_scan)
// Test accumulate on empty WriteTable
acc_bool = @indCteScanAccumulate(&cte_scan)
@indexIteratorFree(&index_iter)
var cte = @indCteScanGetReadCte(&cte_scan)

var ret = 0
var tvi: TableVectorIterator
@tableIterInit(&tvi, exec_ctx, TEMP_OID_MASK, temp_col_oids)
for (@tableIterAdvance(&tvi)) {
var vpi = @tableIterGetVPI(&tvi)
for (; @vpiHasNext(vpi); @vpiAdvance(vpi)) {
var cola = @vpiGetInt(vpi, 0)
ret = ret + 1
}
@vpiReset(vpi)
}
@tableIterClose(&tvi)
@indCteScanFree(&cte_scan)
return ret
}
Loading