Skip to content

Commit

Permalink
workaround for #12185 - stop using is_nothing
Browse files Browse the repository at this point in the history
  • Loading branch information
radeusgd committed Jan 29, 2025
1 parent 6d2158f commit ad09f59
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,26 +77,26 @@ _merge_input_and_tables (input_table : Table) (tables_for_rows : Vector Read_Man

multiplicated_inputs = duplicate_rows input_table counts
Runtime.assert (unified_data.row_count == multiplicated_inputs.row_count)
Runtime.assert (unified_metadata.is_nothing || (unified_metadata.row_count == unified_data.row_count))
Runtime.assert ((Nothing == unified_metadata) || (unified_metadata.row_count == unified_data.row_count))

first_pass = if unified_metadata.is_nothing then multiplicated_inputs else
first_pass = if Nothing == unified_metadata then multiplicated_inputs else
multiplicated_inputs.zip unified_metadata right_prefix=""
first_pass.zip unified_data right_prefix=""

## Unifies provided metadata tables, knowing that some tables may have no
metadata - in such case we want to insert as many Nothing rows for metadata
as there are rows in the corresponding data table.
_unify_metadata (tables : Vector Read_Many_As_Table_Result) (on_problems : Problem_Behavior) -> Table | Nothing =
has_no_metadata = tables.all r-> r.metadata.is_nothing
has_no_metadata = tables.all r-> Nothing == r.metadata
if has_no_metadata then Nothing else
unique = Column_Naming_Helper.in_memory.create_unique_name_strategy
tables.each r->
if r.metadata.is_nothing.not then unique.mark_used r.metadata.column_names
if Nothing != r.metadata then unique.mark_used r.metadata.column_names

# A dummy column because we cannot create a table with 0 columns, it will be removed after union. We find an unique name for it to avoid conflicts.
dummy_column_name = unique.make_unique "_Internal_Placeholder_Column_"
tables_for_union = tables.map r->
if r.metadata.is_nothing.not then r.metadata else
if Nothing != r.metadata then r.metadata else
Table.new [Column.from_repeated_item dummy_column_name Nothing r.data.row_count]

# Metadata are always merged by-name and columns that appear only in some tables are kept.
Expand Down

0 comments on commit ad09f59

Please sign in to comment.