Skip to content

Commit

Permalink
Fix QLP QueryScopeParam's as Object Bad Impl
Browse files Browse the repository at this point in the history
  • Loading branch information
nbauernfeind committed Feb 8, 2024
1 parent d2a86b2 commit 33053c1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2537,10 +2537,11 @@ private Optional<CastExpr> makeCastExpressionForPyCallable(Class<?> retType, Met
private Optional<Class<?>> pyCallableReturnType(@NotNull MethodCallExpr n) {
final PyCallableDetails pyCallableDetails = n.getData(QueryLanguageParserDataKeys.PY_CALLABLE_DETAILS);
final String pyMethodName = pyCallableDetails.pythonMethodName;
final Object paramValueRaw = possibleParams.getOrDefault(pyMethodName, null);
if (paramValueRaw == null) {
final QueryScopeParam<?> queryScopeParam = possibleParams.getOrDefault(pyMethodName, null);
if (queryScopeParam == null) {
return Optional.empty();
}
final Object paramValueRaw = queryScopeParam.getValue();
if (!(paramValueRaw instanceof PyCallableWrapper)) {
return Optional.empty();
}
Expand Down Expand Up @@ -2632,11 +2633,11 @@ private void tryVectorizePythonCallable(@NotNull MethodCallExpr n,
// Note: "paramValueRaw" needs to be the *actual PyCallableWrapper* corresponding to the method.
// TODO: Support vectorization of instance methods of constant objects
// ^^ i.e., create a constant for `new PyCallableWrapperImpl(pyScopeObj.getAttribute("pyMethodName"))`
final QueryScopeParam<?> paramValueParam = possibleParams.getOrDefault(pyMethodName, null);
if (paramValueParam == null) {
final QueryScopeParam<?> queryScopeParam = possibleParams.getOrDefault(pyMethodName, null);
if (queryScopeParam == null) {
throw new IllegalStateException("Resolved Python function name " + pyMethodName + " not found");
}
final Object paramValueRaw = paramValueParam.getValue();
final Object paramValueRaw = queryScopeParam.getValue();
if (!(paramValueRaw instanceof PyCallableWrapper)) {
throw new IllegalStateException("Resolved Python function name " + pyMethodName + " not callable");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ public static Object convert(PyObject pyObject) {
return pyObject.asDict();
} else if (pyObject.isCallable()) {
return new PyCallableWrapperJpyImpl(pyObject);
} else if (pyObject.isNone()) {
return null;
} else if (pyObject.isConvertible()) {
try {
// these are java objects; avoid the overhead of the JNI round trip when possible
Expand Down

0 comments on commit 33053c1

Please sign in to comment.