Skip to content

Commit

Permalink
duckdb: handle line breaks after a string constant (#6109)
Browse files Browse the repository at this point in the history
  • Loading branch information
ozkatz authored Jun 17, 2023
1 parent a5e718e commit c18c11f
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions webui/src/pages/repositories/repository/fileRenderers/duckdb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ async function getDuckDB(): Promise<duckdb.AsyncDuckDB> {
// taken from @duckdb/duckdb-wasm/dist/types/src/bindings/tokens.d.ts
// which, unfortunately, we cannot import.
const DUCKDB_STRING_CONSTANT = 2;
const LAKEFS_URI_PATTERN = /^(['"]?)(lakefs:\/\/(.*))(['"])$/;
const LAKEFS_URI_PATTERN = /^(['"]?)(lakefs:\/\/(.*))(['"])\s*$/;

// returns a mapping of `lakefs://..` URIs to their `s3://...` equivalent
async function extractFiles(conn: AsyncDuckDBConnection, sql: string): Promise<{ [name: string]: string }> {
Expand Down Expand Up @@ -94,16 +94,7 @@ export async function runDuckDBQuery(sql: string): Promise<arrow.Table<any>> {
// remove registrations
await Promise.all(fileNames.map(fileName => db.dropFile(fileName)))
} finally {
await closeDuckDBConnection(conn)
}
return result
}

async function closeDuckDBConnection(conn: AsyncDuckDBConnection | null) {
if (conn !== null) {
await conn.close()
}
const db = await getDuckDB()
await db.flushFiles()
await db.dropFiles()
return result
}

0 comments on commit c18c11f

Please sign in to comment.