@malloydata/malloy-query-builder 0.0.240-dev250311202829 → 0.0.240-dev250311214430
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 +4 -4
- package/dist/query-ast.d.ts +60 -29
- package/dist/query-ast.js +197 -99
- package/dist/query-ast.js.map +1 -1
- package/dist/query-ast.spec.js +280 -74
- package/dist/query-ast.spec.js.map +1 -1
- package/flow/query-ast.d.ts +62 -24
- package/package.json +4 -4
- package/src/query-ast.spec.ts +280 -74
- package/src/query-ast.ts +249 -111
package/README.md
CHANGED
|
@@ -325,10 +325,10 @@ run: flights -> { aggregate: flight_count { where: carrier ~ f`WN, AA`} }
|
|
|
325
325
|
|
|
326
326
|
## Specify or remove source parameter value
|
|
327
327
|
|
|
328
|
-
{@link
|
|
328
|
+
{@link ASTReferenceQueryArrowSource.setParameter}
|
|
329
329
|
|
|
330
330
|
```ts
|
|
331
|
-
query.definition.
|
|
331
|
+
query.definition.as.ArrowQueryDefinition().source.as.ReferenceQueryArrowSource().parameters.setParameter("param", 1)
|
|
332
332
|
```
|
|
333
333
|
```
|
|
334
334
|
run: flights(param is 1) ->
|
|
@@ -336,10 +336,10 @@ run: flights(param is 1) ->
|
|
|
336
336
|
|
|
337
337
|
## List parameters of the source and whether they are required
|
|
338
338
|
|
|
339
|
-
{@link
|
|
339
|
+
{@link ASTReferenceQueryArrowSource.getSourceParameters}
|
|
340
340
|
|
|
341
341
|
```ts
|
|
342
|
-
query.definition.
|
|
342
|
+
query.definition.as.ArrowQueryDefinition().source.as.ReferenceQueryArrowSource().getSourceParameters();
|
|
343
343
|
```
|
|
344
344
|
|
|
345
345
|
## To a particular field in the query (including nests), add/edit/delete annotation
|
package/dist/query-ast.d.ts
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import * as Malloy from '@malloydata/malloy-interfaces';
|
|
2
2
|
import { Tag, TagSetValue } from '@malloydata/malloy-tag';
|
|
3
3
|
import * as Filter from '@malloydata/malloy-filter';
|
|
4
|
+
export type FilterType = 'string' | 'boolean' | 'number' | 'temporal';
|
|
4
5
|
export type ParsedFilter = {
|
|
5
6
|
kind: 'string';
|
|
6
|
-
|
|
7
|
+
parsed: Filter.StringClause | null;
|
|
7
8
|
} | {
|
|
8
9
|
kind: 'number';
|
|
9
|
-
|
|
10
|
+
parsed: Filter.NumberClause | null;
|
|
10
11
|
} | {
|
|
11
12
|
kind: 'boolean';
|
|
12
|
-
|
|
13
|
+
parsed: Filter.BooleanClause | null;
|
|
13
14
|
} | {
|
|
14
|
-
kind: '
|
|
15
|
-
|
|
15
|
+
kind: 'temporal';
|
|
16
|
+
parsed: Filter.TemporalClause | null;
|
|
16
17
|
};
|
|
17
18
|
export type PathSegment = number | string;
|
|
18
19
|
export type Path = PathSegment[];
|
|
@@ -43,7 +44,7 @@ declare abstract class ASTNode<T> {
|
|
|
43
44
|
get as(): {
|
|
44
45
|
Query(): ASTQuery;
|
|
45
46
|
Reference(): ASTReference;
|
|
46
|
-
|
|
47
|
+
ReferenceQueryArrowSource(): ASTReferenceQueryArrowSource;
|
|
47
48
|
ParameterValueList(): ASTParameterValueList;
|
|
48
49
|
Where(): ASTWhere;
|
|
49
50
|
WhereList(): ASTWhereList;
|
|
@@ -72,7 +73,7 @@ declare abstract class ASTNode<T> {
|
|
|
72
73
|
get find(): {
|
|
73
74
|
Query(path: Path): ASTQuery;
|
|
74
75
|
Reference(path: Path): ASTReference;
|
|
75
|
-
|
|
76
|
+
ReferenceQueryArrowSource(path: Path): ASTReferenceQueryArrowSource;
|
|
76
77
|
ParameterValueList(path: Path): ASTParameterValueList;
|
|
77
78
|
Where(path: Path): ASTWhere;
|
|
78
79
|
WhereList(path: Path): ASTWhereList;
|
|
@@ -234,6 +235,7 @@ export declare class ASTQuery extends ASTObjectNode<Malloy.Query, {
|
|
|
234
235
|
removeTagProperty(path: Path, prefix?: string): void;
|
|
235
236
|
setViewToEmptySegment(): ASTSegmentViewDefinition;
|
|
236
237
|
isRunnable(): boolean;
|
|
238
|
+
isEmpty(): boolean;
|
|
237
239
|
/**
|
|
238
240
|
* Gets an {@link ASTSegmentViewDefinition} for the "default" place to add query
|
|
239
241
|
* operations, or creates one if it doesn't exist.
|
|
@@ -328,6 +330,7 @@ export declare class ASTQuery extends ASTObjectNode<Malloy.Query, {
|
|
|
328
330
|
* @param name The name of the view to set as the head of the query pipeline
|
|
329
331
|
*/
|
|
330
332
|
setView(name: string): ASTReferenceViewDefinition;
|
|
333
|
+
private _getInheritedAnnotations;
|
|
331
334
|
getInheritedAnnotations(): Malloy.Annotation[];
|
|
332
335
|
}
|
|
333
336
|
export type RawLiteralValue = number | string | {
|
|
@@ -391,20 +394,6 @@ export declare class ASTFieldReference extends ASTReference {
|
|
|
391
394
|
private getReferenceSchema;
|
|
392
395
|
getFieldInfo(): Malloy.FieldInfo;
|
|
393
396
|
}
|
|
394
|
-
export declare class ASTSourceReference extends ASTReference {
|
|
395
|
-
/**
|
|
396
|
-
* @internal
|
|
397
|
-
*/
|
|
398
|
-
get query(): ASTQuery;
|
|
399
|
-
/**
|
|
400
|
-
* Gets the `Malloy.SourceInfo` for the referenced source
|
|
401
|
-
*
|
|
402
|
-
* @returns The source information for the referenced source
|
|
403
|
-
*/
|
|
404
|
-
getSourceInfo(): Malloy.SourceInfo;
|
|
405
|
-
getSourceParameters(): Malloy.ParameterInfo[];
|
|
406
|
-
areRequiredParametersSet(): boolean;
|
|
407
|
-
}
|
|
408
397
|
export declare class ASTParameterValueList extends ASTListNode<Malloy.ParameterValue, ASTParameterValue> {
|
|
409
398
|
constructor(parameters: Malloy.ParameterValue[]);
|
|
410
399
|
get parameters(): ASTParameterValue[];
|
|
@@ -497,22 +486,27 @@ export interface IASTQueryDefinition extends IASTQueryOrViewDefinition {
|
|
|
497
486
|
reorderFields(names: string[]): void;
|
|
498
487
|
isRunnable(): boolean;
|
|
499
488
|
}
|
|
489
|
+
export type ASTQueryArrowSource = ASTReferenceQueryArrowSource | ASTRefinementQueryDefinition;
|
|
490
|
+
export declare const ASTQueryArrowSource: {
|
|
491
|
+
from(definition: Malloy.QueryArrowSource): ASTReferenceQueryArrowSource | ASTRefinementQueryDefinition;
|
|
492
|
+
};
|
|
500
493
|
export type ASTQueryDefinition = ASTReferenceQueryDefinition | ASTArrowQueryDefinition | ASTRefinementQueryDefinition;
|
|
501
494
|
export declare const ASTQueryDefinition: {
|
|
502
|
-
from
|
|
495
|
+
from(definition: Malloy.QueryDefinition): ASTArrowQueryDefinition | ASTReferenceQueryDefinition | ASTRefinementQueryDefinition;
|
|
503
496
|
};
|
|
504
497
|
export declare class ASTArrowQueryDefinition extends ASTObjectNode<Malloy.QueryDefinitionWithArrow, {
|
|
505
498
|
kind: 'arrow';
|
|
506
|
-
|
|
499
|
+
source: ASTQueryArrowSource;
|
|
507
500
|
view: ASTViewDefinition;
|
|
508
501
|
}> implements IASTQueryDefinition {
|
|
509
502
|
node: Malloy.QueryDefinitionWithArrow;
|
|
510
503
|
constructor(node: Malloy.QueryDefinitionWithArrow);
|
|
511
504
|
get view(): ASTViewDefinition;
|
|
512
505
|
set view(view: ASTViewDefinition);
|
|
513
|
-
get
|
|
506
|
+
get source(): ASTQueryArrowSource;
|
|
507
|
+
set source(source: ASTQueryArrowSource);
|
|
514
508
|
getOrAddDefaultSegment(): ASTSegmentViewDefinition;
|
|
515
|
-
getSourceInfo():
|
|
509
|
+
getSourceInfo(): any;
|
|
516
510
|
getOutputSchema(): Malloy.Schema;
|
|
517
511
|
isRunnable(): boolean;
|
|
518
512
|
/**
|
|
@@ -531,12 +525,12 @@ export declare class ASTArrowQueryDefinition extends ASTObjectNode<Malloy.QueryD
|
|
|
531
525
|
}
|
|
532
526
|
export declare class ASTRefinementQueryDefinition extends ASTObjectNode<Malloy.QueryDefinitionWithRefinement, {
|
|
533
527
|
kind: 'refinement';
|
|
534
|
-
|
|
528
|
+
base: ASTQueryDefinition;
|
|
535
529
|
refinement: ASTViewDefinition;
|
|
536
530
|
}> implements IASTQueryDefinition {
|
|
537
531
|
node: Malloy.QueryDefinitionWithRefinement;
|
|
538
532
|
constructor(node: Malloy.QueryDefinitionWithRefinement);
|
|
539
|
-
get
|
|
533
|
+
get base(): ASTQueryDefinition;
|
|
540
534
|
get refinement(): ASTViewDefinition;
|
|
541
535
|
set refinement(refinement: ASTViewDefinition);
|
|
542
536
|
isRunnable(): boolean;
|
|
@@ -545,7 +539,7 @@ export declare class ASTRefinementQueryDefinition extends ASTObjectNode<Malloy.Q
|
|
|
545
539
|
*/
|
|
546
540
|
get query(): ASTQuery;
|
|
547
541
|
getOrAddDefaultSegment(): ASTSegmentViewDefinition;
|
|
548
|
-
getOutputSchema():
|
|
542
|
+
getOutputSchema(): any;
|
|
549
543
|
/**
|
|
550
544
|
* @internal
|
|
551
545
|
*/
|
|
@@ -555,6 +549,7 @@ export declare class ASTRefinementQueryDefinition extends ASTObjectNode<Malloy.Q
|
|
|
555
549
|
*/
|
|
556
550
|
propagateDown(f: PropagationFunction): void;
|
|
557
551
|
reorderFields(names: string[]): void;
|
|
552
|
+
getSourceInfo(): any;
|
|
558
553
|
}
|
|
559
554
|
export declare class ASTReferenceQueryDefinition extends ASTObjectNode<Malloy.QueryDefinitionWithQueryReference, {
|
|
560
555
|
kind: 'query_reference';
|
|
@@ -583,6 +578,42 @@ export declare class ASTReferenceQueryDefinition extends ASTObjectNode<Malloy.Qu
|
|
|
583
578
|
getOrAddParameters(): any;
|
|
584
579
|
setParameter(name: string, value: RawLiteralValue): void;
|
|
585
580
|
tryGetParameter(name: string): ASTParameterValue | undefined;
|
|
581
|
+
getOutputSchema(): Malloy.Schema;
|
|
582
|
+
getSourceInfo(): Malloy.ModelEntryValue;
|
|
583
|
+
}
|
|
584
|
+
export declare class ASTReferenceQueryArrowSource extends ASTObjectNode<Malloy.QueryArrowSourceWithSourceReference, {
|
|
585
|
+
kind: 'source_reference';
|
|
586
|
+
name: string;
|
|
587
|
+
path?: string[];
|
|
588
|
+
parameters?: ASTParameterValueList;
|
|
589
|
+
}> implements IASTReference {
|
|
590
|
+
node: Malloy.QueryArrowSourceWithSourceReference;
|
|
591
|
+
constructor(node: Malloy.QueryArrowSourceWithSourceReference);
|
|
592
|
+
isRunnable(): boolean;
|
|
593
|
+
get name(): string;
|
|
594
|
+
get arrow(): ASTArrowQueryDefinition;
|
|
595
|
+
get parameters(): ASTParameterValueList | undefined;
|
|
596
|
+
set parameters(parameters: ASTParameterValueList | undefined);
|
|
597
|
+
get path(): string[] | undefined;
|
|
598
|
+
getSourceInfo(): Malloy.ModelEntryValue;
|
|
599
|
+
getOrAddDefaultSegment(): ASTSegmentViewDefinition;
|
|
600
|
+
/**
|
|
601
|
+
* @internal
|
|
602
|
+
*/
|
|
603
|
+
propagateUp(_f: PropagationFunction): void;
|
|
604
|
+
/**
|
|
605
|
+
* @internal
|
|
606
|
+
*/
|
|
607
|
+
propagateDown(_f: PropagationFunction): void;
|
|
608
|
+
getOrAddParameters(): any;
|
|
609
|
+
setParameter(name: string, value: RawLiteralValue): void;
|
|
610
|
+
tryGetParameter(name: string): ASTParameterValue | undefined;
|
|
611
|
+
/**
|
|
612
|
+
* @internal
|
|
613
|
+
*/
|
|
614
|
+
get query(): ASTQuery;
|
|
615
|
+
getSourceParameters(): Malloy.ParameterInfo[];
|
|
616
|
+
areRequiredParametersSet(): boolean;
|
|
586
617
|
}
|
|
587
618
|
export interface IASTViewDefinition extends IASTQueryOrViewDefinition {
|
|
588
619
|
isRunnable(): boolean;
|
|
@@ -1357,7 +1388,7 @@ export declare class ASTFilterWithFilterString extends ASTObjectNode<Malloy.Filt
|
|
|
1357
1388
|
set filterString(filter: string);
|
|
1358
1389
|
setFilterString(filterString: string): void;
|
|
1359
1390
|
getFieldInfo(): Malloy.FieldInfoWithDimension | Malloy.FieldInfoWithMeasure;
|
|
1360
|
-
getFilterType():
|
|
1391
|
+
getFilterType(): FilterType | 'other';
|
|
1361
1392
|
setFilter(filter: ParsedFilter): void;
|
|
1362
1393
|
getFilter(): ParsedFilter;
|
|
1363
1394
|
}
|