Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove superfluous checks in partialize_agg #6327

Merged
merged 1 commit into from
Nov 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading