Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions libs/@local/hashql/core/src/symbol/sym.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ hashql_macros::define_symbols! {
archived,
archived_by_id,
bar,
base_url,
BaseUrl,
bit_and,
bit_not,
Expand Down Expand Up @@ -110,6 +111,7 @@ hashql_macros::define_symbols! {
unknown,
Url,
vectors,
version,
web_id,
// [tidy] sort alphabetically end

Expand Down
6 changes: 6 additions & 0 deletions libs/@local/hashql/mir/src/body/place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,12 @@ pub struct Projection<'heap> {
pub kind: ProjectionKind<'heap>,
}

impl AsRef<Self> for Projection<'_> {
fn as_ref(&self) -> &Self {
self
}
}

/// A projection operation that navigates within structured data.
///
/// Projections allow places to reference nested data within structured types.
Expand Down
3 changes: 3 additions & 0 deletions libs/@local/hashql/mir/src/pass/execution/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ mod island;
mod placement;
mod splitting;
mod statement_placement;
pub mod storage;
mod target;
mod terminator_placement;
mod vertex;

use core::{alloc::Allocator, assert_matches};

Expand All @@ -25,6 +27,7 @@ pub use self::{
island::{Island, IslandId, IslandVec},
placement::error::PlacementDiagnosticCategory,
target::TargetId,
vertex::VertexType,
};
use self::{
fusion::BasicBlockFusion,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use crate::{
local::Local,
location::Location,
operand::Operand,
place::Projection,
rvalue::RValue,
statement::{Assign, Statement, StatementKind},
terminator::TerminatorKind,
Expand All @@ -29,6 +30,7 @@ use crate::{
execution::{
Cost,
cost::{StatementCostVec, TraversalCostVec},
storage::{Access, EntityPath},
},
},
visit::Visitor,
Expand Down Expand Up @@ -319,3 +321,17 @@ where
Ok(())
}
}

/// Determines which backend can access an entity field projection.
///
/// Walks the projection path through the entity schema to determine whether the field is stored in
/// Postgres (as a column or JSONB path) or in the embedding store. Returns `None` if the path
/// doesn't map to any supported backend storage.
///
/// For example:
/// - `entity.properties.foo` → `Some(Access::Postgres(Direct))` (JSONB)
/// - `entity.encodings.vectors` → `Some(Access::Embedding(Direct))`
/// - `entity.metadata.record_id.entity_id.web_id` → `Some(Access::Postgres(Direct))`
pub(crate) fn entity_projection_access(projections: &[Projection<'_>]) -> Option<Access> {
EntityPath::resolve(projections).map(|(path, _)| path.access())
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
use core::alloc::Allocator;

use hashql_core::{
id::{Id as _, bit_vec::DenseBitSet},
symbol::sym,
};
use hashql_core::id::{Id as _, bit_vec::DenseBitSet};

use super::{
StatementPlacement,
Expand All @@ -14,9 +11,10 @@ use crate::{
context::MirContext,
pass::{
execution::{
Cost,
Cost, VertexType,
cost::{StatementCostVec, TraversalCostVec},
statement_placement::lookup::{Access, entity_projection_access},
statement_placement::common::entity_projection_access,
storage::Access,
},
transform::Traversals,
},
Expand All @@ -35,22 +33,19 @@ fn is_supported_place<'heap>(
// For GraphReadFilter bodies, local 1 is the filter argument (vertex). Check if the
// projection path maps to an Embedding-accessible field.
if matches!(body.source, Source::GraphReadFilter(_)) && place.local.as_usize() == 1 {
let local_type = body.local_decls[place.local].r#type;
let type_name = context
.env
.r#type(local_type)
.kind
.opaque()
.map_or_else(|| unreachable!(), |opaque| opaque.name);

if type_name == sym::path::Entity {
return matches!(
entity_projection_access(&place.projections),
Some(Access::Embedding(_))
);
}
let decl = &body.local_decls[place.local];
let Some(vertex_type) = VertexType::from_local(context.env, decl) else {
unimplemented!("lookup for declared type")
};

unimplemented!("unimplemented lookup for declared type")
match vertex_type {
VertexType::Entity => {
return matches!(
entity_projection_access(&place.projections),
Some(Access::Embedding(_))
);
}
}
}

domain.contains(place.local)
Expand Down

This file was deleted.

This file was deleted.

Loading
Loading