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 21, 2023
1 parent c6202df commit 03ef1ab
Showing 1 changed file with 2 additions and 49 deletions.
51 changes: 2 additions & 49 deletions tsl/src/partialize_agg.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,14 @@ is_vectorizable_agg_path(PlannerInfo *root, AggPath *agg_path, Path *path)
if (!is_decompress_chunk)
return false;

#ifdef USE_ASSERT_CHECKING
DecompressChunkPath *decompress_path = (DecompressChunkPath *) path;
Assert(decompress_path->custom_path.custom_paths != NIL);

/* Hypertable compression info is already fetched from the catalog */
Assert(decompress_path->info != NULL);
Assert(decompress_path->info->hypertable_compression_info != NULL);
#endif

/* No filters on the compressed attributes are supported at the moment */
if ((list_length(path->parent->baserestrictinfo) > 0 || path->parent->joininfo != NULL))
Expand All @@ -75,55 +77,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 03ef1ab

Please sign in to comment.