Error 1103: Incorrect table name when reading using tiledb.cloud.sql.exec

Hey there,

I’m attempting to use tiledb.cloud to access some arrays that have been shared with me.
The tiledb.cloud.info() call works for getting info about the array, but when I try and use the same array in a tiledb.cloud.sql.exec() i get an error

import tiledb, tiledb.cloud

tiledb.cloud.login(
    token = '...'
)

// Works
print(tiledb.cloud.info("tiledb://...my_array"))

df_sql = tiledb.cloud.sql.exec(
    query = 
        """
        select * from `tiledb://...my_array` 
        WHERE X >= 147.37 AND X <= 147.38 AND Y > -43.29 AND Y < -42
        """
)       

I get an error like

tiledb.cloud.tiledb_cloud_error.TileDBCloudError: Error 1103: Incorrect table name 'tiledb://...my_array' - Code: 5017

I am able to use the approach above to read a different array which has been shared with me, so it feels like there might be some permissions thing happening somewhere with the problematic array.

One difference might be around AWS permission. The array that I can read is in a public S3 bucket, whereas the array I can’t seem to read is in a restricted bucket. I have set some registered cloud credentials in my tiledb account settings, but I haven’t set any environment variables when executing my script.

Any other tips as to what to look for?

Thanks,
Rowan

And I should also note that accessing the array using the regular tiledb works fine

import tiledb

config = tiledb.Config()
config["rest.token"] = '...'

dataset = tiledb.open("tiledb://...my_array", 'r', ctx=tiledb.Ctx(config))
print(dataset.nonempty_domain())

Hello @rowanwins and welcome to the TileDB forums! My first thought is that the number of characters in tiledb://...my_array is longer than 64 characters?

MariaDB, which we use for the underlying sql parsing, has a limitation of 64 characters for the FROM clause. We have a note on this in our MariaDB docs but I see we are missing this note and example from the TileDB Cloud docs. I will get this added.

If the character count is indeed >= 64a simple work around is as follows:

df_sql = tiledb.cloud.sql.exec(
    query = 
        """
        select * from `my_array` 
        WHERE X >= 147.37 AND X <= 147.38 AND Y > -43.29 AND Y < -42
        """
    init_commands=["CREATE TABLE my_array ENGINE=mytile uri='tiledb://...my_array'"]

What this effectively does is create an alias table in MariaDB with the name “my_array” and we use the uri field we support as a table parameter to allow setting a longer character count for the full URI.

That sounds very possible - the tablename I’m trying to access is 76 chars long inc the tiledb:// or 67 chars long without the tiledb:// bit :face_exhaling:

Thanks for a quick response :+1: and hopefully it’s relatively easy to action on our end :crossed_fingers:

And can confirm that workaround works perfectly thanks @seth !