ArrayLiteral oddness

I've been playing around with the new array literal types and noticed some oddities. I'm could very well be doing something wrong.

When I go to select an array literal I get numeric results. I'm guessing they're the dictionary mapping's. I was expecting the literal form.

where {
  unnest("[\"one\", \"two\", \"three\"]"^^<tag:stardog:api:array> as ?result)


[-14,-15, -16]

I believe the actual values will depend on the specific database and will be different but I was expecting something like

"[\"one\", \"two\", \"three\"]^^<tag:stardog:api:array> 

I also noticed that if you try to send it to a function in the above form

myfunction("[\"one\", \"two\", \"three\"]^^<tag:stardog:api:array>)

It gets passed as a literal with type Datatype.UDF. I could definitely be doing something wrong here but if I create an array type with the set function the myfunction works just fine.

Ok, I think I'm getting it. The literals in the array are transformed to longs from the MappingDictionary. For it to be in the MappingDictionary it has to be in the database. If it's a literal in the query it's not in the database, hence you can't map it so you can't use it.

I should also mention that I realize that there's a good chance the answer is simpley, "it was never meant to be used that way and it's just an internal thing. Just create them with set and unpack them with unwrap.

Maybe that's the reason something like this doesn't return what you expect it, although if my above suspicion is correct I'm surprised it works at all.

Thanks for letting me ask all these questions. I'm having fun but blindly trying to find my way.

select (set(?a) as ?result) where { values ?a {"one" "two" "three"}}

Just a couple of followups. It looks like the auto complete in studio 0.11.0 doesn't appear to include the new set and index functions or unnest.

The only other thing I noticed is that I have a function that takes an ArrayLiteral and it works fine when I pass it a function that generates an array literal but when I use the built in split function I get the following error.

Unrecognized function: split

EDIT: Ok, figured out this one. I have a function called split that generates a warning that I can't called the unqualified function tag:stardog:api:split. I thought that if I created a function name the same as a built in that it prevented unqualified calls to the new function not the built in one. Is this possibly a bug?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.