Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
sbroad
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
core
sbroad
Commits
0b2195aa
Verified
Commit
0b2195aa
authored
11 months ago
by
Denis Smirnov
Browse files
Options
Downloads
Patches
Plain Diff
test: add cte test
parent
434969a9
No related branches found
No related tags found
2 merge requests
!427
Re-implementation: backend syntax tree for local SQL
,
!421
support CTE
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sbroad-cartridge/test_app/test/integration/cte_test.lua
+30
-0
30 additions, 0 deletions
sbroad-cartridge/test_app/test/integration/cte_test.lua
with
30 additions
and
0 deletions
sbroad-cartridge/test_app/test/integration/cte_test.lua
+
30
−
0
View file @
0b2195aa
...
...
@@ -129,5 +129,35 @@ g.test_cte = function ()
t
.
assert_equals
(
err
,
nil
)
t
.
assert_items_equals
(
r
[
"metadata"
],
{
{
name
=
"CTE.B"
,
type
=
"number"
}
})
t
.
assert_items_equals
(
r
[
"rows"
],
{
{
5
},
{
4
}
})
-- randomly distributed cte, used multiple times
r
,
err
=
api
:
call
(
"sbroad.execute"
,
{
[[
WITH cte (b) AS (SELECT "a" FROM "t" WHERE "id" > 3)
SELECT t.c FROM (SELECT count(*) as c FROM cte c1 JOIN cte c2 ON true) t
JOIN cte ON true
]]
,
})
t
.
assert_equals
(
err
,
nil
)
t
.
assert_items_equals
(
r
[
"metadata"
],
{
{
name
=
"T.C"
,
type
=
"integer"
}
})
t
.
assert_items_equals
(
r
[
"rows"
],
{
{
4
},
{
4
}
})
-- cte with segment distributed, used multiple times
r
,
err
=
api
:
call
(
"sbroad.execute"
,
{
[[
WITH cte (b) AS (SELECT "id" FROM "t" WHERE "id" = 1)
SELECT t.c FROM (SELECT count(*) as c FROM cte c1 JOIN cte c2 ON true) t
JOIN cte ON true
]]
,
})
t
.
assert_equals
(
err
,
nil
)
t
.
assert_items_equals
(
r
[
"metadata"
],
{
{
name
=
"T.C"
,
type
=
"integer"
}
})
t
.
assert_items_equals
(
r
[
"rows"
],
{
{
1
}
})
-- globally distributed cte, used multiple times
r
,
err
=
api
:
call
(
"sbroad.execute"
,
{
[[
WITH cte (b) AS (VALUES (1))
SELECT t.c FROM (SELECT count(*) as c FROM cte c1 JOIN cte c2 ON true) t
JOIN cte ON true
]]
,
})
t
.
assert_equals
(
err
,
nil
)
t
.
assert_items_equals
(
r
[
"metadata"
],
{
{
name
=
"T.C"
,
type
=
"integer"
}
})
t
.
assert_items_equals
(
r
[
"rows"
],
{
{
1
}
})
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment