@narrative.io/data-collaboration-sdk-ts 0.0.122 → 0.0.124
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/build/datasets/index.d.ts +2 -2
- package/build/datasets/types.d.ts +17 -17
- package/build/index.d.ts +2 -2
- package/build/nql/Ast.d.ts +184 -0
- package/build/nql/Ast.js +3 -0
- package/build/nql/AstParser.d.ts +186 -0
- package/build/nql/AstParser.js +538 -0
- package/build/nql/DataRulesConverter.d.ts +15 -0
- package/build/nql/DataRulesConverter.js +149 -0
- package/build/nql/NQLParser.js +1 -1
- package/build/nql/NqlBuilder.d.ts +8 -0
- package/build/nql/NqlBuilder.js +297 -0
- package/build/nql/index.d.ts +10 -1
- package/build/nql/index.js +11 -0
- package/build/nql/types.d.ts +298 -298
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ApiRecords } from "../types";
|
|
2
2
|
import { BaseApi } from "../base-api";
|
|
3
|
-
import type { FilePerSnapshotResponse, Dataset, DatasetTableSummaryAPIResponse, ColumnStatistics, RetentionPolicy, DatasetTableSummary, RecalculationInfo, UpdateDatasetRequest } from "./types";
|
|
4
|
-
export { type FilePerSnapshotResponse, type Dataset, type RetentionPolicy, type DatasetTableSummaryAPIResponse, type ColumnStatistics, type UpdateDatasetRequest, };
|
|
3
|
+
import type { FilePerSnapshotResponse, Dataset, DatasetTableSummaryAPIResponse, ColumnStatistics, RetentionPolicy, DatasetTableSummary, RecalculationInfo, UpdateDatasetRequest, SchemaFileConfigType, SchemaPropertiesType, DatasetStatus, DatasetWriteMode, SchemaFileConfig, SchemaProperties, SchemaArrayProperty, Schema, AdvancedStatisticsMetadata, SnapshotRange, Configuration, Columns, ColumnSummary, BasicStatistics, AdvancedStatistics, Histogram, Value } from "./types";
|
|
4
|
+
export { type FilePerSnapshotResponse, type Dataset, type RetentionPolicy, type DatasetTableSummaryAPIResponse, type ColumnStatistics, type UpdateDatasetRequest, type SchemaFileConfigType, type SchemaPropertiesType, type DatasetStatus, type DatasetWriteMode, type SchemaFileConfig, type SchemaProperties, type SchemaArrayProperty, type Schema, type AdvancedStatisticsMetadata, type SnapshotRange, type Configuration, type Columns, type ColumnSummary, type BasicStatistics, type AdvancedStatistics, type Histogram, type Value, };
|
|
5
5
|
/**
|
|
6
6
|
* @module DatasetApi
|
|
7
7
|
* @description This module provides methods for fetching datasets.
|
|
@@ -70,10 +70,10 @@ export interface DatasetTableSummaryAPIResponse {
|
|
|
70
70
|
dataset_id: number;
|
|
71
71
|
records: DatasetTableSummary[];
|
|
72
72
|
}
|
|
73
|
-
type SchemaFileConfigType = "flat" | "json" | "parquet";
|
|
74
|
-
type SchemaPropertiesType = "string" | "boolean" | "double" | "long" | "timestamptz" | "object" | "array";
|
|
75
|
-
type DatasetStatus = "active" | "archived";
|
|
76
|
-
type DatasetWriteMode = "append" | "overwrite";
|
|
73
|
+
export type SchemaFileConfigType = "flat" | "json" | "parquet";
|
|
74
|
+
export type SchemaPropertiesType = "string" | "boolean" | "double" | "long" | "timestamptz" | "object" | "array";
|
|
75
|
+
export type DatasetStatus = "active" | "archived";
|
|
76
|
+
export type DatasetWriteMode = "append" | "overwrite";
|
|
77
77
|
type ExpressionlessRetentionPolicyType = "retain_everything" | "expire_everything";
|
|
78
78
|
type ExpressionedRetentionPolicyType = "retain_when" | "expire_when";
|
|
79
79
|
type SchemaType = "object" | "value";
|
|
@@ -93,14 +93,14 @@ export type RetentionPolicy = {
|
|
|
93
93
|
period: string;
|
|
94
94
|
};
|
|
95
95
|
};
|
|
96
|
-
interface SchemaFileConfig {
|
|
96
|
+
export interface SchemaFileConfig {
|
|
97
97
|
type: SchemaFileConfigType;
|
|
98
98
|
delimiter?: string;
|
|
99
99
|
escape?: string;
|
|
100
100
|
header?: boolean;
|
|
101
101
|
quote?: string;
|
|
102
102
|
}
|
|
103
|
-
type SchemaProperties = Record<string, {
|
|
103
|
+
export type SchemaProperties = Record<string, {
|
|
104
104
|
type: SchemaPropertiesType;
|
|
105
105
|
order?: number;
|
|
106
106
|
approximate_cardinality?: number;
|
|
@@ -108,11 +108,11 @@ type SchemaProperties = Record<string, {
|
|
|
108
108
|
items?: SchemaArrayProperty;
|
|
109
109
|
properties?: SchemaProperties;
|
|
110
110
|
}>;
|
|
111
|
-
interface SchemaArrayProperty {
|
|
111
|
+
export interface SchemaArrayProperty {
|
|
112
112
|
type: SchemaPropertiesType;
|
|
113
113
|
properties?: SchemaProperties;
|
|
114
114
|
}
|
|
115
|
-
interface Schema {
|
|
115
|
+
export interface Schema {
|
|
116
116
|
file_config: SchemaFileConfig;
|
|
117
117
|
type: SchemaType;
|
|
118
118
|
properties: SchemaProperties;
|
|
@@ -137,17 +137,17 @@ export interface ColumnStatistics {
|
|
|
137
137
|
advanced_statistics_metadata: AdvancedStatisticsMetadata;
|
|
138
138
|
columns_summary: ColumnSummary[];
|
|
139
139
|
}
|
|
140
|
-
interface AdvancedStatisticsMetadata {
|
|
140
|
+
export interface AdvancedStatisticsMetadata {
|
|
141
141
|
snapshot_range: SnapshotRange;
|
|
142
142
|
configuration: Configuration;
|
|
143
143
|
}
|
|
144
|
-
interface SnapshotRange {
|
|
144
|
+
export interface SnapshotRange {
|
|
145
145
|
from_snapshot: string;
|
|
146
146
|
until_snapshot: string;
|
|
147
147
|
from_snapshot_timestamp: string;
|
|
148
148
|
until_snapshot_timestamp: string;
|
|
149
149
|
}
|
|
150
|
-
interface Configuration {
|
|
150
|
+
export interface Configuration {
|
|
151
151
|
value_histogram: Columns;
|
|
152
152
|
completeness: Columns;
|
|
153
153
|
approx_count_distinct: Columns;
|
|
@@ -156,16 +156,16 @@ interface Configuration {
|
|
|
156
156
|
mean: Columns;
|
|
157
157
|
deviation: Columns;
|
|
158
158
|
}
|
|
159
|
-
interface Columns {
|
|
159
|
+
export interface Columns {
|
|
160
160
|
columns: string[];
|
|
161
161
|
}
|
|
162
|
-
interface ColumnSummary {
|
|
162
|
+
export interface ColumnSummary {
|
|
163
163
|
name: string;
|
|
164
164
|
type: string;
|
|
165
165
|
basic_statistics: BasicStatistics;
|
|
166
166
|
advanced_statistics: AdvancedStatistics;
|
|
167
167
|
}
|
|
168
|
-
interface BasicStatistics {
|
|
168
|
+
export interface BasicStatistics {
|
|
169
169
|
nan_value_count: number | null;
|
|
170
170
|
null_value_count: number;
|
|
171
171
|
lower_bound: string | number;
|
|
@@ -173,7 +173,7 @@ interface BasicStatistics {
|
|
|
173
173
|
value_count: number;
|
|
174
174
|
column_store_bytes: number;
|
|
175
175
|
}
|
|
176
|
-
interface AdvancedStatistics {
|
|
176
|
+
export interface AdvancedStatistics {
|
|
177
177
|
approx_count_distinct: number | null;
|
|
178
178
|
count_distinct: null;
|
|
179
179
|
histogram: Histogram | null;
|
|
@@ -182,11 +182,11 @@ interface AdvancedStatistics {
|
|
|
182
182
|
completeness: number;
|
|
183
183
|
observed_types: Histogram | null;
|
|
184
184
|
}
|
|
185
|
-
interface Histogram {
|
|
185
|
+
export interface Histogram {
|
|
186
186
|
values: Record<string, Value>;
|
|
187
187
|
number_of_bins: number;
|
|
188
188
|
}
|
|
189
|
-
interface Value {
|
|
189
|
+
export interface Value {
|
|
190
190
|
absolute: number;
|
|
191
191
|
ratio: number;
|
|
192
192
|
}
|
package/build/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { DatasetApi } from "./datasets";
|
|
|
3
3
|
import { HealthCheckApi } from "./health";
|
|
4
4
|
import { RosettaStoneApi } from "./rosetta-stone";
|
|
5
5
|
import { type Environment, type Config, type ApiRecords, type MonetaryAmount } from "./types";
|
|
6
|
-
import type { DatasetTableSummaryAPIResponse, Dataset, DatasetTableSummary, FilePerSnapshotResponse, RetentionPolicy, UpdateDatasetRequest } from "./datasets/types";
|
|
6
|
+
import type { DatasetTableSummaryAPIResponse, Dataset, DatasetTableSummary, FilePerSnapshotResponse, RetentionPolicy, UpdateDatasetRequest, SchemaFileConfigType, SchemaPropertiesType, DatasetStatus, DatasetWriteMode, SchemaFileConfig, SchemaProperties, SchemaArrayProperty, Schema, AdvancedStatisticsMetadata, SnapshotRange, Configuration, Columns, ColumnSummary, BasicStatistics, AdvancedStatistics, Histogram, Value } from "./datasets/types";
|
|
7
7
|
import { type HealthCheckResult } from "./health/types";
|
|
8
8
|
import { type SampleRecords } from "./rosetta-stone/types";
|
|
9
9
|
import { AttributeApi } from "./attributes";
|
|
@@ -33,4 +33,4 @@ declare class NarrativeApi extends BaseApi {
|
|
|
33
33
|
}
|
|
34
34
|
interface NarrativeApi extends BaseApi, HealthCheckApi, DatasetApi, RosettaStoneApi, AttributeApi, PingApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi, MappingsApi, AccessRulesApi, AppsApi, SubscriptionsApi {
|
|
35
35
|
}
|
|
36
|
-
export { NarrativeApi, AttributeApi, HealthCheckApi, DatasetApi, PingApi, ProductsApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi, AppsApi, MappingsApi, AccessRulesApi, SubscriptionsApi, getNqlObject, buildNql, convertNqlObjectToForecastBody, isConversationAssistantMessage, isConversationFunctionMessage, isConversationInputMessage, isConversationMessage, isConversationMessageName, isConversationMessageRole, isConversationMessages, isConversationSystemMessage, isConversationUserMessage, isType, isConversationMessageFunctionCall, isConversationAssistantMessageWithFunctionCall, isRosettaRequestMessage, isConversationAssistantMessageWithoutFunctionCall, type App, type Resource, type UploadsResponse, type PingStatus, type Attribute, type ShallowAttribute, type RefAttribute, type SubAttribute, type PrimitiveAttribute, type ArrayAttribute, type ObjectAttribute, type Environment, type Config, type ApiRecords, type Dataset, type HealthCheckResult, type SampleRecords, type DatasetTableSummary, type DatasetTableSummaryAPIResponse, type UpdateDatasetRequest, type Product, type MonetaryAmount, type CompanyInfo, type Installation, type FilePerSnapshotResponse, type BucketCreationRequest, type UpdateAccessTypeRequest, type Nql, type NqlField, type NqlResult, type NqlQueryInput, type NqlCompileResult, type NqlExpression, type NqlWhere, type NqlFilterExpression, type NqlBooleanExpression, type NqlFilterBinaryExpression, type NqlFilterUnaryExpression, type DataStream, type DataRules, type ColumnSet, type ColumnWithFilterAndExport, type AttributeSet, type ForecastRequest, type ForecastResponse, type CostForecastRequest, type CostForecastResponse, type JobState, type ContractDetails, type CustomerContract, type PaymentMethod, type ContractRateView, type LoginRequest, type LoginResponse, type RegisterRequest, type RegisterResponse, type LoggedInUser, type StytchToken, type ApiToken, type UserRole, type RegistrationStatus, type RegistrationStatusRequest, type RegistrationStatusResponse, type ForecastBody, type ConversationAssistantMessage, type ConversationFunctionMessage, type ConversationIOMessage, type ConversationMessage, type ConversationMessageName, type ConversationMessageRole, type ConversationMessages, type ConversationSystemMessage, type ConversationUserMessage, type RosettaRequestMessage, type ConversationMessageFunctionCall, type ConversationAssistantMessageWithFunctionCall, type RosettaResponseMessage, type ConversationAssistantMessageWithoutFunctionCall, type RetentionPolicy, type AccessRule, type Subscription, type SubscriptionDetails, type DataStreamSubscriptionDetails, type MarketplaceSubscriptionDetails, type SubscriptionOutput, type SubscriptionType, type SubscriptionStatus, type SubscriptionBudget, };
|
|
36
|
+
export { NarrativeApi, AttributeApi, HealthCheckApi, DatasetApi, PingApi, ProductsApi, CompanyInfoApi, InstallationsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi, AppsApi, MappingsApi, AccessRulesApi, SubscriptionsApi, getNqlObject, buildNql, convertNqlObjectToForecastBody, isConversationAssistantMessage, isConversationFunctionMessage, isConversationInputMessage, isConversationMessage, isConversationMessageName, isConversationMessageRole, isConversationMessages, isConversationSystemMessage, isConversationUserMessage, isType, isConversationMessageFunctionCall, isConversationAssistantMessageWithFunctionCall, isRosettaRequestMessage, isConversationAssistantMessageWithoutFunctionCall, type App, type Resource, type UploadsResponse, type PingStatus, type Attribute, type ShallowAttribute, type RefAttribute, type SubAttribute, type PrimitiveAttribute, type ArrayAttribute, type ObjectAttribute, type Environment, type Config, type ApiRecords, type Dataset, type HealthCheckResult, type SampleRecords, type DatasetTableSummary, type DatasetTableSummaryAPIResponse, type UpdateDatasetRequest, type SchemaFileConfigType, type SchemaPropertiesType, type DatasetStatus, type DatasetWriteMode, type SchemaFileConfig, type SchemaProperties, type SchemaArrayProperty, type Schema, type AdvancedStatisticsMetadata, type SnapshotRange, type Configuration, type Columns, type ColumnSummary, type BasicStatistics, type AdvancedStatistics, type Histogram, type Value, type Product, type MonetaryAmount, type CompanyInfo, type Installation, type FilePerSnapshotResponse, type BucketCreationRequest, type UpdateAccessTypeRequest, type Nql, type NqlField, type NqlResult, type NqlQueryInput, type NqlCompileResult, type NqlExpression, type NqlWhere, type NqlFilterExpression, type NqlBooleanExpression, type NqlFilterBinaryExpression, type NqlFilterUnaryExpression, type DataStream, type DataRules, type ColumnSet, type ColumnWithFilterAndExport, type AttributeSet, type ForecastRequest, type ForecastResponse, type CostForecastRequest, type CostForecastResponse, type JobState, type ContractDetails, type CustomerContract, type PaymentMethod, type ContractRateView, type LoginRequest, type LoginResponse, type RegisterRequest, type RegisterResponse, type LoggedInUser, type StytchToken, type ApiToken, type UserRole, type RegistrationStatus, type RegistrationStatusRequest, type RegistrationStatusResponse, type ForecastBody, type ConversationAssistantMessage, type ConversationFunctionMessage, type ConversationIOMessage, type ConversationMessage, type ConversationMessageName, type ConversationMessageRole, type ConversationMessages, type ConversationSystemMessage, type ConversationUserMessage, type RosettaRequestMessage, type ConversationMessageFunctionCall, type ConversationAssistantMessageWithFunctionCall, type RosettaResponseMessage, type ConversationAssistantMessageWithoutFunctionCall, type RetentionPolicy, type AccessRule, type Subscription, type SubscriptionDetails, type DataStreamSubscriptionDetails, type MarketplaceSubscriptionDetails, type SubscriptionOutput, type SubscriptionType, type SubscriptionStatus, type SubscriptionBudget, };
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
type Quantifier = "all" | "distinct";
|
|
2
|
+
interface NqlAggFunction {
|
|
3
|
+
nql: string;
|
|
4
|
+
as?: string;
|
|
5
|
+
args: NqlAst[];
|
|
6
|
+
name: string;
|
|
7
|
+
quantifier: Quantifier | null;
|
|
8
|
+
type: "agg_function";
|
|
9
|
+
}
|
|
10
|
+
interface NqlBinaryOp {
|
|
11
|
+
nql: string;
|
|
12
|
+
as?: string;
|
|
13
|
+
name: string;
|
|
14
|
+
left: NqlAst;
|
|
15
|
+
right: NqlAst;
|
|
16
|
+
type: "binary_op";
|
|
17
|
+
}
|
|
18
|
+
interface NqlCase {
|
|
19
|
+
nql: string;
|
|
20
|
+
as?: string;
|
|
21
|
+
args: CaseArg[];
|
|
22
|
+
type: "case";
|
|
23
|
+
}
|
|
24
|
+
type CaseArg = NqlWhen | NqlElse;
|
|
25
|
+
interface NqlWhen {
|
|
26
|
+
nql: string;
|
|
27
|
+
condition: NqlAst;
|
|
28
|
+
value: NqlAst;
|
|
29
|
+
type: "when";
|
|
30
|
+
}
|
|
31
|
+
interface NqlElse {
|
|
32
|
+
nql: string;
|
|
33
|
+
value: NqlAst;
|
|
34
|
+
type: "else";
|
|
35
|
+
}
|
|
36
|
+
interface NqlFunction {
|
|
37
|
+
nql: string;
|
|
38
|
+
as?: string;
|
|
39
|
+
args: NqlAst[];
|
|
40
|
+
name: string;
|
|
41
|
+
type: "function";
|
|
42
|
+
}
|
|
43
|
+
interface NqlArrayType {
|
|
44
|
+
type: "array";
|
|
45
|
+
items: NqlSimpleType | null;
|
|
46
|
+
}
|
|
47
|
+
interface NqlBinaryType {
|
|
48
|
+
type: "binary";
|
|
49
|
+
format: NqlBinaryTypeFormat | null;
|
|
50
|
+
}
|
|
51
|
+
type NqlBinaryTypeFormat = "geometry";
|
|
52
|
+
interface NqlBooleanType {
|
|
53
|
+
type: "bool";
|
|
54
|
+
}
|
|
55
|
+
interface NqlDoubleType {
|
|
56
|
+
type: "double";
|
|
57
|
+
}
|
|
58
|
+
interface NqlLongType {
|
|
59
|
+
type: "long";
|
|
60
|
+
}
|
|
61
|
+
interface NqlIntervalType {
|
|
62
|
+
type: "interval";
|
|
63
|
+
period: NqlIntervalTypePeriod;
|
|
64
|
+
}
|
|
65
|
+
type NqlIntervalTypePeriod = "day" | "day_hour" | "day_minute" | "day_second" | "hour" | "hour_minute" | "hour_second" | "minute" | "minute_second" | "month" | "second" | "year" | "year_month";
|
|
66
|
+
interface NqlObjectType {
|
|
67
|
+
type: "object";
|
|
68
|
+
properties: NqlSimpleType[];
|
|
69
|
+
}
|
|
70
|
+
interface NqlOtherType {
|
|
71
|
+
type: "other";
|
|
72
|
+
}
|
|
73
|
+
interface NqlStringType {
|
|
74
|
+
type: "string";
|
|
75
|
+
}
|
|
76
|
+
interface NqlTimestampType {
|
|
77
|
+
type: "timestamp";
|
|
78
|
+
}
|
|
79
|
+
type NqlSimpleType = NqlArrayType | NqlBinaryType | NqlBooleanType | NqlDoubleType | NqlLongType | NqlIntervalType | NqlObjectType | NqlOtherType | NqlStringType | NqlTimestampType;
|
|
80
|
+
interface NqlLit {
|
|
81
|
+
nql: string;
|
|
82
|
+
as?: string;
|
|
83
|
+
value_type: NqlSimpleType;
|
|
84
|
+
value: string | null;
|
|
85
|
+
type: "literal";
|
|
86
|
+
}
|
|
87
|
+
interface NqlIdentColumn {
|
|
88
|
+
nql: string;
|
|
89
|
+
as?: string;
|
|
90
|
+
db: string | null;
|
|
91
|
+
schema: string | null;
|
|
92
|
+
table: string;
|
|
93
|
+
column: string;
|
|
94
|
+
type: "column";
|
|
95
|
+
}
|
|
96
|
+
interface NqlIdentTable {
|
|
97
|
+
nql: string;
|
|
98
|
+
as?: string;
|
|
99
|
+
db: string | null;
|
|
100
|
+
schema: string | null;
|
|
101
|
+
table: string;
|
|
102
|
+
type: "table";
|
|
103
|
+
}
|
|
104
|
+
type NqlIdent = NqlIdentColumn | NqlIdentTable;
|
|
105
|
+
type NqlJoinConditionType = "none" | "on" | "using";
|
|
106
|
+
type NqlJoinType = "comma" | "cross" | "full" | "inner" | "left" | "left_semi" | "right";
|
|
107
|
+
interface NqlJoin {
|
|
108
|
+
condition: NqlAst | null;
|
|
109
|
+
condition_type: NqlJoinConditionType;
|
|
110
|
+
left: NqlAst;
|
|
111
|
+
join_type: NqlJoinType;
|
|
112
|
+
right: NqlAst;
|
|
113
|
+
type: "join";
|
|
114
|
+
}
|
|
115
|
+
interface NqlTypeSpec {
|
|
116
|
+
nql: string;
|
|
117
|
+
value: string;
|
|
118
|
+
type: "type_spec";
|
|
119
|
+
}
|
|
120
|
+
interface NqlOp {
|
|
121
|
+
nql: string;
|
|
122
|
+
as?: string;
|
|
123
|
+
args: NqlAst[];
|
|
124
|
+
name: string;
|
|
125
|
+
type: "operator";
|
|
126
|
+
}
|
|
127
|
+
interface NqlWindow {
|
|
128
|
+
nql: string;
|
|
129
|
+
lower_bound: NqlAst | null;
|
|
130
|
+
name: NqlIdent | null;
|
|
131
|
+
order_by: NqlAst[];
|
|
132
|
+
partitions: NqlAst[];
|
|
133
|
+
upper_bound: NqlAst | null;
|
|
134
|
+
type: "window";
|
|
135
|
+
}
|
|
136
|
+
interface NqlUnknown {
|
|
137
|
+
nql: string;
|
|
138
|
+
type: "unknown";
|
|
139
|
+
}
|
|
140
|
+
interface NqlBudget {
|
|
141
|
+
amount: {
|
|
142
|
+
currency: string;
|
|
143
|
+
value: number;
|
|
144
|
+
};
|
|
145
|
+
period: {
|
|
146
|
+
type: "calendar_daily" | "calendar_monthly";
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
interface NqlSelect {
|
|
150
|
+
nql: string;
|
|
151
|
+
as?: string;
|
|
152
|
+
budget: NqlBudget | null;
|
|
153
|
+
columns: NqlAst[];
|
|
154
|
+
from: NqlAst | null;
|
|
155
|
+
group_by: NqlAst[];
|
|
156
|
+
having: NqlAst | null;
|
|
157
|
+
is_distinct: boolean;
|
|
158
|
+
limit: NqlAst | null;
|
|
159
|
+
order_by: NqlAst[];
|
|
160
|
+
qualify: NqlAst | null;
|
|
161
|
+
where: NqlAst | null;
|
|
162
|
+
windows: NqlAst[];
|
|
163
|
+
with: NqlAst[] | null;
|
|
164
|
+
type: "select";
|
|
165
|
+
}
|
|
166
|
+
interface NqlCreateMaterializedView {
|
|
167
|
+
nql: string;
|
|
168
|
+
name: string;
|
|
169
|
+
select: NqlSelect;
|
|
170
|
+
type: "create_materialized_view";
|
|
171
|
+
}
|
|
172
|
+
interface NqlExplain {
|
|
173
|
+
nql: string;
|
|
174
|
+
query: NqlAst;
|
|
175
|
+
type: "explain";
|
|
176
|
+
}
|
|
177
|
+
type NqlAstList = NqlAst[] & {
|
|
178
|
+
type: "ast_list";
|
|
179
|
+
};
|
|
180
|
+
export declare function isAstArray(n: NqlAst): n is NqlAstList;
|
|
181
|
+
type NqlAst = {
|
|
182
|
+
type: string;
|
|
183
|
+
} & (NqlAstList | NqlAggFunction | NqlBinaryOp | NqlCase | NqlFunction | NqlLit | NqlIdent | NqlJoin | NqlTypeSpec | NqlOp | NqlWindow | NqlUnknown | NqlSelect | NqlCreateMaterializedView | NqlExplain);
|
|
184
|
+
export type { NqlAst, NqlAstList, NqlAggFunction, NqlBinaryOp, NqlBudget, NqlCase, NqlFunction, NqlSimpleType, NqlLit, NqlIdent, NqlIdentColumn, NqlIdentTable, NqlJoin, NqlJoinType, NqlJoinConditionType, NqlTypeSpec, NqlOp, NqlWindow, NqlUnknown, NqlSelect, NqlCreateMaterializedView, NqlExplain, };
|
package/build/nql/Ast.js
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import * as ast from "./Ast";
|
|
2
|
+
interface Select {
|
|
3
|
+
type: "select";
|
|
4
|
+
budget: ast.NqlBudget | null;
|
|
5
|
+
columns: Expression[];
|
|
6
|
+
from: Table[] | Raw;
|
|
7
|
+
where: BooleanExpression | Raw | null;
|
|
8
|
+
}
|
|
9
|
+
type Expression = ArithmeticExpression | BooleanExpression | ColumnRef | Lit | FunctionCall | StringExpression | UnaryMinus | Raw;
|
|
10
|
+
interface Raw {
|
|
11
|
+
type: "nql";
|
|
12
|
+
as?: string;
|
|
13
|
+
nql: string;
|
|
14
|
+
}
|
|
15
|
+
type ColumnRef = AttributeRef | DatasetColumnRef | RawRef;
|
|
16
|
+
type ArithmeticExpression = BinaryArithmeticExpression | UnaryMinus;
|
|
17
|
+
type BinaryArithmeticExpression = Add | Divide | Multiply | Subtract;
|
|
18
|
+
type BooleanExpression = And | Between | Equals | NotEquals | Gt | Gte | In | IsNull | Like | Lt | Lte | Not | Or;
|
|
19
|
+
type StringExpression = Concat;
|
|
20
|
+
type Table = RosettaTable | DatasetTable | RawTable;
|
|
21
|
+
interface RosettaTable {
|
|
22
|
+
type: "rosetta_stone";
|
|
23
|
+
as?: string;
|
|
24
|
+
join?: Join;
|
|
25
|
+
}
|
|
26
|
+
interface DatasetTable {
|
|
27
|
+
type: "dataset";
|
|
28
|
+
as?: string;
|
|
29
|
+
datasetId: number;
|
|
30
|
+
join?: Join;
|
|
31
|
+
}
|
|
32
|
+
interface RawTable {
|
|
33
|
+
type: "raw_table";
|
|
34
|
+
as?: string;
|
|
35
|
+
nql: string;
|
|
36
|
+
join?: Join;
|
|
37
|
+
}
|
|
38
|
+
interface Join {
|
|
39
|
+
type: "join";
|
|
40
|
+
condition: BooleanExpression | Raw | null;
|
|
41
|
+
conditionType: ast.NqlJoinConditionType;
|
|
42
|
+
joinType: ast.NqlJoinType;
|
|
43
|
+
}
|
|
44
|
+
interface AttributeRef {
|
|
45
|
+
type: "attribute_ref";
|
|
46
|
+
as?: string;
|
|
47
|
+
name: string;
|
|
48
|
+
column: string;
|
|
49
|
+
}
|
|
50
|
+
interface DatasetColumnRef {
|
|
51
|
+
type: "dataset_column_ref";
|
|
52
|
+
as?: string;
|
|
53
|
+
column: string;
|
|
54
|
+
datasetId: number;
|
|
55
|
+
}
|
|
56
|
+
interface RawRef {
|
|
57
|
+
type: "raw_ref";
|
|
58
|
+
as?: string;
|
|
59
|
+
nql: string;
|
|
60
|
+
}
|
|
61
|
+
interface Lit {
|
|
62
|
+
type: "lit";
|
|
63
|
+
as?: string;
|
|
64
|
+
value_type: ast.NqlSimpleType;
|
|
65
|
+
value: string | null;
|
|
66
|
+
}
|
|
67
|
+
interface FunctionCall {
|
|
68
|
+
type: "function";
|
|
69
|
+
as?: string;
|
|
70
|
+
args: Expression[];
|
|
71
|
+
name: string;
|
|
72
|
+
}
|
|
73
|
+
interface Add {
|
|
74
|
+
type: "+";
|
|
75
|
+
as?: string;
|
|
76
|
+
operands: Expression[];
|
|
77
|
+
}
|
|
78
|
+
interface Divide {
|
|
79
|
+
type: "/";
|
|
80
|
+
as?: string;
|
|
81
|
+
operands: Expression[];
|
|
82
|
+
}
|
|
83
|
+
interface Multiply {
|
|
84
|
+
type: "*";
|
|
85
|
+
as?: string;
|
|
86
|
+
operands: Expression[];
|
|
87
|
+
}
|
|
88
|
+
interface Subtract {
|
|
89
|
+
type: "-";
|
|
90
|
+
as?: string;
|
|
91
|
+
operands: Expression[];
|
|
92
|
+
}
|
|
93
|
+
interface UnaryMinus {
|
|
94
|
+
type: "unary_-";
|
|
95
|
+
as?: string;
|
|
96
|
+
operand: Expression;
|
|
97
|
+
}
|
|
98
|
+
interface And {
|
|
99
|
+
type: "and";
|
|
100
|
+
as?: string;
|
|
101
|
+
operands: Expression[];
|
|
102
|
+
}
|
|
103
|
+
interface Or {
|
|
104
|
+
type: "or";
|
|
105
|
+
as?: string;
|
|
106
|
+
operands: Expression[];
|
|
107
|
+
}
|
|
108
|
+
interface Not {
|
|
109
|
+
type: "not";
|
|
110
|
+
as?: string;
|
|
111
|
+
operand: BooleanExpression | Raw;
|
|
112
|
+
}
|
|
113
|
+
/** Implicitly we only support asymmetric betweens. */
|
|
114
|
+
interface Between {
|
|
115
|
+
type: "between";
|
|
116
|
+
as?: string;
|
|
117
|
+
operand: Expression;
|
|
118
|
+
lower: Expression;
|
|
119
|
+
upper: Expression;
|
|
120
|
+
}
|
|
121
|
+
interface Equals {
|
|
122
|
+
type: "=";
|
|
123
|
+
as?: string;
|
|
124
|
+
left: Expression;
|
|
125
|
+
right: Expression;
|
|
126
|
+
}
|
|
127
|
+
interface NotEquals {
|
|
128
|
+
type: "<>";
|
|
129
|
+
as?: string;
|
|
130
|
+
left: Expression;
|
|
131
|
+
right: Expression;
|
|
132
|
+
}
|
|
133
|
+
interface Lt {
|
|
134
|
+
type: "<";
|
|
135
|
+
as?: string;
|
|
136
|
+
left: Expression;
|
|
137
|
+
right: Expression;
|
|
138
|
+
}
|
|
139
|
+
interface Lte {
|
|
140
|
+
type: "<=";
|
|
141
|
+
as?: string;
|
|
142
|
+
left: Expression;
|
|
143
|
+
right: Expression;
|
|
144
|
+
}
|
|
145
|
+
interface Gt {
|
|
146
|
+
type: ">";
|
|
147
|
+
as?: string;
|
|
148
|
+
left: Expression;
|
|
149
|
+
right: Expression;
|
|
150
|
+
}
|
|
151
|
+
interface Gte {
|
|
152
|
+
type: ">=";
|
|
153
|
+
as?: string;
|
|
154
|
+
left: Expression;
|
|
155
|
+
right: Expression;
|
|
156
|
+
}
|
|
157
|
+
interface In {
|
|
158
|
+
type: "in";
|
|
159
|
+
as?: string;
|
|
160
|
+
negated: boolean;
|
|
161
|
+
expression: Expression;
|
|
162
|
+
values: Expression[] | Raw;
|
|
163
|
+
}
|
|
164
|
+
interface IsNull {
|
|
165
|
+
type: "is_null";
|
|
166
|
+
as?: string;
|
|
167
|
+
negated: boolean;
|
|
168
|
+
operand: Expression;
|
|
169
|
+
}
|
|
170
|
+
interface Like {
|
|
171
|
+
type: "like";
|
|
172
|
+
as?: string;
|
|
173
|
+
negated: boolean;
|
|
174
|
+
value: Expression;
|
|
175
|
+
pattern: string;
|
|
176
|
+
}
|
|
177
|
+
interface Concat {
|
|
178
|
+
type: "||";
|
|
179
|
+
as?: string;
|
|
180
|
+
operands: Expression[];
|
|
181
|
+
}
|
|
182
|
+
export type { Expression, Raw, Select, Table };
|
|
183
|
+
export declare function parseSelect(n: ast.NqlSelect): Select;
|
|
184
|
+
export declare function parseFrom(n: ast.NqlAst): Table[];
|
|
185
|
+
export declare function parseWhere(n: ast.NqlAst): BooleanExpression | Raw;
|
|
186
|
+
export declare function parseExpression(n: ast.NqlAst): Expression;
|