Vectorize the comparison operators for Date type

This uses our normal arithmetic vectorized operators.
This commit is contained in:
Alexander Kuzmenkov 2023-10-31 20:07:31 +01:00
parent a094f175eb
commit bc5e39d67a
4 changed files with 76 additions and 0 deletions

View File

@ -84,3 +84,11 @@
#define PG_PREDICATE(X) F_FLOAT4##X #define PG_PREDICATE(X) F_FLOAT4##X
#include "pred_vector_const_arithmetic_type_pair.c" #include "pred_vector_const_arithmetic_type_pair.c"
/* date functions. */
#define VECTOR_CTYPE DateADT
#define CONST_CTYPE DateADT
#define CONST_CONVERSION(X) DatumGetDateADT(X)
#define PG_PREDICATE(X) F_DATE_##X
#include "pred_vector_const_arithmetic_type_pair.c"

View File

@ -10,6 +10,7 @@
#include <postgres.h> #include <postgres.h>
#include <utils/date.h>
#include <utils/fmgroids.h> #include <utils/fmgroids.h>
#include "compat/compat.h" #include "compat/compat.h"

View File

@ -217,3 +217,54 @@ set timescaledb.debug_require_vector_qual to 'only';
select count(*) from vectorqual where metric4 is null; select count(*) from vectorqual where metric4 is null;
ERROR: debug: encountered non-vector quals when they are disabled ERROR: debug: encountered non-vector quals when they are disabled
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- Date columns
create table date_table(ts date);
select create_hypertable('date_table', 'ts');
NOTICE: adding not-null constraint to column "ts"
create_hypertable
-------------------------
(3,public,date_table,t)
(1 row)
alter table date_table set (timescaledb.compress);
insert into date_table values ('2021-01-01'), ('2021-01-02'),
('2021-01-03');
select count(compress_chunk(x, true)) from show_chunks('date_table') x;
count
-------
1
(1 row)
set timescaledb.debug_require_vector_qual to 'only';
select * from date_table where ts > '2021-01-02';
ts
------------
01-03-2021
(1 row)
select * from date_table where ts >= '2021-01-02';
ts
------------
01-03-2021
01-02-2021
(2 rows)
select * from date_table where ts = '2021-01-02';
ts
------------
01-02-2021
(1 row)
select * from date_table where ts <= '2021-01-02';
ts
------------
01-02-2021
01-01-2021
(2 rows)
select * from date_table where ts < '2021-01-02';
ts
------------
01-01-2021
(1 row)

View File

@ -87,3 +87,19 @@ select count(*) from vectorqual where metric4 > 4;
set timescaledb.debug_require_vector_qual to 'only'; set timescaledb.debug_require_vector_qual to 'only';
select count(*) from vectorqual where metric4 is null; select count(*) from vectorqual where metric4 is null;
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- Date columns
create table date_table(ts date);
select create_hypertable('date_table', 'ts');
alter table date_table set (timescaledb.compress);
insert into date_table values ('2021-01-01'), ('2021-01-02'),
('2021-01-03');
select count(compress_chunk(x, true)) from show_chunks('date_table') x;
set timescaledb.debug_require_vector_qual to 'only';
select * from date_table where ts > '2021-01-02';
select * from date_table where ts >= '2021-01-02';
select * from date_table where ts = '2021-01-02';
select * from date_table where ts <= '2021-01-02';
select * from date_table where ts < '2021-01-02';