Skip to main content

PostgresIntrospector

Struct PostgresIntrospector 

Source
pub struct PostgresIntrospector { /* private fields */ }
Expand description

PostgreSQL introspector for fact table metadata.

Implementations§

Source§

impl PostgresIntrospector

Source

pub const fn new(pool: Pool<Manager>) -> PostgresIntrospector

Create new PostgreSQL introspector from connection pool.

Source§

impl PostgresIntrospector

Source

pub async fn get_index_definitions( &self, relation: &str, ) -> Result<Vec<IndexInfo>, FraiseQLError>

Every index on relation, keys in declared order (#1307).

Keys come from pg_get_indexdef(indexrelid, n, true) rather than from pg_attribute, because an expression key has no attnum: the JSONB identity a page is tie-broken on (data->>'id') is indexed as an expression, and reading indkey alone would report that index as having fewer keys than it has.

Returns an empty vector for a view — a view carries no indexes, so a caller holding a sql_source must resolve it with resolve_base_relations first.

§Errors

Returns FraiseQLError::Database if the catalog query fails.

Source

pub async fn resolve_base_relations( &self, view: &str, ) -> Result<Vec<String>, FraiseQLError>

The tables and materialized views a view reads from (#1307).

A query binds to v_invoice, and v_invoice has no indexes — the indexes that decide whether a page needs a sort live on tb_invoice. Resolved through pg_rewrite/pg_depend rather than by assuming a v_/tb_ naming convention, which is a project convention and not a guarantee about any particular database.

Returns every base relation the view depends on. More than one means the view is a join, and a caller cannot attribute an ordering to a single table without reading the view body.

§Errors

Returns FraiseQLError::Database if the catalog query fails.

Source

pub async fn get_view_columns( &self, view_name: &str, ) -> Result<Vec<String>, FraiseQLError>

Get all column names for a view/table.

§Arguments
  • view_name - Name of the view or table to introspect
§Returns

List of all column names in the view/table.

§Errors

Returns FraiseQLError::ConnectionPool if a connection cannot be acquired, or FraiseQLError::Database if the query fails.

Trait Implementations§

Source§

impl DatabaseIntrospector for PostgresIntrospector

Source§

async fn list_fact_tables(&self) -> Result<Vec<String>, FraiseQLError>

List all fact tables in the database (tables starting with “tf_”). Read more
Source§

async fn get_columns( &self, table_name: &str, ) -> Result<Vec<(String, String, bool)>, FraiseQLError>

Query column information for a table. Read more
Source§

async fn get_indexed_columns( &self, table_name: &str, ) -> Result<Vec<String>, FraiseQLError>

Query indexes for a table. Read more
Source§

fn database_type(&self) -> DatabaseType

Get database type (for SQL type parsing).
Source§

async fn list_relations(&self) -> Result<Vec<RelationInfo>, FraiseQLError>

List all relations (tables and views) in the database. Read more
Source§

async fn get_sample_jsonb( &self, table_name: &str, column_name: &str, ) -> Result<Option<Value>, FraiseQLError>

Get sample JSONB data from a column to extract dimension paths. Read more
Source§

async fn get_sample_json_rows( &self, table_name: &str, column_name: &str, limit: usize, ) -> Result<Vec<Value>, FraiseQLError>

Get sample JSON rows from a column for schema inference and the L3 JSONB-key drift check (#384). Read more
Source§

async fn function_exists( &self, schema: Option<&str>, name: &str, ) -> Result<Option<bool>, FraiseQLError>

Probe whether a callable SQL function named name exists — in schema when given, else resolved against the connection search_path. Read more
Source§

async fn qualified_relation_exists( &self, schema: &str, name: &str, ) -> Result<Option<bool>, FraiseQLError>

Probe whether a schema-qualified relation exists, resolved case-sensitively / verbatim — the same way the runtime resolves a qualified sql_source (quote_postgres_identifier + to_regclass), so a mixed-case relation in an off-search_path schema is not falsely reported missing. Read more
Source§

async fn get_view_definition( &self, relation: &str, ) -> Result<Option<String>, FraiseQLError>

The SQL body of relation, when it is a view (#1303). Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more