Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix QueryScope uri resolution from python #2927

Merged
merged 1 commit into from
Sep 29, 2022
Merged
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
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