Skip to content

Commit

Permalink
Remove superfluous checks in partialize_agg
Browse files Browse the repository at this point in the history
Remove checks that will always return true in current implementation
to make refactoring easier. Aggref->args will always be list of
TargetEntry, and the bulk_decompression check will always return true
as well.
  • Loading branch information
svenklemm committed Nov 19, 2023
1 parent a3aec8c commit e48ea74
Showing 1 changed file with 0 additions and 49 deletions.
49 changes: 0 additions & 49 deletions tsl/src/partialize_agg.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,55 +75,6 @@ is_vectorizable_agg_path(PlannerInfo *root, AggPath *agg_path, Path *path)
if (aggref->aggfnoid != F_SUM_INT4)
return false;

/*
* Check that the input columns of the aggregate can be processed by our vectorized
* implementation. This is possible for (1) segment_by columns and (2) for columns which allow
* bulk decompression.
*
* Bulk decompression is needed to produce the ArrowArray and perform the vectorized operations.
* Bulk decompression should always be possible in the current implementation since we check for
* the data type above. However, when we lift the restriction, the check becomes necessary.
*
* Note: decompress_path->bulk_decompression_column is not populated at this point. So, we have
* to get this data from hypertable_compression_info.
*/
ListCell *lc;
foreach (lc, aggref->args)
{
Node *agg_arg = lfirst(lc);

if (!IsA(agg_arg, TargetEntry))
return false;

TargetEntry *target_entry = castNode(TargetEntry, agg_arg);

if (!IsA(target_entry->expr, Var))
continue;

Var *var = castNode(Var, target_entry->expr);

/* Agg input var is on the compressed relation */
Assert((Index) var->varno == path->parent->relid);
Assert((Index) var->varno == decompress_path->info->chunk_rel->relid);

char *column_name =
get_attname(decompress_path->info->chunk_rte->relid, var->varattno, false);

FormData_hypertable_compression *ci =
get_column_compressioninfo(decompress_path->info->hypertable_compression_info,
column_name);
Assert(ci);

/* If this is a segment_by value, allow vectorization for sum */
if (ci->segmentby_column_index > 0)
continue;

bool bulk_decompression_possible = (tsl_get_decompress_all_function(ci->algo_id) != NULL);

if (!bulk_decompression_possible)
return false;
}

return true;
}

Expand Down

0 comments on commit e48ea74

Please sign in to comment.