Files
postgres-ts-vectors/tests/test-4-hybrid.sql
Maxime Killinger df585b765a
All checks were successful
🚀 Docker Build and Push / build-and-push (15) (push) Successful in 5m54s
🚀 Docker Build and Push / build-and-push (16) (push) Successful in 6m0s
🚀 Docker Build and Push / build-and-push (17) (push) Successful in 5m56s
🚀 Docker Build and Push / build-and-push (18) (push) Successful in 6m4s
feat: Add comprehensive test suite and cleanup step
- Split validation into 4 granular CI steps (Config, Timescale, Vector, Hybrid)
- Added cleanup step for Docker images in CI
- Created SQL test scripts in tests/ for robustness
2025-12-19 14:02:36 +01:00

41 lines
868 B
SQL

-- Test 4: Hybrid (Timescale + Vector)
\set ON_ERROR_STOP on
DROP TABLE IF EXISTS hybrid_logs;
CREATE TABLE hybrid_logs (
time TIMESTAMPTZ NOT NULL,
msg TEXT,
vec vector(2)
);
SELECT create_hypertable('hybrid_logs', 'time');
INSERT INTO hybrid_logs (time, msg, vec) VALUES
(NOW(), 'log1', '[0,0]'),
(NOW() - INTERVAL '1 day', 'old_log', '[1,1]');
-- Index
CREATE INDEX ON hybrid_logs USING vchordrq (vec vector_l2_ops);
-- Hybrid Query
DO $$
DECLARE
res_count int;
BEGIN
-- Recent logs similar to [0.1, 0.1]
SELECT count(*) INTO res_count
FROM (
SELECT * FROM hybrid_logs
WHERE time > NOW() - INTERVAL '1 hour'
ORDER BY vec <-> '[0.1, 0.1]'
LIMIT 1
) sub;
IF res_count != 1 THEN
RAISE EXCEPTION 'Hybrid query failed';
END IF;
RAISE NOTICE 'Hybrid Check: OK';
END
$$;