risingwave_frontend/optimizer/plan_node/generic/
postgres_query.rsuse educe::Educe;
use risingwave_common::catalog::{ColumnDesc, ColumnId, Schema};
use super::GenericPlanNode;
use crate::optimizer::optimizer_context::OptimizerContextRef;
use crate::optimizer::property::FunctionalDependencySet;
#[derive(Debug, Clone, Educe)]
#[educe(PartialEq, Eq, Hash)]
pub struct PostgresQuery {
pub schema: Schema,
pub hostname: String,
pub port: String,
pub username: String,
pub password: String,
pub database: String,
pub query: String,
#[educe(PartialEq(ignore))]
#[educe(Hash(ignore))]
pub ctx: OptimizerContextRef,
}
impl GenericPlanNode for PostgresQuery {
fn schema(&self) -> Schema {
self.schema.clone()
}
fn stream_key(&self) -> Option<Vec<usize>> {
None
}
fn ctx(&self) -> OptimizerContextRef {
self.ctx.clone()
}
fn functional_dependency(&self) -> FunctionalDependencySet {
FunctionalDependencySet::new(self.schema.len())
}
}
impl PostgresQuery {
pub fn columns(&self) -> Vec<ColumnDesc> {
self.schema
.fields
.iter()
.enumerate()
.map(|(i, f)| {
ColumnDesc::named(f.name.clone(), ColumnId::new(i as i32), f.data_type.clone())
})
.collect()
}
}