Skip to content

Commit

Permalink
basic setup to automate
Browse files Browse the repository at this point in the history
  • Loading branch information
Jayko001 committed Apr 12, 2024
1 parent 2fd035f commit bd0535f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
3 changes: 3 additions & 0 deletions sql/prometheus_fdw--0.1.4--0.1.5.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CREATE FUNCTION create_table()
RETURNS VOID AS 'MODULE_PATHNAME', 'create_table'
LANGUAGE C STRICT;
32 changes: 32 additions & 0 deletions src/init.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use pgrx::prelude::*;
use pgrx::spi::Spi;
use std::error::Error;

#[pg_extern]
fn create_table() -> Result<(), Box<dyn Error>> {
let queries = r#"
CREATE TABLE IF NOT EXISTS metric_labels (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
labels jsonb NOT NULL
);
CREATE TABLE IF NOT EXISTS metric_values (
label_id INTEGER REFERENCES metric_labels (id),
time TIMESTAMP NOT NULL,
value DOUBLE PRECISION NOT NULL
) PARTITION BY RANGE (time);
"#;

Spi::run(queries);

Ok(())
}

fn index_tables() {
// Implement indexing logic
}

fn create_partitions(){
// Implement partitioning logic
}
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
mod init;

use pgrx::warning;
use pgrx::{pg_sys, prelude::*, JsonB};
use reqwest::{self, Client};
Expand Down

0 comments on commit bd0535f

Please sign in to comment.