Skip to content

Commit

Permalink
Fix counter
Browse files Browse the repository at this point in the history
  • Loading branch information
sanromeo committed Jan 3, 2024
1 parent 156c903 commit 5eb3621
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,24 @@
{# Process each partition row #}
{%- for row in rows -%}
{%- set single_partition = [] -%}
{# Initialize a manual counter for the index #}
{%- set counter = 0 -%}
{# Use Namespace to hold the counter for loop index #}
{%- set counter = namespace(value=0) -%}
{# Loop through each column in the row #}
{%- for col, partition_key in zip(row, partitioned_by) -%}
{# Process bucketed columns using the new macro with the index #}
{%- do process_bucket_column(col, partition_key, table, ns, counter) -%}
{%- do process_bucket_column(col, partition_key, table, ns, counter.value) -%}

{# Logic for non-bucketed columns #}
{%- set bucket_match = modules.re.search('bucket\((.+),.+([0-9]+)\)', partition_key) -%}
{%- if not bucket_match -%}
{# For non-bucketed columns, format partition key and value #}
{%- set column_type = adapter.convert_type(table, counter) -%}
{%- set column_type = adapter.convert_type(table, counter.value) -%}
{%- set value, comp_func = adapter.format_value_for_partition(col, column_type) -%}
{%- set partition_key_formatted = adapter.format_one_partition_key(partitioned_by[counter]) -%}
{%- set partition_key_formatted = adapter.format_one_partition_key(partitioned_by[counter.value]) -%}
{%- do single_partition.append(partition_key_formatted + comp_func + value) -%}
{%- endif -%}
{# Increment the counter #}
{%- set counter = counter + 1 -%}
{%- set counter.value = counter.value + 1 -%}
{%- endfor -%}

{# Concatenate conditions for a single partition #}
Expand Down

0 comments on commit 5eb3621

Please sign in to comment.