Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
radeusgd committed Mar 8, 2023
1 parent 133cfa1 commit c2bd473
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ type Column
this column contains an empty string or `Nothing`.
is_empty : Column
is_empty self =
new_name = Naming_Helpers.to_expression_text self + " is null"
new_name = Naming_Helpers.to_expression_text self + " is empty"
run_vectorized_unary_op self "is_empty" Filter_Condition.Is_Empty.to_predicate new_name on_missing=True

## Returns a column of booleans, with `True` items at the positions where
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ spec setup =
s1.ends_with "a" . to_vector . should_equal [False, False, False, False, Nothing]
s1.ends_with "b" Case_Sensitivity.Insensitive . to_vector . should_equal [False, False, False, True, Nothing]

Test.group "Colum Operations - Names" <|
Test.group prefix+"Colum Operations - Names" <|
t = table_builder [["a", [1, 2, 3]], ["b", ['x', 'y', 'z']], ["c", [1.0, 2.0, 3.0]], ["d", [True, False, True]]]
Test.specify "arithmetic" <|
((t.at "a") + 42) . name . should_equal "[a] + 42"
Expand Down
16 changes: 8 additions & 8 deletions test/Table_Tests/src/Database/Codegen_Spec.enso
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,21 @@ spec =
arith = (d * 2) + 1
logic = (f || f.not) && True
cmp = (d * d >= e) && (d - e < d)
arith.to_sql.prepare . should_equal ['SELECT (("T2"."D" * ?) + ?) AS "D" FROM "T2" AS "T2"', [[2, int], [1, int]]]
logic.to_sql.prepare . should_equal ['SELECT (("T2"."F" OR (NOT "T2"."F")) AND ?) AS "F" FROM "T2" AS "T2"', [[True, bool]]]
cmp.to_sql.prepare . should_equal ['SELECT ((("T2"."D" * "T2"."D") >= "T2"."E") AND (("T2"."D" - "T2"."E") < "T2"."D")) AS "D" FROM "T2" AS "T2"', []]
arith.to_sql.prepare . should_equal ['SELECT (("T2"."D" * ?) + ?) AS "'+arith.name+'" FROM "T2" AS "T2"', [[2, int], [1, int]]]
logic.to_sql.prepare . should_equal ['SELECT (("T2"."F" OR (NOT "T2"."F")) AND ?) AS "'+logic.name+'" FROM "T2" AS "T2"', [[True, bool]]]
cmp.to_sql.prepare . should_equal ['SELECT ((("T2"."D" * "T2"."D") >= "T2"."E") AND (("T2"."D" - "T2"."E") < "T2"."D")) AS "'+cmp.name+'" FROM "T2" AS "T2"', []]

Test.specify "should support simple text operations" <|
b = t1.at "B"
add = b + "SUFFIX"
add.to_sql.prepare . should_equal ['SELECT ("T1"."B" || ?) AS "B" FROM "T1" AS "T1"', [["SUFFIX", str]]]
add.to_sql.prepare . should_equal ['SELECT ("T1"."B" || ?) AS "[B] + \'SUFFIX\'" FROM "T1" AS "T1"', [["SUFFIX", str]]]

ends = b.ends_with "suf"
starts = b.starts_with "pref"
contains = b.contains "inf"
ends.to_sql.prepare . should_equal ['SELECT ("T1"."B" GLOB (\'*\' || ?)) AS "B" FROM "T1" AS "T1"', [["suf", str]]]
starts.to_sql.prepare . should_equal ['SELECT ("T1"."B" GLOB (? || \'*\')) AS "B" FROM "T1" AS "T1"', [["pref", str]]]
contains.to_sql.prepare . should_equal ['SELECT instr("T1"."B", ?) > 0 AS "B" FROM "T1" AS "T1"', [["inf", str]]]
ends.to_sql.prepare . should_equal ['SELECT ("T1"."B" GLOB (\'*\' || ?)) AS "'+ends.name+'" FROM "T1" AS "T1"', [["suf", str]]]
starts.to_sql.prepare . should_equal ['SELECT ("T1"."B" GLOB (? || \'*\')) AS "'+starts.name+'" FROM "T1" AS "T1"', [["pref", str]]]
contains.to_sql.prepare . should_equal ['SELECT instr("T1"."B", ?) > 0 AS "'+contains.name+'" FROM "T1" AS "T1"', [["inf", str]]]

Test.group "[Codegen] Masking Tables and Columns" <|
Test.specify "should generate a single BETWEEN expression" <|
Expand Down Expand Up @@ -113,7 +113,7 @@ spec =
Test.group "[Codegen] Handling Missing Values" <|
Test.specify "fill_missing should allow to replace missing values in a column with a constant" <|
c = t1.at "A" . fill_missing "not-applicable"
c.to_sql.prepare . should_equal ['SELECT COALESCE("T1"."A", ?) AS "A" FROM "T1" AS "T1"', [["not-applicable", int]]]
c.to_sql.prepare . should_equal ['SELECT COALESCE("T1"."A", ?) AS "fill_missing([A], \'not-applicable\')" FROM "T1" AS "T1"', [["not-applicable", int]]]

Test.specify "filter_blank_rows should drop rows that contain at least one missing column in a Table" <|
t2 = t1.filter_blank_rows when_any=True
Expand Down

0 comments on commit c2bd473

Please sign in to comment.