Skip to content

Commit

Permalink
Further work
Browse files Browse the repository at this point in the history
  • Loading branch information
jnidzwetzki committed May 3, 2023
1 parent 874813c commit 3f7e9c4
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/planner/expand_hypertable.c
Original file line number Diff line number Diff line change
Expand Up @@ -1417,7 +1417,8 @@ ts_plan_expand_hypertable_chunks(Hypertable *ht, PlannerInfo *root, RelOptInfo *
* partitionwise aggregation. */

if ((ts_guc_enable_partitionwise_aggregation &&
!has_partialize_function((Node *) root->parse->targetList, TS_DO_NOT_FIX_AGGSPLIT) && num_chunks > 0) ||
!has_partialize_function((Node *) root->parse->targetList, TS_DO_NOT_FIX_AGGSPLIT) &&
num_chunks > 0) ||
hypertable_is_distributed(ht))
{
enable_partitionwise_aggregate = true; // FIXME
Expand Down
7 changes: 0 additions & 7 deletions src/planner/planner.c
Original file line number Diff line number Diff line change
Expand Up @@ -1512,11 +1512,6 @@ replace_hypertable_modify_paths(PlannerInfo *root, List *pathlist, RelOptInfo *i
return new_pathlist;
}

static void
create_vector_paths(PlannerInfo *root, List *pathlist)
{
}

static void
timescaledb_create_upper_paths_hook(PlannerInfo *root, UpperRelationKind stage,
RelOptInfo *input_rel, RelOptInfo *output_rel, void *extra)
Expand Down Expand Up @@ -1568,8 +1563,6 @@ timescaledb_create_upper_paths_hook(PlannerInfo *root, UpperRelationKind stage,

if (parse->hasAggs)
ts_preprocess_first_last_aggregates(root, root->processed_tlist);

create_vector_paths(root, output_rel->pathlist);
}
}

Expand Down
1 change: 1 addition & 0 deletions tsl/src/nodes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set(SOURCES
target_sources(${TSL_LIBRARY_NAME} PRIVATE ${SOURCES})
add_subdirectory(compress_dml)
add_subdirectory(decompress_chunk)
add_subdirectory(decompress_chunk_vector)
add_subdirectory(frozen_chunk_dml)
add_subdirectory(gapfill)
add_subdirectory(skip_scan)
1 change: 0 additions & 1 deletion tsl/src/nodes/decompress_chunk/decompress_chunk.c
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,6 @@ ts_decompress_chunk_generate_paths(PlannerInfo *root, RelOptInfo *chunk_rel, Hyp
continue;
}


// make make_partition_pruneinfo() happy
root->append_rel_array[info->compressed_rel->relid] =
root->append_rel_array[info->chunk_rel->relid];
Expand Down
3 changes: 3 additions & 0 deletions tsl/src/nodes/decompress_chunk_vector/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Add all *.c to sources in upperlevel directory
set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/decompress_chunk_vector.c)
target_sources(${TSL_LIBRARY_NAME} PRIVATE ${SOURCES})
59 changes: 59 additions & 0 deletions tsl/src/nodes/decompress_chunk_vector/decompress_chunk_vector.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* This file and its contents are licensed under the Timescale License.
* Please see the included NOTICE for copyright information and
* LICENSE-TIMESCALE for a copy of the license.
*/

#include <postgres.h>
#include <catalog/pg_operator.h>
#include <miscadmin.h>
#include <nodes/bitmapset.h>
#include <nodes/makefuncs.h>
#include <nodes/nodeFuncs.h>
#include <optimizer/cost.h>
#include <optimizer/optimizer.h>
#include <optimizer/pathnode.h>
#include <optimizer/paths.h>
#include <parser/parsetree.h>
#include <utils/builtins.h>
#include <utils/lsyscache.h>
#include <utils/typcache.h>

#include <planner.h>

#include "compat/compat.h"
#include "debug_assert.h"
#include "ts_catalog/hypertable_compression.h"
#include "import/planner.h"
#include "compression/create.h"
#include "nodes/decompress_chunk/decompress_chunk.h"
#include "nodes/decompress_chunk/planner.h"
#include "nodes/decompress_chunk/qual_pushdown.h"
#include "nodes/decompress_chunk_vector/decompress_chunk_vector.h"
#include "utils.h"

void
ts_decompress_vector_modify_paths(PlannerInfo *root, RelOptInfo *input_rel, RelOptInfo *output_rel)
{
Assert(root != NULL);
Assert(input_rel != NULL);
Assert(output_rel != NULL);
Assert(output_rel->reloptkind == RELOPT_UPPER_REL);

ListCell *lc;
foreach (lc, output_rel->pathlist)
{
/* We are only interested in AggPaths */
if (!IsA(lfirst(lc), AggPath))
continue;

AggPath *aggregation_path = lfirst_node(AggPath, lc);

/* We are only interested in splitted paths */
if (aggregation_path->aggsplit != AGGSPLIT_FINAL_DESERIAL)
continue;

Path *aggregation_sub_path = aggregation_path->subpath;
Assert(aggregation_sub_path);
}
}
19 changes: 19 additions & 0 deletions tsl/src/nodes/decompress_chunk_vector/decompress_chunk_vector.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* This file and its contents are licensed under the Timescale License.
* Please see the included NOTICE for copyright information and
* LICENSE-TIMESCALE for a copy of the license.
*/
#ifndef TIMESCALEDB_DECOMPRESS_CHUNK_VECTOR_H
#define TIMESCALEDB_DECOMPRESS_CHUNK_VECTOR_H

#include <postgres.h>
#include <nodes/bitmapset.h>
#include <nodes/extensible.h>

#include "chunk.h"
#include "hypertable.h"

extern void ts_decompress_vector_modify_paths(PlannerInfo *root, RelOptInfo *input_rel,
RelOptInfo *output_rel);

#endif
5 changes: 5 additions & 0 deletions tsl/src/planner.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "nodes/compress_dml/compress_dml.h"
#include "nodes/frozen_chunk_dml/frozen_chunk_dml.h"
#include "nodes/decompress_chunk/decompress_chunk.h"
#include "nodes/decompress_chunk_vector/decompress_chunk_vector.h"
#include "nodes/data_node_dispatch.h"
#include "nodes/data_node_copy.h"
#include "nodes/gapfill/gapfill.h"
Expand Down Expand Up @@ -91,6 +92,10 @@ tsl_create_upper_paths_hook(PlannerInfo *root, UpperRelationKind stage, RelOptIn
case UPPERREL_GROUP_AGG:
if (input_reltype != TS_REL_HYPERTABLE_CHILD)
plan_add_gapfill(root, output_rel);

if (output_rel != NULL)
ts_decompress_vector_modify_paths(root, input_rel, output_rel);

break;
case UPPERREL_WINDOW:
if (IsA(linitial(input_rel->pathlist), CustomPath))
Expand Down

0 comments on commit 3f7e9c4

Please sign in to comment.