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

DuckDB.of doesn't ingest relative FileAttachments #190

Closed
Fil opened this issue Nov 17, 2023 · 4 comments
Closed

DuckDB.of doesn't ingest relative FileAttachments #190

Fil opened this issue Nov 17, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@Fil
Copy link
Contributor

Fil commented Nov 17, 2023

EDIT: this now works, but needs to be cleaned up once we ship a new version of stdlib.


This does not currently work:

const db = await DuckDBClient.of({penguins: FileAttachment("simple-parquet.parquet")});

A work-around is to force the URL to be absolute:

function absoluteFA(FA) {
  const {url} = FA;
  FA.url = async function() {
    return new URL(await url.apply(FA), document.location.href).href;
  }
  return FA;
}

then call:

const db = await DuckDBClient.of({penguins: absoluteFA(FileAttachment("simple-parquet.parquet"))});

Maybe that could be fixed in stdlib, https://github.com/observablehq/stdlib/blob/301bd60f43b7416ea4a82a297f0dd287bef83410/src/duckdb.js#L174C36-L174C45

@Fil Fil added the bug Something isn’t working label Nov 17, 2023
@mbostock mbostock added this to the General availability milestone Nov 17, 2023
@Fil
Copy link
Contributor Author

Fil commented Nov 18, 2023

Another workaround:

const db = DuckDBClient.of({
  penguins: {
    file: {
      name: "penguins.parquet",
      url: () => "blob:",
      arrayBuffer: () => FileAttachment("penguins.parquet").arrayBuffer()
    }
  }
})

@Fil
Copy link
Contributor Author

Fil commented Nov 18, 2023

This PR works for me observablehq/stdlib#389

@Fil Fil self-assigned this Nov 18, 2023
mbostock added a commit that referenced this issue Nov 26, 2023
@Fil
Copy link
Contributor Author

Fil commented Nov 27, 2023

When we fix stdlib, revert the (neat) work-around added in 262d2ef

@Fil Fil removed their assignment Nov 27, 2023
@Fil Fil added enhancement New feature or request and removed bug Something isn’t working labels Nov 27, 2023
@Fil
Copy link
Contributor Author

Fil commented Nov 30, 2023

depends on observablehq/runtime#367

Fil added a commit that referenced this issue Nov 30, 2023
@Fil Fil closed this as completed in a8d6246 Nov 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants