sqlite-xsv icon indicating copy to clipboard operation
sqlite-xsv copied to clipboard

`LIMIT N` causes "no query solution" ?

Open asg017 opened this issue 2 years ago • 7 comments

select * from temp.label_reader('test_labels.csv') limit 10;

asg017 avatar Mar 30 '23 22:03 asg017

Having the same issue and this is how I am temporarily overcoming it: SELECT rowid, * FROM temp.ip_reader('H:\Temp\detect_ips.csv.zst') WHERE rowid <= 10 Needless to say this would require some ranking if we where to apply other WHERE statements.

PS: Spectacularly fast, particularly when querying zst compressed files. Thank you!

opustecnica avatar Sep 21 '23 19:09 opustecnica

I know the cause of the issue and it'll be fixed in the next release, I'm just lagging a bit on deploying it. Thanks for sharing!

asg017 avatar Sep 21 '23 19:09 asg017

Alex,

Do you mind if I attempt to fix it? I'd like to fix both the parsing of the column names with spaces and the 'limit' issue above. before I dive in, do you have any hint or suggestions?

THX! :-)

opustecnica avatar Nov 18 '23 23:11 opustecnica

Hey @opustecnica! I actually think this issue was fixed in a recent version of sqlite-xsv, but I'm not 100% sure. v0.2.1-alpha.9 might contain the fix, but I can verify it later. tldr it's a small bug in the xBestIndex method

Do you mind sharing the column names with spaces problem? Feel free to file a separate issue as well

asg017 avatar Nov 18 '23 23:11 asg017

Alex,

Testing on:

#----------------------- xsv_version()

v0.2.1-alpha.9 #----------------------- [this still fails] "SELECT * FROM temp.xsv_5m_Sales_Records_Reader('D:\Temp\5m-Sales-Records.csv.zst') LIMIT 10" "SQL logic error no query solution" #----------------------- [this works, albeit slowly.] "SELECT rowid, * FROM temp.xsv_5m_Sales_Records_Reader('D:\Temp\5m-Sales-Records.csv.zst') WHERE rowid <= 10" rowid Region Country Item_Type


1 Australia and Oceania        Palau        Office Supplies
2 Europe                       Poland       Beverages

...

opustecnica avatar Nov 19 '23 01:11 opustecnica

@opustecnica just published v0.2.1-alpha.11, which should allow for LIMIT constraints on xsv_reader tables. Can you see if it fixes your issue?

asg017 avatar Nov 19 '23 02:11 asg017

SUCCESS!

xsv_version()
-------------
v0.2.1-alpha.11
CREATE VIRTUAL TABLE IF NOT EXISTS temp.xsv_5m_Sales_Records_Reader USING csv_reader(Region TEXT, Country TEXT, Item_Type TEXT);
SELECT * FROM temp.xsv_5m_Sales_Records_Reader('D:\Temp\5m-Sales-Records.csv.zst') LIMIT 10;
Region                       Country      Item_Type
------                       -------      ---------
Australia and Oceania        Palau        Office Supplies
Europe                       Poland       Beverages
North America                Canada       Cereal
Europe                       Belarus      Snacks
Middle East and North Africa Oman         Cereal
Sub-Saharan Africa           Burkina Faso Office Supplies
Europe                       Montenegro   Personal Care
Middle East and North Africa Azerbaijan   Cosmetics
Sub-Saharan Africa           South Sudan  Clothes
North America                Greenland    Personal Care

I am sure you already know this, but the usefulness of the xsv_reader approach (common schema) on large (chronologically organized) csv.zst archives is awesome!

opustecnica avatar Nov 19 '23 12:11 opustecnica