Skip to content

Commit

Permalink
Handle no rows
Browse files Browse the repository at this point in the history
Handle no key
  • Loading branch information
jdunkerley committed Mar 1, 2022
1 parent d984520 commit bf9bae8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,11 @@ type Aggregate_Column
Standard_Deviation c _ _ -> create_closure c col->a->i->
v = col.at i
(c + if v.is_nothing then a else [a.first + 1, a.second + v, (a.at 2) + v*v])
Concatenate c _ j _ _ _ -> create_closure c col->text->i->
val=if (col.at i).is_nothing then "" else (col.at i).to_text
Concatenate c _ j _ _ q -> create_closure c col->text->i->
val=if (col.at i).is_nothing then "" else
text = (col.at i).to_text
if text == "" then (q+q) else
if text.contains j then (q+text+q) else text
if i==0 then val else (text + j + val)
Median c _ -> create_closure c col->map->i->
val = col.at i
Expand Down
7 changes: 4 additions & 3 deletions distribution/lib/Standard/Table/0.0.0-dev/src/Data/Table.enso
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ type Table
key_columns = if selector.is_nothing then [] else
Table_Helpers.select_columns internal_columns=this.columns selector=selector reorder=True on_problems=on_problems warnings=warnings
key_length = key_columns.length
make_key i = Group_By_Key <| key_columns.map v->(v.at i)
make_key = if (key_length == 0) then _->(Group_By_Key [1]) else i->(Group_By_Key (key_columns.map v->(v.at i)))

# New Table Accumulator
new_table = (key_columns.map c->c.name)+(columns.map c->(c.column_name this)) . map n->[n, Vector.new_builder]
Expand All @@ -537,7 +537,7 @@ type Table
key = make_key i
row_index = map.get_or_else key (add_row key)

# Accumulate...
# Accumulate
0.up_to (columns.length) . each j->
aggregator = aggregators.at j
array = new_table.at (j + key_length) . at 1 . to_array
Expand All @@ -546,7 +546,8 @@ type Table
array . set_at row_index new

map.insert key row_index
0.up_to this.row_count . fold Map.empty aggregate
if ((key_length == 0) && (this.row_count == 0)) then (add_row []) else
0.up_to this.row_count . fold Map.empty aggregate

# Now Finalise and make a table
finalise builder index =
Expand Down

0 comments on commit bf9bae8

Please sign in to comment.