qri icon indicating copy to clipboard operation
qri copied to clipboard

SQL querey runtime error: index out of range

Open xxristoskk opened this issue 5 years ago • 4 comments

What is your OS and version?

Linux Mint Cinnamon 20

What version of qri are you using (qri version)?

0.9.11

What did you do?

Tried the command

qri sql "SELECT bc.artist_name FROM xristosk/bandcamp_artists as bc INNER JOIN xristosk/black_bandcamp as bb ON bc.artist_name = bb.name WHERE bc.artist_name = bb.name"

What happened?

Got this error: runtime error: index out of range [12] with length 12

xxristoskk avatar Sep 01 '20 20:09 xxristoskk

I did some debugging and figured out something about the problem. If you do a local checkout of xristosk/bandcamp_artists and look at body.csv, you'll see that there are more columns than there are column names. It doesn't show these unnamed columns on the qri.cloud page, but the column names and first row look like this:

artist_name,bc_url,genres,location,followers,spotify_genres,spotify_id,spotify_pop,spotify_uri,spotify_name,verified_name,verified_genres
Tea & Whiskey,https://teawhiskey.bandcamp.com,"('acoustic', 'Denver')","denver, colorado",,nan,,,,,,,acoustic,denver,colorado,39.7392364,-104.9848623

So acoustic,denver,colorado,39.7392364,-104.9848623 don't correspond to any named columns, and don't show up on qri.cloud.

I made a (perhaps overly blunt) fix (initial version of #1543) that just ignores these the extra columns. I ran this query again and it worked, though it returned only 5 rows after maybe 10 or 20 minutes of processing. But, it seems that the first table isn't actually fully inclusive of the second table so perhaps that's actually correct.

orblivion avatar Sep 24 '20 00:09 orblivion

@orblivion Thanks for digging into this issue! This is an older dataset that appears to have some problems with the structure.json that was never fixed. I'll go ahead and manually change the columns and it should resolve this.

xxristoskk avatar Sep 24 '20 19:09 xxristoskk

After modifying the structure.json to remove extra columns, the query works on my end now.

xxristoskk avatar Sep 24 '20 23:09 xxristoskk

We should leave this issue open until the problem is fixed in code and isn't possible to hit anymore. Having a work-around is good, but the root problem still exists.

dustmop avatar Sep 25 '20 17:09 dustmop