mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-17 19:13:16 +08:00
This patch allows using custom origin's in CAGGs, for instance: time_bucket_ng('7 days', day, '2000-01-03' :: date) AS bucket For weekly buckets this allows the user to choose what should be considered the beginning of the week - Sunday or Monday. Also by shifting the origin one second forward or backward user can tweak the inclusiveness of the buckets. This works for date's, timestamp's and timestamptz's. The bucket size is considered variable-sized in all these cases. CAGGs on top of distributed hypertables, compressed hypertables and compressed distributed hypertables are supported as well. Additionally, this patch does several small refactorings. Firstly, it makes sure that experimental features of CAGGs will be tested in both Debug and Release builds. This was previously overlooked. Secondly, it renames the tests so that a person who is working on experimental features in CAGGs will be able to easily execute all the related tests: `TESTS='exp_cagg_*' make installcheck` Last but not least the patch refactors is_valid_bucketing_function() and renames it to function_allowed_in_cagg_definition(). The reason to do it in this patch is that otherwise, the logic of the function gets rather confusing which complicates code review. fix
53 lines
1.3 KiB
C
53 lines
1.3 KiB
C
/*
|
|
* This file and its contents are licensed under the Apache License 2.0.
|
|
* Please see the included NOTICE for copyright information and
|
|
* LICENSE-APACHE for a copy of the license.
|
|
*/
|
|
#ifndef TIMESCALEDB_FUNC_CACHE_H
|
|
#define TIMESCALEDB_FUNC_CACHE_H
|
|
|
|
#include <postgres.h>
|
|
#include <nodes/primnodes.h>
|
|
|
|
#include "export.h"
|
|
|
|
#define FUNC_CACHE_MAX_FUNC_ARGS 10
|
|
|
|
typedef Expr *(*sort_transform_func)(FuncExpr *func);
|
|
typedef double (*group_estimate_func)(PlannerInfo *root, FuncExpr *expr, double path_rows);
|
|
|
|
/* Describes the function origin */
|
|
typedef enum
|
|
{
|
|
/*
|
|
* Function is provided by PostgreSQL.
|
|
*/
|
|
ORIGIN_POSTGRES = 0,
|
|
/*
|
|
* Function is provided by TimescaleDB.
|
|
*/
|
|
ORIGIN_TIMESCALE = 1,
|
|
/*
|
|
* Fuction is provided by TimescaleDB and is experimental.
|
|
* It should be looked for in the experimental schema.
|
|
*/
|
|
ORIGIN_TIMESCALE_EXPERIMENTAL = 2,
|
|
} FuncOrigin;
|
|
|
|
typedef struct FuncInfo
|
|
{
|
|
const char *funcname;
|
|
FuncOrigin origin;
|
|
bool is_bucketing_func;
|
|
bool allowed_in_cagg_definition;
|
|
int nargs;
|
|
Oid arg_types[FUNC_CACHE_MAX_FUNC_ARGS];
|
|
group_estimate_func group_estimate;
|
|
sort_transform_func sort_transform;
|
|
} FuncInfo;
|
|
|
|
extern TSDLLEXPORT FuncInfo *ts_func_cache_get(Oid funcid);
|
|
extern TSDLLEXPORT FuncInfo *ts_func_cache_get_bucketing_func(Oid funcid);
|
|
|
|
#endif /* TIMESCALEDB_FUNC_CACHE_H */
|