Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot install extension using install 'h3ext' from '...'; syntax #95

Closed
isaacbrodsky opened this issue Mar 21, 2024 · 3 comments · Fixed by #108
Closed

Cannot install extension using install 'h3ext' from '...'; syntax #95

isaacbrodsky opened this issue Mar 21, 2024 · 3 comments · Fixed by #108

Comments

@isaacbrodsky
Copy link
Owner

isaacbrodsky commented Mar 21, 2024

D install 'h3ext' from 'http://pub-cc26a6fd5d8240078bd0c2e0623393a5.r2.dev';
HTTP Error: Failed to download extension "h3ext" at URL "http://pub-cc26a6fd5d8240078bd0c2e0623393a5.r2.dev/v0.10.1/linux_amd64/h3ext.duckdb_extension.gz"

Candidate extensions: "s3", "http", "inet"

Perhaps this is because Cloudflare always redirects to HTTPS, and DuckDB does not support HTTPS? Trying to download from the same URL with scheme https gets misdetected as a local file path.

I think what is happening here is that DuckDB has an assumption that extensions are distributed via S3 and that S3 does not enforce HTTPS.

Depends on duckdb/duckdb#9835

@isaacbrodsky isaacbrodsky changed the title Cannot instsall extension using install 'h3ext' from '...'; syntax Cannot install extension using install 'h3ext' from '...'; syntax Mar 21, 2024
@jcolot
Copy link

jcolot commented Apr 15, 2024

@isaacbrodsky It seems to work now, I tried from a build of latest source of duckdb, replaced in the examples esbuild-browser with this index.html:

`
// @ts-nocheck
import * as duckdb from '@duckdb/duckdb-wasm';
import * as arrow from 'apache-arrow';

(async () => {
try {
const DUCKDB_CONFIG = await duckdb.selectBundle({
mvp: {
mainModule: './duckdb-mvp.wasm',
mainWorker: './duckdb-browser-mvp.worker.js',
},
eh: {
mainModule: './duckdb-eh.wasm',
mainWorker: './duckdb-browser-eh.worker.js',
},
coi: {
mainModule: './duckdb-coi.wasm',
mainWorker: './duckdb-browser-coi.worker.js',
pthreadWorker: './duckdb-browser-coi.pthread.worker.js',
},
});

    const logger = new duckdb.ConsoleLogger();
    const worker = new Worker(DUCKDB_CONFIG.mainWorker!);
    const db = new duckdb.AsyncDuckDB(logger, worker);
    await db.instantiate(DUCKDB_CONFIG.mainModule, DUCKDB_CONFIG.pthreadWorker);
    await db.open({allowUnsignedExtensions: true});
    const conn = await db.connect();
    window.conn = conn;
    await conn.query(`SET custom_extension_repository='https://storage.googleapis.com/duckdb-extensions';`);
    await conn.query(`LOAD h3ext;`);
    await conn.query(`INSTALL h3ext;`);
    const result = await conn.query(`SELECT h3_cell_to_latlng('85283473fffffff') as lat_lng`);
    const latLng = result.toArray()[0].toJSON().lat_lng;
    var div = document.createElement('div');
    div.innerHTML = latLng;
    document.body.appendChild(div); // Append the div to the body
} catch (e) {
    var div = document.createElement('div');
    div.innerHTML = JSON.stringify(e); // Assuming you want the same message in the catch block
    document.body.appendChild(div); // Append the error div to the body
    console.error(e);
}

})();
`

@srstsavage
Copy link

I can confirm this works with h3-duckdb 1.0.0 using the python client:

import duckdb

duckdb.sql("INSTALL h3ext FROM 'https://pub-cc26a6fd5d8240078bd0c2e0623393a5.r2.dev'")

con = duckdb.connect(config = {"allow_unsigned_extensions": "true"})
con.load_extension("h3ext")
con.sql("SELECT h3_cell_to_latlng(cast(586265647244115967 as ubigint));").show()

output:

┌────────────────────────────────────────────────────────┐
│ h3_cell_to_latlng(CAST(586265647244115967 AS UBIGINT)) │
│                        double[]                        │
├────────────────────────────────────────────────────────┤
│ [44.104731208541175, 41.04892671698865]                │
└────────────────────────────────────────────────────────┘

Also thanks so much, this project is awesome!

@isaacbrodsky
Copy link
Owner Author

Thanks for confirming @srstsavage !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants