From 6c477a792a543e4cc8b96440f6f806e25e15baea Mon Sep 17 00:00:00 2001 From: George Kastrinis Date: Tue, 3 Sep 2024 10:15:28 +0300 Subject: [PATCH] [Rel v0.2] Migrate Julia SKD tests (#127) --- examples/hello.rel | 2 +- examples/show-problems.jl | 2 +- examples/show-result.jl | 11 ++++++----- test/integration.jl | 18 +++++++++--------- test/runtests.jl | 7 ++++--- 5 files changed, 21 insertions(+), 19 deletions(-) diff --git a/examples/hello.rel b/examples/hello.rel index f1dc799..569f2d1 100644 --- a/examples/hello.rel +++ b/examples/hello.rel @@ -1 +1 @@ -def R = "hello", "world" \ No newline at end of file +def R {("hello", "world")} diff --git a/examples/show-problems.jl b/examples/show-problems.jl index 2e5c96c..cf49592 100644 --- a/examples/show-problems.jl +++ b/examples/show-problems.jl @@ -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 diff --git a/examples/show-result.jl b/examples/show-result.jl index 12dfbe3..181a7e0 100644 --- a/examples/show-result.jl +++ b/examples/show-result.jl @@ -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) diff --git a/test/integration.jl b/test/integration.jl index 82d7758..a5abd1e 100644 --- a/test/integration.jl +++ b/test/integration.jl @@ -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])" @@ -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) @@ -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. @@ -296,7 +296,7 @@ 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] @@ -304,7 +304,7 @@ with_engine(CTX) do engine_name """ 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] @@ -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" @@ -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" @@ -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" @@ -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" diff --git a/test/runtests.jl b/test/runtests.jl index 49c2762..81d12ab 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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": {