Skip to content

Commit

Permalink
#67: Fixed LISTAGG syntax (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
redcatbear authored Feb 1, 2023
1 parent 58cc65c commit f20e5c9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
10 changes: 7 additions & 3 deletions doc/changes/changes_2.4.0.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# virtual-schema-common-lua 2.4.0, released 2023-01-??
# virtual-schema-common-lua 2.4.0, released 2023-02-01

Code name: Boolean Properties
Code name: Boolean Properties, IS JSON, LISTAGG

## Summary

Expand All @@ -16,4 +16,8 @@ The core database does not push the `OVER` clause that makes the main difference

* #19: Added `LISTAGG` aggregate function rendering
* #60: Added `IS [NOT] JSON` predicate rendering
* #63: Added support for boolean Virtual Schema properties
* #63: Added support for boolean Virtual Schema properties

## Bugfixes

* #67: Fixed `LISTAGG` overflow clause
2 changes: 1 addition & 1 deletion spec/RequestDispatcher_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ describe("RequestDispatcher", function()
assert.error_contains(call_with_illegal_request_type, "Unknown Virtual Schema request type 'illegal' received.")
end)

it("wraps caught errors to log them",function()
it("wraps caught errors to log them", function()
assert.has_error(call_with_illegal_request_type)
assert.spy(log_mock.fatal).was.called_with(
[[F-RQD-1: Unknown Virtual Schema request type 'illegal' received.
Expand Down
8 changes: 4 additions & 4 deletions spec/queryrenderer/AggregateFunctionAppender_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ describe("AggregateFunctionRenderer", function()
)

it_asserts(
[[LISTAGG("capabilities"."name") ON OVERFLOW ERROR]],
[[LISTAGG("capabilities"."name" ON OVERFLOW ERROR)]],
run_complex_function("LISTAGG",
{
arguments = {reference.column("capabilities", "name")},
Expand All @@ -192,7 +192,7 @@ describe("AggregateFunctionRenderer", function()
)

it_asserts(
[[LISTAGG("capabilities"."name") ON OVERFLOW TRUNCATE WITHOUT COUNT]],
[[LISTAGG("capabilities"."name" ON OVERFLOW TRUNCATE WITHOUT COUNT)]],
run_complex_function("LISTAGG",
{
arguments = {reference.column("capabilities", "name")},
Expand All @@ -203,7 +203,7 @@ describe("AggregateFunctionRenderer", function()
)

it_asserts(
[[LISTAGG("capabilities"."name") ON OVERFLOW TRUNCATE ', etc.' WITHOUT COUNT]],
[[LISTAGG("capabilities"."name" ON OVERFLOW TRUNCATE ', etc.' WITHOUT COUNT)]],
run_complex_function("LISTAGG",
{
arguments = {reference.column("capabilities", "name")},
Expand All @@ -217,7 +217,7 @@ describe("AggregateFunctionRenderer", function()
)

it_asserts(
[[LISTAGG("capabilities"."name") ON OVERFLOW TRUNCATE WITH COUNT]],
[[LISTAGG("capabilities"."name" ON OVERFLOW TRUNCATE WITH COUNT)]],
run_complex_function("LISTAGG",
{
arguments = {reference.column("capabilities", "name")},
Expand Down
12 changes: 6 additions & 6 deletions src/exasolvs/queryrenderer/AggregateFunctionAppender.lua
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,6 @@ function AggregateFunctionAppender:_listagg(f)
self:_append(", ")
self:_append_expression(f.separator)
end
self:_append(")")
if f.orderBy then
self:_append(" WITHIN GROUP (")
SelectAppender._append_order_by(self, f.orderBy, true)
self:_append(")")
end
local overflow = f.overflowBehavior
if overflow then
if overflow.type == "ERROR" then
Expand All @@ -158,6 +152,12 @@ function AggregateFunctionAppender:_listagg(f)
self:_append((overflow.truncationType == "WITH COUNT") and " WITH COUNT" or " WITHOUT COUNT")
end
end
self:_append(")")
if f.orderBy then
self:_append(" WITHIN GROUP (")
SelectAppender._append_order_by(self, f.orderBy, true)
self:_append(")")
end
end

AggregateFunctionAppender._max = AggregateFunctionAppender._append_distinct_function
Expand Down

0 comments on commit f20e5c9

Please sign in to comment.