refactor(core): use sqlalchemy orm and table reflection in sql resource store - #1485
Merged
Merged
Conversation
AlessandroPomponio
force-pushed
the
ap_1484_rework_metastore_orm
branch
from
September 30, 2026 13:19
22f78d2 to
9ac2ba9
Compare
AlessandroPomponio
marked this pull request as ready for review
October 1, 2026 07:54
AlessandroPomponio
added this pull request to stack #1489
October 1, 2026 08:39
Signed-off-by: Alessandro Pomponio <alessandro.pomponio1@ibm.com>
Signed-off-by: Alessandro Pomponio <alessandro.pomponio1@ibm.com>
… constructs Signed-off-by: Alessandro Pomponio <alessandro.pomponio1@ibm.com>
… constructs Signed-off-by: Alessandro Pomponio <alessandro.pomponio1@ibm.com>
… constructs Signed-off-by: Alessandro Pomponio <alessandro.pomponio1@ibm.com>
Signed-off-by: Alessandro Pomponio <alessandro.pomponio1@ibm.com>
Signed-off-by: Alessandro Pomponio <alessandro.pomponio1@ibm.com>
Signed-off-by: Alessandro Pomponio <alessandro.pomponio1@ibm.com>
Signed-off-by: Alessandro Pomponio <alessandro.pomponio1@ibm.com>
Signed-off-by: Alessandro Pomponio <alessandro.pomponio1@ibm.com>
AlessandroPomponio
force-pushed
the
ap_1484_rework_metastore_orm
branch
from
October 1, 2026 10:35
c2551f3 to
4228018
Compare
Signed-off-by: Alessandro Pomponio <alessandro.pomponio1@ibm.com>
Signed-off-by: Alessandro Pomponio <alessandro.pomponio1@ibm.com>
christian-pinto
approved these changes
Oct 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR reworks the metastore's SQL layer to replace ad-hoc raw SQL string queries and manual table-existence bookkeeping with SQLAlchemy ORM constructs. The result is a cleaner, more maintainable, and more type-safe database layer that no longer depends on dialect-specific raw SQL for introspection.
High-level Changes
sqlalchemy.text(...)queries in the resource store (filtering, joining, traversal, relationship lookups) have been replaced with ORM-style constructs usingTable,select,and_, column operators, and explicit aliases._tables_exist_cachemechanism and theensureExistsparameter have been removed. Instead,create_sql_resource_storenow returns aMetaDataobject that is cached via_reflected_metadata_cache, giving the store direct, typed references to its tables (_resources_table,_relationships_table) without extra round-trips.table_exists_queryandcheck_table_existsremoved: The dialect-specific raw SQL helpers for checking table existence have been deleted along with the now-unnecessarystatements.pyexport surface.json_extract_field_as_stringutility added: A new helper wraps the->>JSON extraction operator in acast(..., String)to prevent SQLAlchemy's JSON type processor from attempting to deserialise already-extracted scalar values, fixing a latentJSONDecodeError.__getstate__/__setstate__now include the table references so they are properly dropped and re-reflected across Ray serialisation boundaries.Impact
These are internal implementation changes with no effect on the public ado API, CLI behaviour, or resource schemas. Performance is unchanged or slightly improved by eliminating redundant table-existence network queries. Any code that previously passed
ensureExiststoSQLResourceStoredirectly must be updated, but that parameter was not part of the public API.