jerryshao commented on code in PR #12823:
URL: https://github.com/apache/gravitino/pull/12823#discussion_r3914392744
##########
core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/base/FunctionMetaBaseSQLProvider.java:
##########
@@ -228,11 +250,12 @@ public String selectFunctionMetaBySchemaIdAndName(
+ " vi.audit_info as version_audit_info, vi.deleted_at as
version_deleted_at"
+ " FROM "
+ TABLE_NAME
- + " fm INNER JOIN "
+ + " fm LEFT JOIN "
Review Comment:
Switching this to a `LEFT JOIN` can cause a `NullPointerException`
downstream.
`FunctionPO.fromFunctionPO()` unconditionally does:
```java
FunctionVersionPO versionPO = functionPO.functionVersionPO();
... versionPO.definitions() ...
```
with no null check. If a function's `function_current_version` ever has no
matching active row in `function_version_info`, this query now returns the
function row with a `null` nested `functionVersionPO` (MyBatis returns `null`
for a fully-null annotation-based association by default), and `fromFunctionPO`
throws an NPE.
This is reachable through the default read path:
`FunctionPOStorageOps.supportsParentIdRelationalRead()` is `true` and
`Configs.CACHE_ENABLED` defaults to `true`, so
`getFunctionByIdentifier`/`getFunctionPOByIdentifier` (backing
get/update/delete) route through this exact query by default. Before this
change the same broken-invariant state degraded gracefully to "not found"
(INNER JOIN excluded the row); after it, it's a 500.
Worth noting `ViewMetaBaseSQLProvider.selectViewMetaBySchemaIdAndName`
deliberately kept `INNER JOIN` for the equivalent association, specifically to
guarantee its nested PO is never null - this diverges from that convention
without adding the corresponding null guard.
Since the LEFT JOIN is needed for the mid-transaction overwrite readback
(before the version row is inserted), maybe a dedicated query for that specific
call site would be safer than changing this shared, widely-used one - or add a
null check in `fromFunctionPO`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]