data-finder-ts 0.1.3 → 0.1.5
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 +17 -55
- package/dist/chunk-BGEX377Q.js +230 -0
- package/dist/chunk-BGEX377Q.js.map +1 -0
- package/dist/chunk-BKPWV3OF.js +962 -0
- package/dist/chunk-BKPWV3OF.js.map +1 -0
- package/dist/{chunk-EYXBYV2X.js → chunk-GPHWC533.js} +2 -2
- package/dist/chunk-KAK75RVS.js +198 -0
- package/dist/chunk-KAK75RVS.js.map +1 -0
- package/dist/chunk-MGEL5RWM.js +628 -0
- package/dist/chunk-MGEL5RWM.js.map +1 -0
- package/dist/chunk-PF6EJZHB.js +1015 -0
- package/dist/chunk-PF6EJZHB.js.map +1 -0
- package/dist/datafinder/attribute.cjs +595 -18
- package/dist/datafinder/attribute.cjs.map +1 -1
- package/dist/datafinder/attribute.d.cts +73 -10
- package/dist/datafinder/attribute.d.ts +73 -10
- package/dist/datafinder/attribute.js +2 -2
- package/dist/datafinder/runner.cjs +1589 -288
- package/dist/datafinder/runner.cjs.map +1 -1
- package/dist/datafinder/runner.d.cts +41 -7
- package/dist/datafinder/runner.d.ts +41 -7
- package/dist/datafinder/runner.js +12 -6
- package/dist/datafinder/sql-generator.cjs +1484 -281
- package/dist/datafinder/sql-generator.cjs.map +1 -1
- package/dist/datafinder/sql-generator.d.cts +19 -14
- package/dist/datafinder/sql-generator.d.ts +19 -14
- package/dist/datafinder/sql-generator.js +9 -7
- package/dist/datafinder/typed-attributes.cjs +856 -93
- package/dist/datafinder/typed-attributes.cjs.map +1 -1
- package/dist/datafinder/typed-attributes.d.cts +3 -135
- package/dist/datafinder/typed-attributes.d.ts +3 -135
- package/dist/datafinder/typed-attributes.js +3 -3
- package/dist/dialect-CogGPm_y.d.cts +38 -0
- package/dist/dialect-aaG1bDi5.d.ts +38 -0
- package/dist/index.cjs +2080 -480
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +119 -14
- package/dist/index.d.ts +119 -14
- package/dist/index.js +362 -12
- package/dist/index.js.map +1 -1
- package/dist/model/milestoning.cjs +529 -0
- package/dist/model/milestoning.cjs.map +1 -1
- package/dist/model/milestoning.js +2 -2
- package/dist/model/relational.cjs +608 -12
- package/dist/model/relational.cjs.map +1 -1
- package/dist/model/relational.d.cts +456 -47
- package/dist/model/relational.d.ts +456 -47
- package/dist/model/relational.js +61 -3
- package/dist/typed-attributes-CUTf_6Ru.d.ts +328 -0
- package/dist/typed-attributes-CdWXq_78.d.cts +328 -0
- package/package.json +5 -2
- package/dist/chunk-3SSWFES4.js +0 -448
- package/dist/chunk-3SSWFES4.js.map +0 -1
- package/dist/chunk-5K2Z3YDY.js +0 -393
- package/dist/chunk-5K2Z3YDY.js.map +0 -1
- package/dist/chunk-6QTCGJWX.js +0 -98
- package/dist/chunk-6QTCGJWX.js.map +0 -1
- package/dist/chunk-DFYZVBII.js +0 -652
- package/dist/chunk-DFYZVBII.js.map +0 -1
- package/dist/chunk-V647VNMY.js +0 -135
- package/dist/chunk-V647VNMY.js.map +0 -1
- /package/dist/{chunk-EYXBYV2X.js.map → chunk-GPHWC533.js.map} +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -1,22 +1,81 @@
|
|
|
1
|
-
|
|
1
|
+
import { Attribute } from './datafinder/attribute.cjs';
|
|
2
2
|
export { getRelatedFinderClass, registerRelatedFinderClass } from './datafinder/finder-registry.cjs';
|
|
3
|
-
export { BooleanAttribute, DateAttribute, DateTimeAttribute, DecimalAttribute, DoubleAttribute, FloatAttribute, IntegerAttribute, NumericAttribute, StringAttribute } from './
|
|
3
|
+
export { B as BooleanAttribute, D as DateAttribute, a as DateTimeAttribute, b as DecimalAttribute, c as DoubleAttribute, F as FloatAttribute, I as IntegerAttribute, N as NumericAttribute, d as NumericFunctionOperation, S as StringAttribute, e as StringFunctionOperation } from './typed-attributes-CdWXq_78.cjs';
|
|
4
|
+
import { NumericConstantOperation, ConstantOperation, CountAllOperation, Operation, ExistsOperation, NotExistsOperation, RelationalOperationElement, CaseOperation, JoinTreeNodeOperation, SortOperation } from './model/relational.cjs';
|
|
5
|
+
export { AggregateOperation, AggregateOperator, Aggregates, Alias, Aliasable, Arithmetic, ArithmeticOperand, ArithmeticOperation, ArithmeticOperator, BinaryOperation, BooleanAggregates, BooleanConstantOperation, Column, ColumnWithJoin, Comparable, ComparisonOperation, ComparisonOperator, ConcatOperation, ConcatPart, DATE_ONLY_PATTERN, DataCatalog, DataStore, Database, DateArithmeticOperation, DateConstantOperation, DateDiffOperation, DateExtractOperation, DateOnly, DatePart, DateTimeConstantOperation, DateTruncOperation, DecimalConstantOperation, FloatConstantOperation, ForeignKey, InOperation, IntegerConstantOperation, IsNotNullOperation, IsNullOperation, JoinOperation, LIKE_ESCAPE, LogicalOperation, LogicalOperator, NUMERIC_FUNCTIONS, NoOperation, NotInOperation, ScalarFunction, ScalarFunctionOperation, Schema, SelectOperation, SortDirection, Sortable, StringConstantOperation, StringPredicates, Table, UnaryOperation, WindowFunction, WindowFunctionOperation, WindowSpecification, applyMixins, concat, containsAggregate, containsAggregateOrWindow, escapeLike, operandOf, sample, valueOperand } from './model/relational.cjs';
|
|
4
6
|
export { selectSqlToString, toSql } from './datafinder/sql-generator.cjs';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export {
|
|
7
|
+
export { D as DATABRICKS, a as DUCKDB, b as DialectName, P as POSTGRES, S as SqlDialect, d as dialectOf } from './dialect-CogGPm_y.cjs';
|
|
8
|
+
import { QueryRunner, QueryTarget, Row } from './datafinder/runner.cjs';
|
|
9
|
+
export { DEFAULT_TIMEOUT_MS, FinderResult, QueryTimeoutError, clearRunner, convertInputsAndSelect, convertInputsAndSelectForDateRange, getRunner, registerRunner } from './datafinder/runner.cjs';
|
|
8
10
|
export { BiTemporalColumns, BusinessDateAndProcessingTemporalColumns, MilestonedTable, MilestoningColumns, ProcessingTemporalColumns, SingleBusinessDateColumn } from './model/milestoning.cjs';
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
/** Expressions that are not a column of a finder: values to select next to the columns. */
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* A fixed value as a column: `f.findAll(null, null, [f.name(), constant('EU').alias('Region')])`.
|
|
16
|
+
* A number is a `NumericConstantOperation`, which takes part in arithmetic: `constant(100).minus(f.price())`.
|
|
17
|
+
* A `DateOnly` is a date and any other `Date` a timestamp. It is named "Constant" unless `alias` gives it a name.
|
|
18
|
+
*/
|
|
19
|
+
declare function constant(value: number): NumericConstantOperation;
|
|
20
|
+
declare function constant(value: boolean | string | Date): ConstantOperation;
|
|
21
|
+
declare function constant(value: boolean | number | string | Date): ConstantOperation;
|
|
22
|
+
/**
|
|
23
|
+
* The number of rows in the group, `COUNT(*)`: `f.findAll(null, null, [f.category(), countAll()]).groupBy(f.category())`.
|
|
24
|
+
* Unlike `count()` of a column it also counts rows where that column is missing.
|
|
25
|
+
*/
|
|
26
|
+
declare function countAll(): CountAllOperation;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* A value that depends on a condition, written as in polars:
|
|
30
|
+
* `when(f.age().gt(30)).then('senior').otherwise('junior')`.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/** What a branch can be: a column or expression as it is, a plain value as a constant. */
|
|
34
|
+
type Branch = Attribute | RelationalOperationElement | boolean | number | string | Date;
|
|
35
|
+
/**
|
|
36
|
+
* Something that is true or false for a row, which a `when` can test: a comparison, a null check, a membership
|
|
37
|
+
* test, `exists`, or `and` / `or` of those. Checked when `when` is called.
|
|
38
|
+
*/
|
|
39
|
+
type Condition = Operation | ExistsOperation | NotExistsOperation;
|
|
40
|
+
type Case = [Condition, RelationalOperationElement];
|
|
41
|
+
/**
|
|
42
|
+
* `when(condition).then(value)`: a column on its own (missing where the condition does not hold), or continued
|
|
43
|
+
* with another `when` or closed with `otherwise`.
|
|
44
|
+
*/
|
|
45
|
+
declare class Then extends CaseOperation {
|
|
46
|
+
private readonly cases;
|
|
47
|
+
constructor(cases: Case[]);
|
|
48
|
+
/** Another case, tried when the ones before it do not hold. */
|
|
49
|
+
when(condition: Condition): When;
|
|
50
|
+
/** The value when none of the cases hold. */
|
|
51
|
+
otherwise(branch: Branch): CaseOperation;
|
|
14
52
|
}
|
|
15
|
-
declare class
|
|
16
|
-
readonly
|
|
17
|
-
|
|
18
|
-
|
|
53
|
+
declare class When {
|
|
54
|
+
private readonly condition;
|
|
55
|
+
private readonly earlier;
|
|
56
|
+
constructor(condition: Condition, earlier?: Case[]);
|
|
57
|
+
/** The value where the condition holds. A value is a column, an expression or a plain value. */
|
|
58
|
+
then(branch: Branch): Then;
|
|
19
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Start a conditional: `when(f.category().eq('Technology')).then('tech').otherwise('other')`.
|
|
62
|
+
*
|
|
63
|
+
* Further cases follow with `.when(...).then(...)`; with no `otherwise` the value is missing (NULL). A condition
|
|
64
|
+
* that is NULL for a row (a comparison with a missing value) is not true, so that row takes the next case.
|
|
65
|
+
*/
|
|
66
|
+
declare function when(condition: Condition): When;
|
|
67
|
+
|
|
68
|
+
/** Python's `str.title()`: uppercase the first letter of each alphabetic run and lowercase the rest. */
|
|
69
|
+
declare function titleCase(value: string): string;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Join-less alternates for a related class's properties, keyed by dotted property path relative to
|
|
73
|
+
* that class (e.g. `name`, `branch.city`). The attributes point at flat columns on the owning table.
|
|
74
|
+
*/
|
|
75
|
+
type EmbeddedAttributes = Record<string, Attribute>;
|
|
76
|
+
/** The alternates under `prefix` (e.g. `branch.`), re-keyed relative to it; undefined when there are none. */
|
|
77
|
+
declare function embeddedUnder(embedded: EmbeddedAttributes | undefined, prefix: string): EmbeddedAttributes | undefined;
|
|
78
|
+
|
|
20
79
|
declare class RelatedFinder {
|
|
21
80
|
private readonly _node;
|
|
22
81
|
constructor(_node: JoinTreeNodeOperation);
|
|
@@ -24,4 +83,50 @@ declare class RelatedFinder {
|
|
|
24
83
|
notExists(): NotExistsOperation;
|
|
25
84
|
}
|
|
26
85
|
|
|
27
|
-
|
|
86
|
+
/**
|
|
87
|
+
* Runs a query on a Databricks SQL warehouse through the SQL Statement Execution REST API
|
|
88
|
+
* (`/api/2.0/sql/statements`), which is plain HTTPS and so works from a browser as well as Node.
|
|
89
|
+
*
|
|
90
|
+
* A browser cannot call a Databricks workspace directly, as the workspace does not send CORS headers, so
|
|
91
|
+
* `host` is usually a server of your own that forwards `/api/2.0/sql/…` to the workspace (and may add the
|
|
92
|
+
* credentials, in which case no `token` is needed here).
|
|
93
|
+
*/
|
|
94
|
+
|
|
95
|
+
interface DatabricksConfig {
|
|
96
|
+
/** The workspace URL, or a server that forwards the Statement Execution API to it. No trailing path. */
|
|
97
|
+
host: string;
|
|
98
|
+
/** The SQL warehouse that runs the statements. */
|
|
99
|
+
warehouseId: string;
|
|
100
|
+
/** Sent as the bearer token. A function is called for every request, so a token can be refreshed. */
|
|
101
|
+
token?: string | (() => string | Promise<string>);
|
|
102
|
+
/** The catalog and schema unqualified table names resolve in. */
|
|
103
|
+
catalog?: string;
|
|
104
|
+
schema?: string;
|
|
105
|
+
/** Extra request headers, for a gateway in front of the workspace. */
|
|
106
|
+
headers?: Record<string, string>;
|
|
107
|
+
/** `fetch`, if not the global one. */
|
|
108
|
+
fetch?: typeof fetch;
|
|
109
|
+
/** How long to wait before first asking again whether a statement has finished (it backs off from there). */
|
|
110
|
+
pollIntervalMs?: number;
|
|
111
|
+
}
|
|
112
|
+
/** A statement Databricks ran and failed, or the API refused. */
|
|
113
|
+
declare class DatabricksQueryError extends Error {
|
|
114
|
+
readonly code?: string | undefined;
|
|
115
|
+
readonly statementId?: string | undefined;
|
|
116
|
+
constructor(message: string, code?: string | undefined, statementId?: string | undefined);
|
|
117
|
+
}
|
|
118
|
+
declare class DatabricksConnect implements QueryRunner {
|
|
119
|
+
private readonly config;
|
|
120
|
+
readonly dialect: "databricks";
|
|
121
|
+
/** Names of the columns of the last query that returned. */
|
|
122
|
+
lastColumns: string[];
|
|
123
|
+
constructor(config: DatabricksConfig);
|
|
124
|
+
select(businessDate: Date | null, processingDatetime: Date | null, columns: (Attribute | RelationalOperationElement)[], table: QueryTarget, op: RelationalOperationElement, orderBy?: SortOperation[], groupBy?: Attribute[], limit?: number, timeoutMs?: number, businessDateTo?: Date | null, distinct?: boolean, offset?: number, having?: Operation): Promise<Row[]>;
|
|
125
|
+
/** The rows of a finished statement, following its chunks. */
|
|
126
|
+
private rows;
|
|
127
|
+
/** Ask Databricks to stop a statement. Best effort: the query is already given up on. */
|
|
128
|
+
private cancel;
|
|
129
|
+
private call;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export { Attribute, CaseOperation, ConstantOperation, CountAllOperation, type DatabricksConfig, DatabricksConnect, DatabricksQueryError, type EmbeddedAttributes, ExistsOperation, JoinTreeNodeOperation, NotExistsOperation, NumericConstantOperation, Operation, QueryRunner, QueryTarget, RelatedFinder, RelationalOperationElement, Row, SortOperation, constant, countAll, embeddedUnder, titleCase, when };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,22 +1,81 @@
|
|
|
1
|
-
|
|
1
|
+
import { Attribute } from './datafinder/attribute.js';
|
|
2
2
|
export { getRelatedFinderClass, registerRelatedFinderClass } from './datafinder/finder-registry.js';
|
|
3
|
-
export { BooleanAttribute, DateAttribute, DateTimeAttribute, DecimalAttribute, DoubleAttribute, FloatAttribute, IntegerAttribute, NumericAttribute, StringAttribute } from './
|
|
3
|
+
export { B as BooleanAttribute, D as DateAttribute, a as DateTimeAttribute, b as DecimalAttribute, c as DoubleAttribute, F as FloatAttribute, I as IntegerAttribute, N as NumericAttribute, d as NumericFunctionOperation, S as StringAttribute, e as StringFunctionOperation } from './typed-attributes-CUTf_6Ru.js';
|
|
4
|
+
import { NumericConstantOperation, ConstantOperation, CountAllOperation, Operation, ExistsOperation, NotExistsOperation, RelationalOperationElement, CaseOperation, JoinTreeNodeOperation, SortOperation } from './model/relational.js';
|
|
5
|
+
export { AggregateOperation, AggregateOperator, Aggregates, Alias, Aliasable, Arithmetic, ArithmeticOperand, ArithmeticOperation, ArithmeticOperator, BinaryOperation, BooleanAggregates, BooleanConstantOperation, Column, ColumnWithJoin, Comparable, ComparisonOperation, ComparisonOperator, ConcatOperation, ConcatPart, DATE_ONLY_PATTERN, DataCatalog, DataStore, Database, DateArithmeticOperation, DateConstantOperation, DateDiffOperation, DateExtractOperation, DateOnly, DatePart, DateTimeConstantOperation, DateTruncOperation, DecimalConstantOperation, FloatConstantOperation, ForeignKey, InOperation, IntegerConstantOperation, IsNotNullOperation, IsNullOperation, JoinOperation, LIKE_ESCAPE, LogicalOperation, LogicalOperator, NUMERIC_FUNCTIONS, NoOperation, NotInOperation, ScalarFunction, ScalarFunctionOperation, Schema, SelectOperation, SortDirection, Sortable, StringConstantOperation, StringPredicates, Table, UnaryOperation, WindowFunction, WindowFunctionOperation, WindowSpecification, applyMixins, concat, containsAggregate, containsAggregateOrWindow, escapeLike, operandOf, sample, valueOperand } from './model/relational.js';
|
|
4
6
|
export { selectSqlToString, toSql } from './datafinder/sql-generator.js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export {
|
|
7
|
+
export { D as DATABRICKS, a as DUCKDB, b as DialectName, P as POSTGRES, S as SqlDialect, d as dialectOf } from './dialect-aaG1bDi5.js';
|
|
8
|
+
import { QueryRunner, QueryTarget, Row } from './datafinder/runner.js';
|
|
9
|
+
export { DEFAULT_TIMEOUT_MS, FinderResult, QueryTimeoutError, clearRunner, convertInputsAndSelect, convertInputsAndSelectForDateRange, getRunner, registerRunner } from './datafinder/runner.js';
|
|
8
10
|
export { BiTemporalColumns, BusinessDateAndProcessingTemporalColumns, MilestonedTable, MilestoningColumns, ProcessingTemporalColumns, SingleBusinessDateColumn } from './model/milestoning.js';
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
/** Expressions that are not a column of a finder: values to select next to the columns. */
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* A fixed value as a column: `f.findAll(null, null, [f.name(), constant('EU').alias('Region')])`.
|
|
16
|
+
* A number is a `NumericConstantOperation`, which takes part in arithmetic: `constant(100).minus(f.price())`.
|
|
17
|
+
* A `DateOnly` is a date and any other `Date` a timestamp. It is named "Constant" unless `alias` gives it a name.
|
|
18
|
+
*/
|
|
19
|
+
declare function constant(value: number): NumericConstantOperation;
|
|
20
|
+
declare function constant(value: boolean | string | Date): ConstantOperation;
|
|
21
|
+
declare function constant(value: boolean | number | string | Date): ConstantOperation;
|
|
22
|
+
/**
|
|
23
|
+
* The number of rows in the group, `COUNT(*)`: `f.findAll(null, null, [f.category(), countAll()]).groupBy(f.category())`.
|
|
24
|
+
* Unlike `count()` of a column it also counts rows where that column is missing.
|
|
25
|
+
*/
|
|
26
|
+
declare function countAll(): CountAllOperation;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* A value that depends on a condition, written as in polars:
|
|
30
|
+
* `when(f.age().gt(30)).then('senior').otherwise('junior')`.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/** What a branch can be: a column or expression as it is, a plain value as a constant. */
|
|
34
|
+
type Branch = Attribute | RelationalOperationElement | boolean | number | string | Date;
|
|
35
|
+
/**
|
|
36
|
+
* Something that is true or false for a row, which a `when` can test: a comparison, a null check, a membership
|
|
37
|
+
* test, `exists`, or `and` / `or` of those. Checked when `when` is called.
|
|
38
|
+
*/
|
|
39
|
+
type Condition = Operation | ExistsOperation | NotExistsOperation;
|
|
40
|
+
type Case = [Condition, RelationalOperationElement];
|
|
41
|
+
/**
|
|
42
|
+
* `when(condition).then(value)`: a column on its own (missing where the condition does not hold), or continued
|
|
43
|
+
* with another `when` or closed with `otherwise`.
|
|
44
|
+
*/
|
|
45
|
+
declare class Then extends CaseOperation {
|
|
46
|
+
private readonly cases;
|
|
47
|
+
constructor(cases: Case[]);
|
|
48
|
+
/** Another case, tried when the ones before it do not hold. */
|
|
49
|
+
when(condition: Condition): When;
|
|
50
|
+
/** The value when none of the cases hold. */
|
|
51
|
+
otherwise(branch: Branch): CaseOperation;
|
|
14
52
|
}
|
|
15
|
-
declare class
|
|
16
|
-
readonly
|
|
17
|
-
|
|
18
|
-
|
|
53
|
+
declare class When {
|
|
54
|
+
private readonly condition;
|
|
55
|
+
private readonly earlier;
|
|
56
|
+
constructor(condition: Condition, earlier?: Case[]);
|
|
57
|
+
/** The value where the condition holds. A value is a column, an expression or a plain value. */
|
|
58
|
+
then(branch: Branch): Then;
|
|
19
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Start a conditional: `when(f.category().eq('Technology')).then('tech').otherwise('other')`.
|
|
62
|
+
*
|
|
63
|
+
* Further cases follow with `.when(...).then(...)`; with no `otherwise` the value is missing (NULL). A condition
|
|
64
|
+
* that is NULL for a row (a comparison with a missing value) is not true, so that row takes the next case.
|
|
65
|
+
*/
|
|
66
|
+
declare function when(condition: Condition): When;
|
|
67
|
+
|
|
68
|
+
/** Python's `str.title()`: uppercase the first letter of each alphabetic run and lowercase the rest. */
|
|
69
|
+
declare function titleCase(value: string): string;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Join-less alternates for a related class's properties, keyed by dotted property path relative to
|
|
73
|
+
* that class (e.g. `name`, `branch.city`). The attributes point at flat columns on the owning table.
|
|
74
|
+
*/
|
|
75
|
+
type EmbeddedAttributes = Record<string, Attribute>;
|
|
76
|
+
/** The alternates under `prefix` (e.g. `branch.`), re-keyed relative to it; undefined when there are none. */
|
|
77
|
+
declare function embeddedUnder(embedded: EmbeddedAttributes | undefined, prefix: string): EmbeddedAttributes | undefined;
|
|
78
|
+
|
|
20
79
|
declare class RelatedFinder {
|
|
21
80
|
private readonly _node;
|
|
22
81
|
constructor(_node: JoinTreeNodeOperation);
|
|
@@ -24,4 +83,50 @@ declare class RelatedFinder {
|
|
|
24
83
|
notExists(): NotExistsOperation;
|
|
25
84
|
}
|
|
26
85
|
|
|
27
|
-
|
|
86
|
+
/**
|
|
87
|
+
* Runs a query on a Databricks SQL warehouse through the SQL Statement Execution REST API
|
|
88
|
+
* (`/api/2.0/sql/statements`), which is plain HTTPS and so works from a browser as well as Node.
|
|
89
|
+
*
|
|
90
|
+
* A browser cannot call a Databricks workspace directly, as the workspace does not send CORS headers, so
|
|
91
|
+
* `host` is usually a server of your own that forwards `/api/2.0/sql/…` to the workspace (and may add the
|
|
92
|
+
* credentials, in which case no `token` is needed here).
|
|
93
|
+
*/
|
|
94
|
+
|
|
95
|
+
interface DatabricksConfig {
|
|
96
|
+
/** The workspace URL, or a server that forwards the Statement Execution API to it. No trailing path. */
|
|
97
|
+
host: string;
|
|
98
|
+
/** The SQL warehouse that runs the statements. */
|
|
99
|
+
warehouseId: string;
|
|
100
|
+
/** Sent as the bearer token. A function is called for every request, so a token can be refreshed. */
|
|
101
|
+
token?: string | (() => string | Promise<string>);
|
|
102
|
+
/** The catalog and schema unqualified table names resolve in. */
|
|
103
|
+
catalog?: string;
|
|
104
|
+
schema?: string;
|
|
105
|
+
/** Extra request headers, for a gateway in front of the workspace. */
|
|
106
|
+
headers?: Record<string, string>;
|
|
107
|
+
/** `fetch`, if not the global one. */
|
|
108
|
+
fetch?: typeof fetch;
|
|
109
|
+
/** How long to wait before first asking again whether a statement has finished (it backs off from there). */
|
|
110
|
+
pollIntervalMs?: number;
|
|
111
|
+
}
|
|
112
|
+
/** A statement Databricks ran and failed, or the API refused. */
|
|
113
|
+
declare class DatabricksQueryError extends Error {
|
|
114
|
+
readonly code?: string | undefined;
|
|
115
|
+
readonly statementId?: string | undefined;
|
|
116
|
+
constructor(message: string, code?: string | undefined, statementId?: string | undefined);
|
|
117
|
+
}
|
|
118
|
+
declare class DatabricksConnect implements QueryRunner {
|
|
119
|
+
private readonly config;
|
|
120
|
+
readonly dialect: "databricks";
|
|
121
|
+
/** Names of the columns of the last query that returned. */
|
|
122
|
+
lastColumns: string[];
|
|
123
|
+
constructor(config: DatabricksConfig);
|
|
124
|
+
select(businessDate: Date | null, processingDatetime: Date | null, columns: (Attribute | RelationalOperationElement)[], table: QueryTarget, op: RelationalOperationElement, orderBy?: SortOperation[], groupBy?: Attribute[], limit?: number, timeoutMs?: number, businessDateTo?: Date | null, distinct?: boolean, offset?: number, having?: Operation): Promise<Row[]>;
|
|
125
|
+
/** The rows of a finished statement, following its chunks. */
|
|
126
|
+
private rows;
|
|
127
|
+
/** Ask Databricks to stop a statement. Best effort: the query is already given up on. */
|
|
128
|
+
private cancel;
|
|
129
|
+
private call;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export { Attribute, CaseOperation, ConstantOperation, CountAllOperation, type DatabricksConfig, DatabricksConnect, DatabricksQueryError, type EmbeddedAttributes, ExistsOperation, JoinTreeNodeOperation, NotExistsOperation, NumericConstantOperation, Operation, QueryRunner, QueryTarget, RelatedFinder, RelationalOperationElement, Row, SortOperation, constant, countAll, embeddedUnder, titleCase, when };
|