Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for not in contains operations #115

Merged
merged 1 commit into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions lib/kino_explorer/data_transform_cell.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ defmodule KinoExplorer.DataTransformCell do
"time"
]
@filter_options %{
"binary" => ["equal", "contains", "not equal"],
"binary" => ["equal", "contains", "not contains", "not equal"],
"boolean" => ["equal", "not equal"],
"category" => ["equal", "contains", "not equal"],
"category" => ["equal", "contains", "not contains", "not equal"],
"date" => ["less", "less equal", "equal", "not equal", "greater equal", "greater"],
"datetime[ms]" => ["less", "less equal", "equal", "not equal", "greater equal", "greater"],
"datetime[μs]" => ["less", "less equal", "equal", "not equal", "greater equal", "greater"],
"datetime[ns]" => ["less", "less equal", "equal", "not equal", "greater equal", "greater"],
"float" => ["less", "less equal", "equal", "not equal", "greater equal", "greater"],
"integer" => ["less", "less equal", "equal", "not equal", "greater equal", "greater"],
"string" => ["equal", "contains", "not equal"],
"string" => ["equal", "contains", "not contains", "not equal"],
"time" => ["less", "less equal", "equal", "not equal", "greater equal", "greater"]
}
@fill_missing_options %{
Expand Down Expand Up @@ -96,7 +96,8 @@ defmodule KinoExplorer.DataTransformCell do
"not equal" => "!=",
"greater equal" => ">=",
"greater" => ">",
"contains" => "contains"
"contains" => "contains",
"not contains" => "not contains"
}

@multiselect_operations [:discard, :group_by]
Expand Down
29 changes: 29 additions & 0 deletions test/kino_explorer/data_transform_cell_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,35 @@ defmodule KinoExplorer.DataTransformCellTest do
"""
end

test "not contains" do
root = %{
"data_frame" => "people",
"assign_to" => "exported_df",
"data_frame_alias" => DF,
"missing_require" => nil,
"is_data_frame" => true,
"collect" => true
}

operations = [
%{
"column" => "surname",
"filter" => "not contains",
"type" => "string",
"value" => "Santiago",
"active" => true,
"operation_type" => "filters"
}
]

attrs = Map.put(root, "operations", operations)

assert DataTransformCell.to_source(attrs) == """
exported_df =
people |> DF.lazy() |> DF.filter(not contains(surname, "Santiago")) |> DF.collect()\
"""
end

test "source with an auto generated require" do
root = %{
"data_frame_alias" => DF,
Expand Down
Loading