From 3f7e9c4a7e61b9662a9af57a768bfa69156b0311 Mon Sep 17 00:00:00 2001 From: Jan Nidzwetzki Date: Thu, 27 Apr 2023 15:15:25 +0200 Subject: [PATCH] Further work --- src/planner/expand_hypertable.c | 3 +- src/planner/planner.c | 7 --- tsl/src/nodes/CMakeLists.txt | 1 + .../nodes/decompress_chunk/decompress_chunk.c | 1 - .../decompress_chunk_vector/CMakeLists.txt | 3 + .../decompress_chunk_vector.c | 59 +++++++++++++++++++ .../decompress_chunk_vector.h | 19 ++++++ tsl/src/planner.c | 5 ++ 8 files changed, 89 insertions(+), 9 deletions(-) create mode 100644 tsl/src/nodes/decompress_chunk_vector/CMakeLists.txt create mode 100644 tsl/src/nodes/decompress_chunk_vector/decompress_chunk_vector.c create mode 100644 tsl/src/nodes/decompress_chunk_vector/decompress_chunk_vector.h diff --git a/src/planner/expand_hypertable.c b/src/planner/expand_hypertable.c index 89321ba6f39..0221f669028 100644 --- a/src/planner/expand_hypertable.c +++ b/src/planner/expand_hypertable.c @@ -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 diff --git a/src/planner/planner.c b/src/planner/planner.c index a8979188986..02aebe1680e 100644 --- a/src/planner/planner.c +++ b/src/planner/planner.c @@ -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) @@ -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); } } diff --git a/tsl/src/nodes/CMakeLists.txt b/tsl/src/nodes/CMakeLists.txt index 678ed001569..f3cc4ff0ba5 100644 --- a/tsl/src/nodes/CMakeLists.txt +++ b/tsl/src/nodes/CMakeLists.txt @@ -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) diff --git a/tsl/src/nodes/decompress_chunk/decompress_chunk.c b/tsl/src/nodes/decompress_chunk/decompress_chunk.c index 9c42418b541..2a5fe4f4202 100644 --- a/tsl/src/nodes/decompress_chunk/decompress_chunk.c +++ b/tsl/src/nodes/decompress_chunk/decompress_chunk.c @@ -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]; diff --git a/tsl/src/nodes/decompress_chunk_vector/CMakeLists.txt b/tsl/src/nodes/decompress_chunk_vector/CMakeLists.txt new file mode 100644 index 00000000000..fb9da9de5ea --- /dev/null +++ b/tsl/src/nodes/decompress_chunk_vector/CMakeLists.txt @@ -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}) diff --git a/tsl/src/nodes/decompress_chunk_vector/decompress_chunk_vector.c b/tsl/src/nodes/decompress_chunk_vector/decompress_chunk_vector.c new file mode 100644 index 00000000000..017d724a692 --- /dev/null +++ b/tsl/src/nodes/decompress_chunk_vector/decompress_chunk_vector.c @@ -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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#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); + } +} diff --git a/tsl/src/nodes/decompress_chunk_vector/decompress_chunk_vector.h b/tsl/src/nodes/decompress_chunk_vector/decompress_chunk_vector.h new file mode 100644 index 00000000000..e5d010e3eb6 --- /dev/null +++ b/tsl/src/nodes/decompress_chunk_vector/decompress_chunk_vector.h @@ -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 +#include +#include + +#include "chunk.h" +#include "hypertable.h" + +extern void ts_decompress_vector_modify_paths(PlannerInfo *root, RelOptInfo *input_rel, + RelOptInfo *output_rel); + +#endif \ No newline at end of file diff --git a/tsl/src/planner.c b/tsl/src/planner.c index f516b3c2a53..aaa72c6f173 100644 --- a/tsl/src/planner.c +++ b/tsl/src/planner.c @@ -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" @@ -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))