feat(database): add Snowflake data sources (#2972)

Snowflake is a built-in data source kind: connection dialog, key-pair, browser single sign-on, password or token sign-in, the database tree, SQL consoles, and Snowflake-aware SQL assistance and syntax colours. The driver speaks Snowflake's session protocol over the existing reqwest + rustls stack, with no JDBC/ODBC or native library and no new package. Metadata is read with SHOW / DESCRIBE, which need no running warehouse; introspected names are kept on disk for completion.

Co-authored-by: vvnadolskyy <12991410+vvnadolskyy@users.noreply.github.com>
This commit is contained in:
pH
2026-11-12 23:06:10 +08:00
committed by GitHub
co-authored by vvnadolskyy
parent 51c14d3b03
commit 59eb6446d4
89 changed files with 12461 additions and 139 deletions
+17 -1
View File
@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
import { formatSql } from "./format";
import { formatSql, formatted } from "./format";
const fmt = (sql: string) => {
let out = sql;
@@ -70,4 +70,20 @@ describe("formatSql", () => {
const edits = formatSql(sql, "sqlite", { from: sql.length - 2, to: sql.length - 1 });
expect(edits).toEqual([{ from: sql.lastIndexOf("select"), to: sql.length, insert: "select 1;" }]);
});
it("keeps Snowflake dollar strings, comments, casts, variant paths and stages", () => {
const sf = (sql: string) => formatted(sql, "snowflake");
expect(sf("select src:customer.name::string,src['k'].v[0] from t where x=$$ a b $$ // why\n;")).toBe(
"select src:customer.name::string,\n src['k'].v[0]\nfrom t\nwhere x = $$ a b $$ // why\n;",
);
expect(sf("select $1 from @my_stage/path/f.csv (file_format=>'ff') t where y='it\\'s; ok';")).toBe(
"select $1\nfrom @my_stage/path/f.csv (file_format => 'ff') t\nwhere y = 'it\\'s; ok';",
);
expect(sf("select a from t qualify row_number() over (order by a)=1 and a>0;")).toBe(
"select a\nfrom t\nqualify row_number() over(order by a) = 1\n and a > 0;",
);
expect(sf("show tables ->> select $1 from $1;")).toBe("show tables ->>\nselect $1\nfrom $1;");
const body = "create procedure p() returns int language sql as $$ begin return 1; end $$;";
expect(sf(body)).toContain("$$ begin return 1; end $$;");
});
});