Skip to content

Commit b5af135

Browse files
authored
Merge pull request #204 from GameAnalytics/having
Add support for `is_null` filter
2 parents bdd96c5 + 3bf1cbb commit b5af135

File tree

4 files changed

+39
-0
lines changed

4 files changed

+39
-0
lines changed

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,18 @@ updates:
66
interval: daily
77
time: "04:00"
88
open-pull-requests-limit: 10
9+
groups:
10+
mix-minor-updates:
11+
patterns:
12+
- "*"
13+
update-types:
14+
- "minor"
15+
- "patch"
916
- package-ecosystem: "github-actions"
1017
directory: "/"
1118
schedule:
1219
interval: monthly
20+
groups:
21+
gh-actions:
22+
patterns:
23+
- "*"

CODEOWNERS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @GameAnalytics/ga-backend

lib/panoramix/query.ex

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,10 @@ defmodule Panoramix.Query do
718718
end
719719
end
720720

721+
defp build_filter({:is_null, _, [column]}) do
722+
{:%{}, [], [type: "null", column: column]}
723+
end
724+
721725
defp build_filter({:expression, _, [expression]}) do
722726
# A math expression, as described in http://druid.io/docs/0.12.1/misc/math-expr
723727
# We're expecting a string that we're passing on to Druid

test/panoramix_test.exs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,4 +1540,27 @@ defmodule PanoramixTest do
15401540
%{"expression" => "foo + 2", "name" => "plus_two", "outputType" => "double", "type" => "expression"}]} =
15411541
query2 |> Panoramix.Query.to_json() |> Jason.decode!()
15421542
end
1543+
1544+
test "builds a query with is_null filter" do
1545+
query =
1546+
from "table",
1547+
query_type: "groupBy",
1548+
filter: is_null(:foo) and not is_null(:bar)
1549+
1550+
assert query.filter
1551+
1552+
json = Panoramix.Query.to_json(query)
1553+
1554+
assert %{
1555+
"queryType" => "groupBy",
1556+
"context" => %{"priority" => 0, "timeout" => 120_000},
1557+
"filter" => %{
1558+
"type" => "and",
1559+
"fields" => [
1560+
%{"type" => "null", "column" => "foo"},
1561+
%{"type" => "not", "field" => %{"type" => "null", "column" => "bar"}}
1562+
]
1563+
}
1564+
} = Jason.decode!(json)
1565+
end
15431566
end

0 commit comments

Comments
 (0)