Skip to content

Commit

Permalink
[Rel v0.2] Migrate Julia SKD tests (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
gkastrinis authored Sep 3, 2024
1 parent a886be8 commit 6c477a7
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion examples/hello.rel
Original file line number Diff line number Diff line change
@@ -1 +1 @@
def R = "hello", "world"
def R {("hello", "world")}
2 changes: 1 addition & 1 deletion examples/show-problems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function run(database, engine; profile)
conf = load_config(; profile = profile)
ctx = Context(conf)
# TODO: rewrite via async + get_transaction_problems
rsp = exec_v1(ctx, database, engine, "def output = **nonsense**")
rsp = exec_v1(ctx, database, engine, "def output { **nonsense** }")
show_problems(rsp)
end

Expand Down
11 changes: 6 additions & 5 deletions examples/show-result.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ using RAI: Context, HTTPError, exec, load_config, show_result
include("parseargs.jl")

const source = """
def output =
:drink, "martini", 2, 12.50, "2020-01-01";
:drink, "sazerac", 4, 14.25, "2020-02-02";
:drink, "cosmopolitan", 4, 11.00, "2020-03-03";
:drink, "bellini", 3, 12.25, "2020-04-04"
def output {
(:drink, "martini", 2, 12.50, "2020-01-01");
(:drink, "sazerac", 4, 14.25, "2020-02-02");
(:drink, "cosmopolitan", 4, 11.00, "2020-03-03");
(:drink, "bellini", 3, 12.25, "2020-04-04")
}
"""

function run(database, engine; profile)
Expand Down
18 changes: 9 additions & 9 deletions test/integration.jl
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ with_engine(CTX) do engine_name
@testset "exec" begin
# Test the synchronous path. We expect a response that contains `metadata`,
# `problems`, `results` and the `transaction` information.
query_string = "x, x^2, x^3, x^4 from x in {1; 2; 3; 4; 5}"
query_string = "def output(x, x2, x3, x4): {1; 2; 3; 4; 5}(x) and x2 = x^2 and x3 = x^3 and x4 = x^4"
resp = exec(CTX, database_name, engine_name, query_string)

@info "transaction id: $(resp.transaction[:id])"
Expand Down Expand Up @@ -207,7 +207,7 @@ with_engine(CTX) do engine_name
end

@testset "exec_async" begin
query_string = "x, x^2, x^3, x^4 from x in {1; 2; 3; 4; 5}"
query_string = "def output(x, x2, x3, x4): {1; 2; 3; 4; 5}(x) and x2 = x^2 and x3 = x^3 and x4 = x^4"
resp = exec_async(CTX, database_name, engine_name, query_string)
@info "transaction id: $(resp.transaction[:id])"
resp = wait_until_done(CTX, resp)
Expand Down Expand Up @@ -271,7 +271,7 @@ with_engine(CTX) do engine_name
@test resp.transaction[:state] == "COMPLETED"

results = Dict(
exec(CTX, database_name, engine_name, "def output = $csv_relation").results,
exec(CTX, database_name, engine_name, "def output { $(csv_relation) }").results,
)

# `v2` contains the `String` columm, `v1` contains the FilePos column.
Expand All @@ -296,15 +296,15 @@ with_engine(CTX) do engine_name
return String(take!(io))
end
@testset "empty arrow file" begin
query_string = "def output = true"
query_string = "def output { true }"
resp = exec(CTX, database_name, engine_name, query_string)
@info "transaction id: $(resp.transaction[:id])"
@test show_result_str(resp) === """[:output]
()
"""
end
@testset "multiple physical relations" begin
query_string = ":a, 1; :b, 2,3; :b, 4,5"
query_string = "def output {(:a, 1); (:b, 2,3); (:b, 4,5)}"
resp = exec(CTX, database_name, engine_name, query_string)
@info "transaction id: $(resp.transaction[:id])"
@test show_result_str(resp) === """[:output, :a, Int64]
Expand All @@ -325,7 +325,7 @@ with_engine(CTX) do engine_name
models = list_models(CTX, database_name, engine_name)
@test length(models) > 0

models = Dict("test_model" => "def foo = :bar")
models = Dict("test_model" => "def foo { :bar }")
resp = load_models(CTX, database_name, engine_name, models)
@info "transaction id: $(resp.transaction[:id])"
@test resp.transaction.state == "COMPLETED"
Expand All @@ -345,7 +345,7 @@ with_engine(CTX) do engine_name
@test !("test_model" in models)

# test escape special rel character
models = Dict("percent" => "def foo = \"98%\"")
models = Dict("percent" => "def foo { \"98%\" }")
resp = load_models(CTX, database_name, engine_name, models)
@info "transaction id: $(resp.transaction[:id])"
@test resp.transaction.state == "COMPLETED"
Expand All @@ -354,7 +354,7 @@ with_engine(CTX) do engine_name
@test resp.transaction.state == "COMPLETED"
@test length(resp.problems) == 0

models = Dict("percent" => "def foo = \"98\\%\"")
models = Dict("percent" => "def foo { \"98\\%\" }")
resp = load_models(CTX, database_name, engine_name, models)
@info "transaction id: $(resp.transaction[:id])"
@test resp.transaction.state == "COMPLETED"
Expand All @@ -374,7 +374,7 @@ with_engine(CTX) do engine_name
@test !("percent" in models)

# test escape """
models = Dict("triple_quoted" => "def foo = \"\"\"98\\%\"\"\" ")
models = Dict("triple_quoted" => "def foo { \"\"\"98\\%\"\"\" }")
resp = load_models(CTX, database_name, engine_name, models)
@info "transaction id: $(resp.transaction[:id])"
@test resp.transaction.state == "COMPLETED"
Expand Down
7 changes: 4 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ end
@test occursin(r"^rai-sdk-julia/\d+\.\d+\.\d+$", RAI._user_agent())
end

# def output =
# 1, "foo", 3.4, :foo;
# 2, "bar", 5.6, :foo
# def output {
# (1, "foo", 3.4, :foo);
# (2, "bar", 5.6, :foo)
# }
const body = """{
"output": [{
"rel_key": {
Expand Down

0 comments on commit 6c477a7

Please sign in to comment.