1 parent
4eabeb6a15
commit
eccbc5a315
4 files changed
+375
-5
No files matched your search
+23
-1
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { sqlSemanticDialectFor } from "@/lib/sql/semantic/dialect";
|
||||
import { sqlReferenceAnalysisDialectFor, sqlSemanticDialectFor } from "@/lib/sql/semantic/dialect";
|
||||
|
||||
describe("ClickHouse semantic dialect", () => {
|
||||
it("takes precedence over the legacy MySQL behavior dialect", () => {
|
||||
@@ -17,3 +17,25 @@ describe("ClickHouse semantic dialect", () => {
|
||||
expect(dialect.quoteIdentifier("event`name")).toBe("`event``name`");
|
||||
});
|
||||
});
|
||||
|
||||
describe("SQL reference analysis dialect", () => {
|
||||
it("uses Spark SQL grammar for Kyuubi connections", () => {
|
||||
expect(
|
||||
sqlReferenceAnalysisDialectFor({
|
||||
databaseType: "kyuubi",
|
||||
identifierQuote: "`",
|
||||
fallbackDialect: "generic",
|
||||
}),
|
||||
).toBe("spark");
|
||||
});
|
||||
|
||||
it("preserves the configured fallback for other connection types", () => {
|
||||
expect(
|
||||
sqlReferenceAnalysisDialectFor({
|
||||
databaseType: "hive",
|
||||
identifierQuote: "`",
|
||||
fallbackDialect: "generic",
|
||||
}),
|
||||
).toBe("generic");
|
||||
});
|
||||
});
|
||||
@@ -154,6 +154,7 @@ export const SQL_SEMANTIC_DIALECTS: Record<string, SqlSemanticDialectAdapter> =
|
||||
};
|
||||
|
||||
export function sqlReferenceAnalysisDialectFor(options: { databaseType?: DatabaseType; identifierQuote?: string; fallbackDialect: string }): string {
|
||||
if (options.databaseType === "kyuubi") return "spark";
|
||||
if (options.databaseType === "kingbase" && options.identifierQuote === "`") return "mysql";
|
||||
return options.fallbackDialect;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user