Replies: 3 comments 4 replies
-
Hi @kesmit13! Indeed, constructing a single The The simplest solution to achieve this would be to eagerly rewrite the operation on construction, the implementation is located at [JSONValue.getitem def __getitem__(self, key):
op = self.op()
if isinstance(op, ops.JSONGetItem):
node = ops.JSONGetItem(op.arg, key=f"{op.index}.{key}")
else:
node = ops.JSONGetItem(op, key)
return node.to_expr() This should provide the requested feature, although there might be backends not supporting nested JSON access. It would be nice to go over the backends with existing ibis implementation for |
Beta Was this translation helpful? Give feedback.
-
I did find a solution that might be the "right" way to do this, although it does take a bit more work. I created a custom JSON data type that I return when mapping SingleStoreDB <=> Ibis data types. I then have to create SingleStoreDBJSONValue, SingleStoreDBJSONScalar, and SingleStoreDBJSONColumn objects that handle the
This still doesn't solve the tuple issue I'm seeing and I can't use the main branch version because I'm working on 6.1 compatibility, so I'm not sure how to get around that one just yet. |
Beta Was this translation helpful? Give feedback.
-
After playing with this for a while, I think rewriting the |
Beta Was this translation helpful? Give feedback.
-
We are using the JSONGetItem operation for accessing JSON objects in SingleStoreDB, however, it only allows for integers and strings to be provided. Our JSON functions allow specifying a full path to an object in JSON as a series of ints and / or strings. It would be nice if the JSONGetItem would allow a tuple of ints / strings kind of like numpy does. You could then specify a path to a nested JSON object as:
Currently, you have to do the following, which results in multiple calls to our JSON functions rather than a single one.
I tried hacking in a
tuple_of
object into theindex
of the existing class, but there are apparently properties that get cached when the class in created, so it didn't work. If I also patch in the cached properties, it gets further, but I get the following error.I'm just wondering if there is a safe way to do this type of thing, without the possibility of breaking other backends using the existing class?
Beta Was this translation helpful? Give feedback.
All reactions