@memberjunction/sql-dialect 6.2.0-edge.5 → 6.2.0-edge.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +280 -91
- package/dist/dialectFactory.d.ts +37 -5
- package/dist/dialectFactory.d.ts.map +1 -1
- package/dist/dialectFactory.js +106 -14
- package/dist/dialectFactory.js.map +1 -1
- package/dist/dialects/ansi.d.ts +55 -0
- package/dist/dialects/ansi.d.ts.map +1 -0
- package/dist/dialects/ansi.js +136 -0
- package/dist/dialects/ansi.js.map +1 -0
- package/dist/dialects/baseSchemaDDL.d.ts +78 -0
- package/dist/dialects/baseSchemaDDL.d.ts.map +1 -0
- package/dist/dialects/baseSchemaDDL.js +63 -0
- package/dist/dialects/baseSchemaDDL.js.map +1 -0
- package/dist/dialects/databricksQueryDialect.d.ts +41 -0
- package/dist/dialects/databricksQueryDialect.d.ts.map +1 -0
- package/dist/dialects/databricksQueryDialect.js +103 -0
- package/dist/dialects/databricksQueryDialect.js.map +1 -0
- package/dist/dialects/mysqlQueryDialect.d.ts +46 -0
- package/dist/dialects/mysqlQueryDialect.d.ts.map +1 -0
- package/dist/dialects/mysqlQueryDialect.js +117 -0
- package/dist/dialects/mysqlQueryDialect.js.map +1 -0
- package/dist/dialects/oracleQueryDialect.d.ts +42 -0
- package/dist/dialects/oracleQueryDialect.d.ts.map +1 -0
- package/dist/dialects/oracleQueryDialect.js +92 -0
- package/dist/dialects/oracleQueryDialect.js.map +1 -0
- package/dist/dialects/postgresqlSchemaDDL.d.ts +112 -0
- package/dist/dialects/postgresqlSchemaDDL.d.ts.map +1 -0
- package/dist/dialects/postgresqlSchemaDDL.js +590 -0
- package/dist/dialects/postgresqlSchemaDDL.js.map +1 -0
- package/dist/dialects/snowflakeQueryDialect.d.ts +41 -0
- package/dist/dialects/snowflakeQueryDialect.d.ts.map +1 -0
- package/dist/dialects/snowflakeQueryDialect.js +94 -0
- package/dist/dialects/snowflakeQueryDialect.js.map +1 -0
- package/dist/dialects/sqlServerSchemaDDL.d.ts +83 -0
- package/dist/dialects/sqlServerSchemaDDL.d.ts.map +1 -0
- package/dist/dialects/sqlServerSchemaDDL.js +507 -0
- package/dist/dialects/sqlServerSchemaDDL.js.map +1 -0
- package/dist/facets/dialectBinding.d.ts +26 -0
- package/dist/facets/dialectBinding.d.ts.map +1 -0
- package/dist/facets/dialectBinding.js +2 -0
- package/dist/facets/dialectBinding.js.map +1 -0
- package/dist/facets/dialectGrammar.d.ts +82 -0
- package/dist/facets/dialectGrammar.d.ts.map +1 -0
- package/dist/facets/dialectGrammar.js +2 -0
- package/dist/facets/dialectGrammar.js.map +1 -0
- package/dist/facets/dialectKey.d.ts +9 -0
- package/dist/facets/dialectKey.d.ts.map +1 -0
- package/dist/facets/dialectKey.js +2 -0
- package/dist/facets/dialectKey.js.map +1 -0
- package/dist/facets/dialectLexicalRules.d.ts +102 -0
- package/dist/facets/dialectLexicalRules.d.ts.map +1 -0
- package/dist/facets/dialectLexicalRules.js +2 -0
- package/dist/facets/dialectLexicalRules.js.map +1 -0
- package/dist/facets/dialectSchemaDDL.d.ts +213 -0
- package/dist/facets/dialectSchemaDDL.d.ts.map +1 -0
- package/dist/facets/dialectSchemaDDL.js +2 -0
- package/dist/facets/dialectSchemaDDL.js.map +1 -0
- package/dist/facets/dialectTypes.d.ts +31 -0
- package/dist/facets/dialectTypes.d.ts.map +1 -0
- package/dist/facets/dialectTypes.js +2 -0
- package/dist/facets/dialectTypes.js.map +1 -0
- package/dist/facets/dialectWriter.d.ts +59 -0
- package/dist/facets/dialectWriter.d.ts.map +1 -0
- package/dist/facets/dialectWriter.js +2 -0
- package/dist/facets/dialectWriter.js.map +1 -0
- package/dist/identifierReferences.d.ts +8 -1
- package/dist/identifierReferences.d.ts.map +1 -1
- package/dist/identifierReferences.js +8 -1
- package/dist/identifierReferences.js.map +1 -1
- package/dist/index.d.ts +22 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -5
- package/dist/index.js.map +1 -1
- package/dist/postgresqlAutoQuote.d.ts +10 -0
- package/dist/postgresqlAutoQuote.d.ts.map +1 -1
- package/dist/postgresqlAutoQuote.js +12 -0
- package/dist/postgresqlAutoQuote.js.map +1 -1
- package/dist/postgresqlDialect.d.ts +57 -149
- package/dist/postgresqlDialect.d.ts.map +1 -1
- package/dist/postgresqlDialect.js +110 -676
- package/dist/postgresqlDialect.js.map +1 -1
- package/dist/postgresqlRestarLayeredOuter.d.ts.map +1 -1
- package/dist/postgresqlRestarLayeredOuter.js +45 -15
- package/dist/postgresqlRestarLayeredOuter.js.map +1 -1
- package/dist/queryDialect.d.ts +42 -0
- package/dist/queryDialect.d.ts.map +1 -0
- package/dist/queryDialect.js +25 -0
- package/dist/queryDialect.js.map +1 -0
- package/dist/sqlDialect.d.ts +148 -212
- package/dist/sqlDialect.d.ts.map +1 -1
- package/dist/sqlDialect.js +751 -29
- package/dist/sqlDialect.js.map +1 -1
- package/dist/sqlServerDialect.d.ts +54 -117
- package/dist/sqlServerDialect.d.ts.map +1 -1
- package/dist/sqlServerDialect.js +124 -587
- package/dist/sqlServerDialect.js.map +1 -1
- package/package.json +4 -2
package/dist/dialectFactory.js
CHANGED
|
@@ -1,29 +1,121 @@
|
|
|
1
|
+
import { MJGlobal } from '@memberjunction/global';
|
|
2
|
+
import { SQLDialect } from './sqlDialect.js';
|
|
3
|
+
import { QueryDialect } from './queryDialect.js';
|
|
1
4
|
import { SQLServerDialect } from './sqlServerDialect.js';
|
|
2
5
|
import { PostgreSQLDialect } from './postgresqlDialect.js';
|
|
6
|
+
import { MySQLQueryDialect } from './dialects/mysqlQueryDialect.js';
|
|
7
|
+
import { OracleQueryDialect } from './dialects/oracleQueryDialect.js';
|
|
8
|
+
import { SnowflakeQueryDialect } from './dialects/snowflakeQueryDialect.js';
|
|
9
|
+
import { DatabricksQueryDialect } from './dialects/databricksQueryDialect.js';
|
|
3
10
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
11
|
+
* The dialects of the platforms MJ itself runs on. Built-in dialects are constructed directly and
|
|
12
|
+
* are not registered with the class factory, so neither import order nor a test that stubs
|
|
13
|
+
* `@memberjunction/global` can make one unresolvable.
|
|
6
14
|
*/
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
15
|
+
const PLATFORM_DIALECT_CLASSES = [SQLServerDialect, PostgreSQLDialect];
|
|
16
|
+
/** The query-only dialects this package ships, constructed directly for the same reason. */
|
|
17
|
+
const QUERY_ONLY_DIALECT_CLASSES = [MySQLQueryDialect, OracleQueryDialect, SnowflakeQueryDialect, DatabricksQueryDialect];
|
|
18
|
+
/** The platform keys, in order. */
|
|
19
|
+
const PLATFORM_KEYS = PLATFORM_DIALECT_CLASSES.map(dialectClass => new dialectClass().PlatformKey);
|
|
20
|
+
/** Every built-in dialect, keyed by its exact key, as a factory for a new instance. */
|
|
21
|
+
const BUILT_IN_DIALECTS = new Map([...PLATFORM_DIALECT_CLASSES, ...QUERY_ONLY_DIALECT_CLASSES].map(dialectClass => {
|
|
22
|
+
const factory = () => new dialectClass();
|
|
23
|
+
return [factory().Key, factory];
|
|
24
|
+
}));
|
|
11
25
|
/**
|
|
12
|
-
*
|
|
26
|
+
* Narrows an arbitrary string to a {@link DatabasePlatform} this build can
|
|
27
|
+
* actually serve. Use this instead of comparing against a hardcoded
|
|
28
|
+
* `'sqlserver' | 'postgresql'` literal union at call sites — the platform
|
|
29
|
+
* dialects are the single source of truth for which platforms exist.
|
|
30
|
+
*/
|
|
31
|
+
export function IsSupportedPlatform(platform) {
|
|
32
|
+
return typeof platform === 'string' && PLATFORM_KEYS.some(key => key === platform);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The platform keys this build has a dialect for. Derived from the same
|
|
36
|
+
* dialects {@link GetDialect} serves, so callers never maintain a parallel list.
|
|
37
|
+
*/
|
|
38
|
+
export function SupportedPlatforms() {
|
|
39
|
+
return [...PLATFORM_KEYS];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The keys of every dialect that resolves: the built-in ones, then any third-party dialect
|
|
43
|
+
* registered with the class factory under {@link QueryDialect}.
|
|
44
|
+
*/
|
|
45
|
+
export function RegisteredDialectKeys() {
|
|
46
|
+
return [...new Set([...BUILT_IN_DIALECTS.keys(), ...classFactoryDialectKeys()])];
|
|
47
|
+
}
|
|
48
|
+
/** Keys registered with the class factory under {@link QueryDialect}; empty when the factory is unavailable. */
|
|
49
|
+
function classFactoryDialectKeys() {
|
|
50
|
+
try {
|
|
51
|
+
return MJGlobal.Instance.ClassFactory.GetAllRegistrations(QueryDialect)
|
|
52
|
+
.map(registration => registration.Key)
|
|
53
|
+
.filter((key) => typeof key === 'string');
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return [];
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Creates the dialect under exactly `key` (same case): a built-in one directly, otherwise the
|
|
61
|
+
* class-factory registration for it. Returns `null` when there is none.
|
|
62
|
+
*/
|
|
63
|
+
function createDialect(key) {
|
|
64
|
+
const builtIn = BUILT_IN_DIALECTS.get(key);
|
|
65
|
+
return builtIn ? builtIn() : createFromClassFactory(key);
|
|
66
|
+
}
|
|
67
|
+
/** A consumer-registered dialect for exactly `key` from the class factory, or `null`. */
|
|
68
|
+
function createFromClassFactory(key) {
|
|
69
|
+
try {
|
|
70
|
+
const factory = MJGlobal.Instance.ClassFactory;
|
|
71
|
+
const registration = factory.GetRegistration(QueryDialect, key);
|
|
72
|
+
if (!registration || registration.Key !== key) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
return factory.CreateInstance(QueryDialect, key);
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Resolves a dialect key to a new instance of its {@link QueryDialect}, such as `'mysql'` or
|
|
83
|
+
* `'snowflake'` for an External Data Source, or `'sqlserver'` / `'postgresql'` (which are full
|
|
84
|
+
* {@link SQLDialect}s). Built-in keys resolve directly; any other key resolves through a
|
|
85
|
+
* class-factory registration under {@link QueryDialect}.
|
|
13
86
|
*
|
|
14
|
-
*
|
|
15
|
-
|
|
87
|
+
* @throws Error if no dialect exists under the key
|
|
88
|
+
*/
|
|
89
|
+
export function GetQueryDialect(key) {
|
|
90
|
+
const dialect = createDialect(key);
|
|
91
|
+
if (!dialect) {
|
|
92
|
+
throw new Error(`No QueryDialect registered for "${key}". ` +
|
|
93
|
+
`Registered dialects: ${RegisteredDialectKeys().join(', ')}`);
|
|
94
|
+
}
|
|
95
|
+
return dialect;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Resolves a platform key to its concrete {@link SQLDialect} instance.
|
|
99
|
+
*
|
|
100
|
+
* This is the single factory for platform dialect resolution — all consumers should
|
|
101
|
+
* call this instead of maintaining their own switch/map. It serves the built-in platform
|
|
102
|
+
* dialects and any full {@link SQLDialect} registered with the class factory; a query-only
|
|
103
|
+
* dialect (see {@link GetQueryDialect}) is refused.
|
|
16
104
|
*
|
|
17
105
|
* @param platform - The database platform key (e.g., 'sqlserver', 'postgresql')
|
|
18
106
|
* @returns The concrete SQLDialect instance for the platform
|
|
19
|
-
* @throws Error if
|
|
107
|
+
* @throws Error if no SQLDialect exists under the key
|
|
20
108
|
*/
|
|
21
109
|
export function GetDialect(platform) {
|
|
22
|
-
const
|
|
23
|
-
if (!
|
|
110
|
+
const dialect = createDialect(platform);
|
|
111
|
+
if (!(dialect instanceof SQLDialect)) {
|
|
24
112
|
throw new Error(`No SQLDialect registered for "${platform}". ` +
|
|
25
|
-
`Supported platforms: ${
|
|
113
|
+
`Supported platforms: ${PLATFORM_KEYS.join(', ')}`);
|
|
26
114
|
}
|
|
27
|
-
return
|
|
115
|
+
return dialect;
|
|
116
|
+
}
|
|
117
|
+
/** The keys of the query-only dialects this package ships. */
|
|
118
|
+
export function ShippedQueryOnlyDialectKeys() {
|
|
119
|
+
return QUERY_ONLY_DIALECT_CLASSES.map(dialectClass => new dialectClass().Key);
|
|
28
120
|
}
|
|
29
121
|
//# sourceMappingURL=dialectFactory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialectFactory.js","sourceRoot":"","sources":["../src/dialectFactory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dialectFactory.js","sourceRoot":"","sources":["../src/dialectFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAoB,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAE9E;;;;GAIG;AACH,MAAM,wBAAwB,GAAG,CAAC,gBAAgB,EAAE,iBAAiB,CAAU,CAAC;AAEhF,4FAA4F;AAC5F,MAAM,0BAA0B,GAAG,CAAC,iBAAiB,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,sBAAsB,CAAU,CAAC;AAEnI,mCAAmC;AACnC,MAAM,aAAa,GAAgC,wBAAwB,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC,IAAI,YAAY,EAAE,CAAC,WAAW,CAAC,CAAC;AAEhI,uFAAuF;AACvF,MAAM,iBAAiB,GAA4C,IAAI,GAAG,CACtE,CAAC,GAAG,wBAAwB,EAAE,GAAG,0BAA0B,CAAC,CAAC,GAA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YAAY,EAAE,CAAC,GAAG,CAAC,CAAC;AAClF,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { DialectLexicalRules } from '../facets/dialectLexicalRules.js';
|
|
2
|
+
import type { DialectGrammar } from '../facets/dialectGrammar.js';
|
|
3
|
+
import type { DateAddUnit, DialectWriter, LimitClauseResult } from '../facets/dialectWriter.js';
|
|
4
|
+
import { QueryDialect } from '../queryDialect.js';
|
|
5
|
+
/**
|
|
6
|
+
* Standard SQL lexical rules: `"…"` identifiers with doubled-quote escapes, `'…'` strings with
|
|
7
|
+
* doubled-quote escapes and an optional `N` prefix, `--` line comments and non-nested `/* *\/`
|
|
8
|
+
* block comments, `?` placeholders, unquoted names folded to upper case.
|
|
9
|
+
*/
|
|
10
|
+
export declare const ANSI_LEXICAL: DialectLexicalRules;
|
|
11
|
+
/** Statement keywords that write data, change the schema, change permissions or run code, in standard SQL. */
|
|
12
|
+
export declare const ANSI_WRITE_STATEMENT_KEYWORDS: readonly string[];
|
|
13
|
+
/**
|
|
14
|
+
* Standard SQL grammar facts: `OFFSET … FETCH FIRST` row caps, ORDER BY allowed in CTEs and
|
|
15
|
+
* derived tables, nested WITH, `WITH RECURSIVE`, no query-hint clause, `LATERAL`.
|
|
16
|
+
*/
|
|
17
|
+
export declare const ANSI_GRAMMAR: DialectGrammar;
|
|
18
|
+
/**
|
|
19
|
+
* Writes standard SQL. Each dialect's writer extends this and overrides only what its database
|
|
20
|
+
* spells differently.
|
|
21
|
+
*/
|
|
22
|
+
export declare class AnsiWriter implements DialectWriter {
|
|
23
|
+
QuoteIdentifier(name: string): string;
|
|
24
|
+
QuoteSchema(schema: string, object: string): string;
|
|
25
|
+
QuoteColumnAlias(aliasName: string): string;
|
|
26
|
+
QuoteStringLiteral(value: string): string;
|
|
27
|
+
StringLiteralPrefix(_text: string): string;
|
|
28
|
+
/** Backslash-escapes `\`, `%` and `_`, for platforms whose LIKE uses backslash as the default escape. */
|
|
29
|
+
EscapeLikePattern(text: string): string;
|
|
30
|
+
BooleanLiteral(value: boolean): string;
|
|
31
|
+
get NullLiteral(): string;
|
|
32
|
+
LimitClause(limit: number, offset?: number): LimitClauseResult;
|
|
33
|
+
Cast(expr: string, sqlType: string): string;
|
|
34
|
+
CastToText(expr: string): string;
|
|
35
|
+
Coalesce(expr: string, fallback: string): string;
|
|
36
|
+
IsNull(expr: string, fallback: string): string;
|
|
37
|
+
ConcatOperator(): string | null;
|
|
38
|
+
Concat(...parts: string[]): string;
|
|
39
|
+
JsonExtract(column: string, path: string): string;
|
|
40
|
+
DateAddExpression(unit: DateAddUnit, amount: number, baseExpr: string): string;
|
|
41
|
+
CurrentTimestampUTC(): string;
|
|
42
|
+
LowerCase(expr: string): string;
|
|
43
|
+
IIF(condition: string, trueVal: string, falseVal: string): string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Base for query-only dialects: standard SQL facets by default. A dialect overrides the facets
|
|
47
|
+
* (or the parts of them) where its database differs.
|
|
48
|
+
*/
|
|
49
|
+
export declare abstract class AnsiQueryDialect extends QueryDialect {
|
|
50
|
+
private readonly ansiWriter;
|
|
51
|
+
get Lexical(): DialectLexicalRules;
|
|
52
|
+
get Grammar(): DialectGrammar;
|
|
53
|
+
get Writer(): DialectWriter;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=ansi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ansi.d.ts","sourceRoot":"","sources":["../../src/dialects/ansi.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAA4B,MAAM,kCAAkC,CAAC;AACtG,OAAO,KAAK,EAAE,cAAc,EAAc,MAAM,6BAA6B,CAAC;AAC9E,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAChG,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD;;;;GAIG;AACH,eAAO,MA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Q,EAAE,MAAM,GAAG,MAAM;IAI9E,mBAAmB,IAAI,MAAM;IAI7B,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAI/B,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM;CAGpE;AAED;;;GAGG;AACH,8BAAsB,gBAAiB,SAAQ,YAAY;IACvD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAkD;IAE7E,IAAI,OAAO,IAAI,mBAAmB,CAEjC;IAED,IAAI,OAAO,IAAI,cAAc,CAE5B;IAED,IAAI,MAAM,IAAI,aAAa,CAE1B;CACJ"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { QueryDialect } from '../queryDialect.js';
|
|
2
|
+
/**
|
|
3
|
+
* Standard SQL lexical rules: `"…"` identifiers with doubled-quote escapes, `'…'` strings with
|
|
4
|
+
* doubled-quote escapes and an optional `N` prefix, `--` line comments and non-nested `/* *\/`
|
|
5
|
+
* block comments, `?` placeholders, unquoted names folded to upper case.
|
|
6
|
+
*/
|
|
7
|
+
export const ANSI_LEXICAL = Object.freeze({
|
|
8
|
+
IdentifierQuotes: Object.freeze([Object.freeze({ Open: '"', Close: '"', DoubledCloseEscape: true })]),
|
|
9
|
+
StringLiterals: Object.freeze([
|
|
10
|
+
Object.freeze({ Prefixes: Object.freeze(['', 'N']), Quote: "'", DoubledQuoteEscape: true, BackslashEscape: false }),
|
|
11
|
+
]),
|
|
12
|
+
BackslashEscapesDependOnServerSettings: false,
|
|
13
|
+
DollarQuotedStrings: 'none',
|
|
14
|
+
AlternativeQuotingPrefixes: Object.freeze([]),
|
|
15
|
+
LineComments: Object.freeze([Object.freeze({ Opener: '--', RequiresWhitespaceAfter: false })]),
|
|
16
|
+
BlockComments: Object.freeze({ Nested: false, ExecutableOpeners: Object.freeze([]) }),
|
|
17
|
+
ParameterPlaceholders: Object.freeze(['question']),
|
|
18
|
+
UnquotedIdentifierCase: 'upper',
|
|
19
|
+
});
|
|
20
|
+
/** Statement keywords that write data, change the schema, change permissions or run code, in standard SQL. */
|
|
21
|
+
export const ANSI_WRITE_STATEMENT_KEYWORDS = Object.freeze([
|
|
22
|
+
'INSERT', 'UPDATE', 'DELETE', 'MERGE', 'CREATE', 'ALTER', 'DROP', 'TRUNCATE', 'GRANT', 'REVOKE', 'CALL',
|
|
23
|
+
]);
|
|
24
|
+
/**
|
|
25
|
+
* Standard SQL grammar facts: `OFFSET … FETCH FIRST` row caps, ORDER BY allowed in CTEs and
|
|
26
|
+
* derived tables, nested WITH, `WITH RECURSIVE`, no query-hint clause, `LATERAL`.
|
|
27
|
+
*/
|
|
28
|
+
export const ANSI_GRAMMAR = Object.freeze({
|
|
29
|
+
ParserGrammar: null,
|
|
30
|
+
DefaultSchema: null,
|
|
31
|
+
RowCapForms: Object.freeze(['offset-fetch']),
|
|
32
|
+
AllowsOrderByInCTE: true,
|
|
33
|
+
AllowsOrderByInDerivedTable: true,
|
|
34
|
+
SupportsNestedWith: true,
|
|
35
|
+
RecursiveKeyword: 'RECURSIVE',
|
|
36
|
+
QueryHintKeyword: null,
|
|
37
|
+
DocumentTailClauses: Object.freeze([]),
|
|
38
|
+
SetOperatorKeywords: Object.freeze(['UNION', 'INTERSECT', 'EXCEPT']),
|
|
39
|
+
CorrelatedJoin: 'lateral',
|
|
40
|
+
WriteStatementKeywords: ANSI_WRITE_STATEMENT_KEYWORDS,
|
|
41
|
+
CallerSQLForbiddenFunctions: Object.freeze([]),
|
|
42
|
+
DefaultPagingOrderBy: '1',
|
|
43
|
+
SelectListPagingOrderBy: null,
|
|
44
|
+
PagingRequiresOrderBy: false,
|
|
45
|
+
});
|
|
46
|
+
/**
|
|
47
|
+
* Writes standard SQL. Each dialect's writer extends this and overrides only what its database
|
|
48
|
+
* spells differently.
|
|
49
|
+
*/
|
|
50
|
+
export class AnsiWriter {
|
|
51
|
+
QuoteIdentifier(name) {
|
|
52
|
+
return `"${name.replace(/"/g, '""')}"`;
|
|
53
|
+
}
|
|
54
|
+
QuoteSchema(schema, object) {
|
|
55
|
+
return `${this.QuoteIdentifier(schema)}.${this.QuoteIdentifier(object)}`;
|
|
56
|
+
}
|
|
57
|
+
QuoteColumnAlias(aliasName) {
|
|
58
|
+
return this.QuoteIdentifier(aliasName);
|
|
59
|
+
}
|
|
60
|
+
QuoteStringLiteral(value) {
|
|
61
|
+
return `'${value.replace(/'/g, "''")}'`;
|
|
62
|
+
}
|
|
63
|
+
StringLiteralPrefix(_text) {
|
|
64
|
+
return '';
|
|
65
|
+
}
|
|
66
|
+
/** Backslash-escapes `\`, `%` and `_`, for platforms whose LIKE uses backslash as the default escape. */
|
|
67
|
+
EscapeLikePattern(text) {
|
|
68
|
+
return text.replace(/\\/g, '\\\\').replace(/%/g, '\\%').replace(/_/g, '\\_');
|
|
69
|
+
}
|
|
70
|
+
BooleanLiteral(value) {
|
|
71
|
+
return value ? 'TRUE' : 'FALSE';
|
|
72
|
+
}
|
|
73
|
+
get NullLiteral() {
|
|
74
|
+
return 'NULL';
|
|
75
|
+
}
|
|
76
|
+
LimitClause(limit, offset) {
|
|
77
|
+
if (offset != null) {
|
|
78
|
+
return { prefix: '', suffix: `OFFSET ${offset} ROWS FETCH NEXT ${limit} ROWS ONLY` };
|
|
79
|
+
}
|
|
80
|
+
return { prefix: '', suffix: `FETCH FIRST ${limit} ROWS ONLY` };
|
|
81
|
+
}
|
|
82
|
+
Cast(expr, sqlType) {
|
|
83
|
+
return `CAST(${expr} AS ${sqlType})`;
|
|
84
|
+
}
|
|
85
|
+
CastToText(expr) {
|
|
86
|
+
return this.Cast(expr, 'VARCHAR');
|
|
87
|
+
}
|
|
88
|
+
Coalesce(expr, fallback) {
|
|
89
|
+
return `COALESCE(${expr}, ${fallback})`;
|
|
90
|
+
}
|
|
91
|
+
IsNull(expr, fallback) {
|
|
92
|
+
return this.Coalesce(expr, fallback);
|
|
93
|
+
}
|
|
94
|
+
ConcatOperator() {
|
|
95
|
+
return '||';
|
|
96
|
+
}
|
|
97
|
+
Concat(...parts) {
|
|
98
|
+
const operator = this.ConcatOperator();
|
|
99
|
+
return operator === null ? `CONCAT(${parts.join(', ')})` : parts.join(` ${operator} `);
|
|
100
|
+
}
|
|
101
|
+
JsonExtract(column, path) {
|
|
102
|
+
return `JSON_VALUE(${column}, '${path}')`;
|
|
103
|
+
}
|
|
104
|
+
DateAddExpression(unit, amount, baseExpr) {
|
|
105
|
+
return `${baseExpr} + INTERVAL '${amount}' ${unit}`;
|
|
106
|
+
}
|
|
107
|
+
CurrentTimestampUTC() {
|
|
108
|
+
return 'CURRENT_TIMESTAMP';
|
|
109
|
+
}
|
|
110
|
+
LowerCase(expr) {
|
|
111
|
+
return `LOWER(${expr})`;
|
|
112
|
+
}
|
|
113
|
+
IIF(condition, trueVal, falseVal) {
|
|
114
|
+
return `CASE WHEN ${condition} THEN ${trueVal} ELSE ${falseVal} END`;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Base for query-only dialects: standard SQL facets by default. A dialect overrides the facets
|
|
119
|
+
* (or the parts of them) where its database differs.
|
|
120
|
+
*/
|
|
121
|
+
export class AnsiQueryDialect extends QueryDialect {
|
|
122
|
+
constructor() {
|
|
123
|
+
super(...arguments);
|
|
124
|
+
this.ansiWriter = Object.freeze(new AnsiWriter());
|
|
125
|
+
}
|
|
126
|
+
get Lexical() {
|
|
127
|
+
return ANSI_LEXICAL;
|
|
128
|
+
}
|
|
129
|
+
get Grammar() {
|
|
130
|
+
return ANSI_GRAMMAR;
|
|
131
|
+
}
|
|
132
|
+
get Writer() {
|
|
133
|
+
return this.ansiWriter;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=ansi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ansi.js","sourceRoot":"","sources":["../../src/dialects/ansi.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE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AG,IAAI,CAAC,cAAc,EAAE,CAAC;QACvC,OAAO,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,UAAU,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,QAAQ,GAAG,CAAC,CAAC;IAC3F,CAAC;IAED,WAAW,CAAC,MAAc,EAAE,IAAY;QACpC,OAAO,cAAc,MAAM,MAAM,IAAI,IAAI,CAAC;IAC9C,CAAC;IAED,iBAAiB,CAAC,IAAiB,EAAE,MAAc,EAAE,QAAgB;QACjE,OAAO,GAAG,QAAQ,gBAAgB,MAAM,KAAK,IAAI,EAAE,CAAC;IACxD,CAAC;IAED,mBAAmB;QACf,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAED,SAAS,CAAC,IAAY;QAClB,OAAO,SAAS,IAAI,GAAG,CAAC;IAC5B,CAAC;IAED,GAAG,CAAC,SAAiB,EAAE,OAAe,EAAE,QAAgB;QACpD,OAAO,aAAa,SAAS,SAAS,OAAO,SAAS,QAAQ,MAAM,CAAC;IACzE,CAAC;CACJ;AAED;;;GAGG;AACH,MAAM,OAAgB,gBAAiB,SAAQ,YAAY;IAA3D;;QACqB,eAAU,GAAkB,MAAM,CAAC,MAAM,CAAC,IAAI,UAAU,EAAE,CAAC,CAAC;IAajF,CAAC;IAXG,IAAI,OAAO;QACP,OAAO,YAAY,CAAC;IACxB,CAAC;IAED,IAAI,OAAO;QACP,OAAO,YAAY,CAAC;IACxB,CAAC;IAED,IAAI,MAAM;QACN,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;CACJ"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { DataTypeMap } from '../dataTypeMap.js';
|
|
2
|
+
import type { DialectWriter } from '../facets/dialectWriter.js';
|
|
3
|
+
import type { DialectSchemaDDL, SchemaIntrospectionSQL, ColumnDDLOptions, AlterColumnOptions, TriggerOptions, IndexOptions, ResolveTypeOptions } from '../facets/dialectSchemaDDL.js';
|
|
4
|
+
/**
|
|
5
|
+
* Base for a platform's {@link DialectSchemaDDL}: the members with a sensible default live here,
|
|
6
|
+
* the platform supplies the rest. Built over the platform's {@link DialectWriter}, which it uses
|
|
7
|
+
* for quoting and literals.
|
|
8
|
+
*/
|
|
9
|
+
export declare abstract class BaseSchemaDDL implements DialectSchemaDDL {
|
|
10
|
+
protected readonly Writer: DialectWriter;
|
|
11
|
+
constructor(Writer: DialectWriter);
|
|
12
|
+
abstract CanonicalSchemaName(name: string): string;
|
|
13
|
+
abstract BooleanParameterType(): string;
|
|
14
|
+
abstract ParameterRef(name: string): string;
|
|
15
|
+
abstract ParameterDefault(value: string): string;
|
|
16
|
+
abstract NewUUID(): string;
|
|
17
|
+
abstract CastToUUID(expr: string): string;
|
|
18
|
+
abstract StringSplitFunction(value: string, delimiter: string): string;
|
|
19
|
+
abstract FullTextSearchPredicate(column: string, searchTerm: string): string;
|
|
20
|
+
abstract AffectedRowCountSQL(dmlStatement: string, alias: string): string;
|
|
21
|
+
abstract get TypeMap(): DataTypeMap;
|
|
22
|
+
abstract ReturnInsertedClause(columns?: string[]): string;
|
|
23
|
+
abstract AutoIncrementPKExpression(): string;
|
|
24
|
+
abstract UUIDPKDefault(): string;
|
|
25
|
+
abstract ScopeIdentityExpression(): string;
|
|
26
|
+
abstract RowCountExpression(): string;
|
|
27
|
+
abstract BatchSeparator(): string;
|
|
28
|
+
abstract ExistenceCheckSQL(objectType: string, schema: string, name: string): string;
|
|
29
|
+
abstract CreateOrReplaceSupported(objectType: string): boolean;
|
|
30
|
+
abstract FullTextIndexDDL(table: string, columns: string[], catalog?: string): string;
|
|
31
|
+
abstract EscapeFlywayStringInterpolation(sql: string): string;
|
|
32
|
+
abstract ProcedureCallSyntax(schema: string, name: string, params: string[]): string;
|
|
33
|
+
abstract CreateSchemaDDL(schemaName: string): string;
|
|
34
|
+
abstract AddColumnClause(col: ColumnDDLOptions): string;
|
|
35
|
+
abstract AlterColumnDDL(quotedTable: string, options: AlterColumnOptions): string;
|
|
36
|
+
abstract CommentOnColumn(schema: string, table: string, column: string, comment: string): string;
|
|
37
|
+
abstract FallbackType(): string;
|
|
38
|
+
abstract ResolveAbstractType(options: ResolveTypeOptions): string;
|
|
39
|
+
abstract CreateTableIfNotExistsDDL(schema: string, tableName: string, columnsDDL: string): string;
|
|
40
|
+
abstract ConditionalBlock(condition: string, thenSQL: string, elseSQL?: string): string;
|
|
41
|
+
abstract RaiseSignalSQL(message: string): string;
|
|
42
|
+
abstract TriggerDDL(options: TriggerOptions): string;
|
|
43
|
+
abstract IndexDDL(options: IndexOptions): string;
|
|
44
|
+
abstract GrantPermission(permission: string, objectType: string, schema: string, object: string, role: string): string;
|
|
45
|
+
abstract CommentOnObject(objectType: string, schema: string, name: string, comment: string): string;
|
|
46
|
+
abstract SchemaIntrospectionQueries(): SchemaIntrospectionSQL;
|
|
47
|
+
abstract ForeignKeyGraphSQL(schema: string): string;
|
|
48
|
+
abstract AtomicBatchScript(statements: string[]): string;
|
|
49
|
+
abstract CreateSavepointSQL(name: string): string;
|
|
50
|
+
abstract ReleaseSavepointSQL(name: string): string | null;
|
|
51
|
+
abstract RollbackToSavepointSQL(name: string): string;
|
|
52
|
+
/** No practical declare-time cap on an index key string; a platform overrides it where one exists. */
|
|
53
|
+
get MaxKeyStringLength(): number;
|
|
54
|
+
/** No in-row size limit by default. */
|
|
55
|
+
get MaxInRowSizeBytes(): number | null;
|
|
56
|
+
/** No column-count cap by default. */
|
|
57
|
+
get MaxColumnCount(): number | null;
|
|
58
|
+
/** A conservative off-row-pointer floor of 24 bytes. */
|
|
59
|
+
EstimateInRowBytes(_rawSqlType: string): number;
|
|
60
|
+
/** The empty-GUID literal as a plain quoted string. */
|
|
61
|
+
EmptyUUIDLiteral(): string;
|
|
62
|
+
/** `CAST(expr AS <bounded string type>)`, defaulting to MJ's 450-character indexable width. */
|
|
63
|
+
CastToBoundedString(expr: string, maxLength?: number): string;
|
|
64
|
+
/** No cap by default. */
|
|
65
|
+
CapIndexableType(rawSqlType: string): string;
|
|
66
|
+
/**
|
|
67
|
+
* Splits on a `;` followed by optional inline whitespace and a newline, trims each fragment,
|
|
68
|
+
* drops empties, and ends each statement with `;`.
|
|
69
|
+
*/
|
|
70
|
+
SplitStatements(batch: string): string[];
|
|
71
|
+
/** `CREATE TABLE IF NOT EXISTS <fullTable> (...);` as a single statement. */
|
|
72
|
+
CreateTableIfAbsent(fullTable: string, columnsBody: string): string;
|
|
73
|
+
/** {@link CommentOnObject} terminated with `;`, for platforms whose comment statement is idempotent. */
|
|
74
|
+
CommentOnObjectIfAbsent(objectType: string, schema: string, name: string, comment: string): string;
|
|
75
|
+
/** {@link CommentOnColumn} unchanged, for platforms whose comment statement is idempotent. */
|
|
76
|
+
CommentOnColumnIfAbsent(schema: string, table: string, column: string, comment: string): string;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=baseSchemaDDL.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseSchemaDDL.d.ts","sourceRoot":"","sources":["../../src/dialects/baseSchemaDDL.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,EACR,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,kBAAkB,EACrB,MAAM,+BAA+B,CAAC;AAEvC;;;;GAIG;AACH,8BAAsB,aAAc,YAAW,gBAAgB;IAC/C,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,aAAa;gBAArB,MAAM,EAAE,aAAa;IAEpD,QAAQ,CAAC,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAClD,QAAQ,CAAC,oBAAoB,IAAI,MAAM;IACvC,QAAQ,CAAC,YAAY,CAAC,IAA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+1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base for a platform's {@link DialectSchemaDDL}: the members with a sensible default live here,
|
|
3
|
+
* the platform supplies the rest. Built over the platform's {@link DialectWriter}, which it uses
|
|
4
|
+
* for quoting and literals.
|
|
5
|
+
*/
|
|
6
|
+
export class BaseSchemaDDL {
|
|
7
|
+
constructor(Writer) {
|
|
8
|
+
this.Writer = Writer;
|
|
9
|
+
}
|
|
10
|
+
/** No practical declare-time cap on an index key string; a platform overrides it where one exists. */
|
|
11
|
+
get MaxKeyStringLength() {
|
|
12
|
+
return Number.MAX_SAFE_INTEGER;
|
|
13
|
+
}
|
|
14
|
+
/** No in-row size limit by default. */
|
|
15
|
+
get MaxInRowSizeBytes() {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
/** No column-count cap by default. */
|
|
19
|
+
get MaxColumnCount() {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
/** A conservative off-row-pointer floor of 24 bytes. */
|
|
23
|
+
EstimateInRowBytes(_rawSqlType) {
|
|
24
|
+
return 24;
|
|
25
|
+
}
|
|
26
|
+
/** The empty-GUID literal as a plain quoted string. */
|
|
27
|
+
EmptyUUIDLiteral() {
|
|
28
|
+
return `'00000000-0000-0000-0000-000000000000'`;
|
|
29
|
+
}
|
|
30
|
+
/** `CAST(expr AS <bounded string type>)`, defaulting to MJ's 450-character indexable width. */
|
|
31
|
+
CastToBoundedString(expr, maxLength = 450) {
|
|
32
|
+
const sqlType = this.ResolveAbstractType({ type: 'string', maxLength });
|
|
33
|
+
return `CAST(${expr} AS ${sqlType})`;
|
|
34
|
+
}
|
|
35
|
+
/** No cap by default. */
|
|
36
|
+
CapIndexableType(rawSqlType) {
|
|
37
|
+
return rawSqlType;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Splits on a `;` followed by optional inline whitespace and a newline, trims each fragment,
|
|
41
|
+
* drops empties, and ends each statement with `;`.
|
|
42
|
+
*/
|
|
43
|
+
SplitStatements(batch) {
|
|
44
|
+
return batch
|
|
45
|
+
.split(/;\s*\n/g)
|
|
46
|
+
.map((s) => s.trim())
|
|
47
|
+
.filter((s) => s.length > 0)
|
|
48
|
+
.map((s) => (s.endsWith(';') ? s : s + ';'));
|
|
49
|
+
}
|
|
50
|
+
/** `CREATE TABLE IF NOT EXISTS <fullTable> (...);` as a single statement. */
|
|
51
|
+
CreateTableIfAbsent(fullTable, columnsBody) {
|
|
52
|
+
return `CREATE TABLE IF NOT EXISTS ${fullTable} (\n${columnsBody}\n);`;
|
|
53
|
+
}
|
|
54
|
+
/** {@link CommentOnObject} terminated with `;`, for platforms whose comment statement is idempotent. */
|
|
55
|
+
CommentOnObjectIfAbsent(objectType, schema, name, comment) {
|
|
56
|
+
return this.CommentOnObject(objectType, schema, name, comment) + ';';
|
|
57
|
+
}
|
|
58
|
+
/** {@link CommentOnColumn} unchanged, for platforms whose comment statement is idempotent. */
|
|
59
|
+
CommentOnColumnIfAbsent(schema, table, column, comment) {
|
|
60
|
+
return this.CommentOnColumn(schema, table, column, comment);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=baseSchemaDDL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseSchemaDDL.js","sourceRoot":"","sources":["../../src/dialects/baseSchemaDDL.ts"],"names":[],"mappings":"AAYA;;;;GAIG;AACH,MAAM,OAAgB,aAAa;IAC/B,YAA+B,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;IAAG,CAAC;IA2CxD,sGAAsG;IACtG,IAAI,kBAAkB;QAClB,OAAO,MAAM,CAAC,gBAAgB,CAAC;IACnC,CAAC;IAED,uCAAuC;IACvC,IAAI,iBAAiB;QACjB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,sCAAsC;IACtC,IAAI,cAAc;QACd,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,wDAAwD;IACxD,kBAAkB,CAAC,WAAmB;QAClC,OAAO,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C,eAAe,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAChE,CAAC;CACJ"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { DialectKey } from '../facets/dialectKey.js';
|
|
2
|
+
import type { DialectLexicalRules } from '../facets/dialectLexicalRules.js';
|
|
3
|
+
import type { DialectGrammar } from '../facets/dialectGrammar.js';
|
|
4
|
+
import type { DateAddUnit, DialectWriter, LimitClauseResult } from '../facets/dialectWriter.js';
|
|
5
|
+
import { AnsiQueryDialect, AnsiWriter } from './ansi.js';
|
|
6
|
+
/** Base URL: https://docs.databricks.com/en/sql/language-manual/ */
|
|
7
|
+
export declare const DATABRICKS_LEXICAL: DialectLexicalRules;
|
|
8
|
+
/**
|
|
9
|
+
* Databricks grammar facts. `LIMIT` and `OFFSET`, no TOP or FETCH FIRST
|
|
10
|
+
* (https://docs.databricks.com/en/sql/language-manual/sql-ref-syntax-qry-query.html);
|
|
11
|
+
* `WITH RECURSIVE` (https://docs.databricks.com/en/sql/language-manual/sql-ref-syntax-qry-select-cte.html);
|
|
12
|
+
* MINUS as an alternative for EXCEPT
|
|
13
|
+
* (https://docs.databricks.com/en/sql/language-manual/sql-ref-syntax-qry-select-setops.html);
|
|
14
|
+
* LATERAL (https://docs.databricks.com/en/sql/language-manual/sql-ref-syntax-qry-select-table-reference.html).
|
|
15
|
+
* node-sql-parser reads it with its Hive grammar.
|
|
16
|
+
*/
|
|
17
|
+
export declare const DATABRICKS_GRAMMAR: DialectGrammar;
|
|
18
|
+
/** Writes Databricks SQL: backtick identifiers, backslash-escaped literals, `LIMIT`, `TIMESTAMPADD`. */
|
|
19
|
+
export declare class DatabricksWriter extends AnsiWriter {
|
|
20
|
+
QuoteIdentifier(name: string): string;
|
|
21
|
+
/** Escapes with backslashes only: a doubled quote would end the literal and start another. */
|
|
22
|
+
QuoteStringLiteral(value: string): string;
|
|
23
|
+
LimitClause(limit: number, offset?: number): LimitClauseResult;
|
|
24
|
+
CastToText(expr: string): string;
|
|
25
|
+
/** https://docs.databricks.com/en/sql/language-manual/functions/get_json_object.html */
|
|
26
|
+
JsonExtract(column: string, path: string): string;
|
|
27
|
+
/** https://docs.databricks.com/en/sql/language-manual/functions/timestampadd.html */
|
|
28
|
+
DateAddExpression(unit: DateAddUnit, amount: number, baseExpr: string): string;
|
|
29
|
+
/** https://docs.databricks.com/en/sql/language-manual/functions/current_timestamp.html */
|
|
30
|
+
CurrentTimestampUTC(): string;
|
|
31
|
+
}
|
|
32
|
+
/** Databricks, read as an External Data Source. Query-only: no DDL facet. */
|
|
33
|
+
export declare class DatabricksQueryDialect extends AnsiQueryDialect {
|
|
34
|
+
private readonly writer;
|
|
35
|
+
get Key(): DialectKey;
|
|
36
|
+
get DisplayName(): string;
|
|
37
|
+
get Lexical(): DialectLexicalRules;
|
|
38
|
+
get Grammar(): DialectGrammar;
|
|
39
|
+
get Writer(): DialectWriter;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=databricksQueryDialect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"databricksQueryDialect.d.ts","sourceRoot":"","sources":["../../src/dialects/databricksQueryDialect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,EAAE,mBAAmB,EAA4B,MAAM,kCAAkC,CAAC;AACtG,OAAO,KAAK,EAAE,cAAc,EAAc,MAAM,6BAA6B,CAAC;AAC9E,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAChG,OAAO,EAA6D,gBAAgB,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEpH,oEAAoE;AACpE,eAAO,MAAM,kBAAkB,EAAE,mBA2B/B,CAAC;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,EAAE,cAY/B,CAAC;AAEH,wGAAwG;AAC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