Skip to content

Commit

Permalink
Fix QueryScope uri resolution from python
Browse files Browse the repository at this point in the history
Fixes #2893
  • Loading branch information
devinrsmith committed Sep 29, 2022
1 parent d379f90 commit 01c0a8e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions py/server/deephaven/uri.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

""" Tools for resolving Uniform Resource Identifiers (URIs) into objects. """

from typing import Union
from typing import Any

import jpy

Expand All @@ -14,9 +14,9 @@
_JResolveTools = jpy.get_type("io.deephaven.uri.ResolveTools")


def resolve(uri: str) -> Union[jpy.JType, JObjectWrapper]:
def resolve(uri: str) -> Any:
"""Resolves a Uniform Resource Identifier (URI) string into an object. Objects with custom Python wrappers,
like Table, return an instance of the wrapper class; otherwise, the raw Java object is returned.
like Table, return an instance of the wrapper class; otherwise, the Java or Python object is returned.
Args:
Expand All @@ -30,6 +30,9 @@ def resolve(uri: str) -> Union[jpy.JType, JObjectWrapper]:
"""

try:
return wrap_j_object(_JResolveTools.resolve(uri))
# When grabbing something out of the query scope, it may already be presented as a PyObject; in which case,
# when the value gets back into python, it's a native python type - in which case, we don't need to wrap it.
item = _JResolveTools.resolve(uri)
return wrap_j_object(item) if isinstance(item, jpy.JType) else item
except Exception as e:
raise DHError(e, "failed to resolve the URI.") from e

0 comments on commit 01c0a8e

Please sign in to comment.