pub struct RewriteRegCastToSubquery { /* private fields */ }Expand description
Rewrite forward oid-alias casts ('x'::regclass, 'public'::regnamespace,
…) to oid values the way Postgres does.
Postgres oid-alias types cast a name to the matching catalog oid; DataFusion has no such types. This rule rewrites the forward (name->oid) direction at the AST layer, before DataFusion plans the query:
- a numeric string operand (
'16417') becomes a literal oid – Postgres treats a numeric string as the oid itself, and emitting a literal avoids embedding a(SELECT ...)in contexts DataFusion can’t decorrelate (e.g.VALUES ('16417'::regclass)insideIN (...)); - a name string operand (
'public') becomes a scalar subquery against the backing catalog table. The subquery is plain SQL, so DataFusion resolvespg_catalog.pg_namespace/pg_class/pg_type/pg_procthrough the catalog at plan time – noTableProvideror catalog handle is needed in the rule, which is why this lives at the SQL layer rather than as an analyzer rule.
Only the forward direction is rewritten (operand is a string literal or a
prepared-statement $N placeholder). Reverse / column-operand casts such
as prorettype::regtype::text (oid -> name for display) are left untouched;
the PgOidTypePlanner maps those cast types to Int32 so they still parse.
§Limitation vs an analyzer rule
Because the SQL layer has no schema, this rule can only resolve casts that
explicitly name an oid-alias type. The implicit form
oid_col = 'public' (bare string vs an oid column) is not recognized here
– there’s no cast in the AST to key off. Resolving that would require
schema awareness (an analyzer rule + a catalog provider). In practice the
only client query affected is blacklisted.
Implementations§
Trait Implementations§
Source§impl Debug for RewriteRegCastToSubquery
impl Debug for RewriteRegCastToSubquery
Source§impl Default for RewriteRegCastToSubquery
impl Default for RewriteRegCastToSubquery
Auto Trait Implementations§
impl Freeze for RewriteRegCastToSubquery
impl RefUnwindSafe for RewriteRegCastToSubquery
impl Send for RewriteRegCastToSubquery
impl Sync for RewriteRegCastToSubquery
impl Unpin for RewriteRegCastToSubquery
impl UnsafeUnpin for RewriteRegCastToSubquery
impl UnwindSafe for RewriteRegCastToSubquery
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more