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.
select
?result
where {
unnest("[\"one\", \"two\", \"three\"]"^^<tag:stardog:api:array> as ?result)
}
returns
a
[-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"}}