Gathering detailed insights and metrics for @malloydata/malloy-query-builder
Gathering detailed insights and metrics for @malloydata/malloy-query-builder
Gathering detailed insights and metrics for @malloydata/malloy-query-builder
Gathering detailed insights and metrics for @malloydata/malloy-query-builder
Malloy is an experimental language for describing data relationships and transformations.
npm install @malloydata/malloy-query-builder
Typescript
Module System
Min. Node Version
Node Version
NPM Version
TypeScript (97.82%)
ANTLR (0.6%)
Thrift (0.39%)
Shell (0.33%)
CSS (0.28%)
JavaScript (0.26%)
Nearley (0.2%)
HTML (0.06%)
PEG.js (0.05%)
MDX (0.02%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
2,184 Stars
4,683 Commits
95 Forks
26 Watchers
310 Branches
49 Contributors
Updated on Jul 10, 2025
Latest Version
0.0.295
Package Id
@malloydata/malloy-query-builder@0.0.295
Unpacked Size
862.23 kB
Size
86.34 kB
File Count
24
NPM Version
10.8.2
Node Version
20.19.3
Published on
Jul 10, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
3
Get started with the {@link ASTQuery} class.
{@link ASTQuery.toMalloy}
1query.setSource('flights'); 2query.setView('by_carrier'); 3query.toMalloy();
run: flights -> by_carrier
This is for the Explorer, e.g., to create the query summary UI
{@link ASTQuery.getOrAddDefaultSegment}
1query.setSource('flights'); 2query.getOrAddDefaultSegment().addGroupBy("carrier");
run: flights -> { group_by: carrier }
{@link ASTQuery.setViewToEmptySegment}
1query.setSource('flights'); 2query.setViewToEmptySegment().addGroupBy("carrier");
run: flights -> { group_by: carrier }
{@link ASTQuery.setView}
1query.setSource('flights'); 2query.setView('by_carrier');
run: flights -> by_carrier
{@link ASTSegmentViewDefinition.isRunnable}
run: flights -> { }
1query.isRunnable() // false
{@link ASTSegmentViewDefinition.addGroupBy} {@link ASTSegmentViewDefinition.addAggregate} {@link ASTSegmentViewDefinition.addNest}
1const segment = query.getOrAddDefaultSegment(); 2segment.addGroupBy('carrier'); 3segment.addAggregate('flight_count'); 4segment.addNest('by_origin');
run: flights -> {
group_by: carrier
aggregate: flight_count
nest: by_origin
}
{@link ASTSegmentViewDefinition.addDateGroupBy} {@link ASTSegmentViewDefinition.addTimestampGroupBy}
1const segment = query.getOrAddDefaultSegment(); 2segment.addTimestampGroupBy('dep_time', 'month');
run: flights -> {
group_by: dep_time.month
}
{@link ASTGroupByViewOperation.delete} {@link ASTAggregateViewOperation.delete} {@link ASTNestViewOperation.delete} {@link ASTGroupByViewOperation.rename} {@link ASTAggregateViewOperation.rename} {@link ASTNestViewOperation.rename}
run: flights -> {
group_by: carrier
aggregate: flight_count
}
1groupBy.delete(); 2aggregate.rename("flight_count_2");
run: flights -> { aggregate: flight_count_2 is flight_count }
{@link ASTSegmentViewDefinition.hasField}
1query.getOrAddDefaultSegment().hasField('carrier');
{@link ASTOrderByViewOperation.delete}
run: flights -> {
group_by: carrier
order_by: carrier desc
}
1orderBy.delete();
run: flights -> { group_by: carrier }
{@link ASTOrderByViewOperation.setField}
run: flights -> {
group_by:
carrier
flight_count
order_by: carrier desc
}
1orderBy.setField("flight_count");
run: flights -> {
group_by:
carrier
flight_count
order_by: flight_count desc
}
{@link ASTOrderByViewOperation.setDirection}
run: flights -> {
group_by: carrier
order_by: carrier desc
}
1orderBy.setDirection(Malloy.OrderByDirection.ASC);
run: flights -> {
group_by: carrier
order_by: flight_count asc
}
1query.getOrAddDefaultSegment().addWhere("carrier", "WN, AA");
run: flights -> { where: carrier ~ f`WN, AA` }
1query.getOrAddDefaultSegment().setLimit(10);
run: flights -> { limit: 10 }
{@link ASTSegmentViewDefinition.addEmptyNest}
1query.getOrAddDefaultSegment().addEmptyNest("by_origin");
run: flights -> { nest: by_origin is { } }
{@link ASTSegmentViewDefinition.getInputSchema}
1query.getOrAddDefaultSegment().getInputSchema();
{
fields: [
{ kind: "measure", name: "flight_count", type: { kind: "string_type" }}
...
]
}
{@link IASTViewDefinition.addEmptyRefinement}
1const view = query.setView("by_carrier"); 2const segment = view.addEmptyRefinement(); 3segment.setLimit(10);
run: flights -> by_carrier + { limit: 10 }
{@link IASTViewDefinition.addViewRefinement}
1const view = query.setView("by_carrier"); 2view.addViewRefinement("top10");
run: flights -> by_carrier + top10
{@link ASTQuery.reorderFields} {@link ASTView.reorderFields}
If the view or query is a simple segment, it will automatically reorder the clauses.
run: flights -> {
group_by: carrier
aggregate: flight_count
}
1query.reorderFields(['flight_count', 'carrier']);
run: flights -> {
aggregate: flight_count
group_by: carrier
}
Otherwise, it will add an annotation:
run: flights -> by_carrier
1query.reorderFields(['flight_count', 'carrier']);
# field_order = [flight_count, carrier]
run: flights -> by_carrier
1query.getOrAddDefaultSegment().addAggregate('flight_count').addWhere('carrier', 'WN, AA');
run: flights -> { aggregate: flight_count { where: carrier ~ f`WN, AA`} }
{@link ASTReferenceQueryArrowSource.setParameter}
1query.definition.as.ArrowQueryDefinition().source.as.ReferenceQueryArrowSource().parameters.setParameter("param", 1)
run: flights(param is 1) ->
{@link ASTReferenceQueryArrowSource.getSourceParameters}
1query.definition.as.ArrowQueryDefinition().source.as.ReferenceQueryArrowSource().getSourceParameters();
{@link IASTAnnotatable.setTagProperty} {@link IASTAnnotatable.removeTagProperty}
1query 2 .getOrAddDefaultSegment() 3 .addGroupBy('carrier'); 4 .setTagProperty(['a', 'b', 'c'], 10);
run: flights -> {
# a.b.c = 10
group_by: carrier
}
1// Assume that 'by_carrier' has, in the model, a tag "bar_chart" 2query 3 .getOrAddDefaultSegment() 4 .addNest('by_carrier'); 5 .removeTagProperty(['bar_chart']);
run: flights -> {
# -bar_chart
nest: by_carrier
}
{@link IASTAnnotatable.getIntrinsicTag} {@link IASTAnnotatable.getInheritedTag}
1query 2 .getOrAddDefaultSegment() 3 .addGroupBy('carrier'); 4 .getIntrinsicTag() 5 .has('some_tag'); 6query 7 .getOrAddDefaultSegment() 8 .addGroupBy('carrier'); 9 .getInheritedTag() 10 .has('some_tag');
1query.setTagProperty(['bar_chart']); 2query.setSource('flights'); 3query.setView('by_carrier');
# bar_chart
run: flights -> by_carrier
This is only ever a partial validation: cube resolution, aggregate validation, and expression validation (and possibly other validation) must happen in the translator, and will not be replicated in the QueryBuilder We will do as much validation as we can do, but it is possible some queries will only generate errors when you do a full translation (probably when you run it)
This happens automatically when you call {@link ASTSegmentViewDefinition.addGroupBy}, {@link ASTSegmentViewDefinition.addAggregate}, {@link ASTSegmentViewDefinition.addNest}, {@link ASTSegmentViewDefinition.addWhere}, {@link ASTSegmentViewDefinition.addOrderBy}, {@link ASTSegmentViewDefinition.setLimit}, etc..
{@link ASTQuery.getOrAddDefaultSegment}
1query.setSource('flights'); 2query.getOrAddDefaultSegment().addGroupBy("carrier");
run: flights -> { group_by: carrier }
run: flights -> by_carrier
1query.setSource('flights'); 2query.getOrAddDefaultSegment().setLimit(10);
run: flights -> by_carrier + { limit: 10 }
No vulnerabilities found.
Reason
30 commit(s) and 8 issue activity found in the last 90 days -- score normalized to 10
Reason
GitHub workflow tokens follow principle of least privilege
Details
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
no binaries found in the repo
Reason
SAST tool is not run on all commits -- score normalized to 9
Details
Reason
dependency not pinned by hash detected -- score normalized to 6
Details
Reason
5 existing vulnerabilities detected
Details
Reason
Found 3/19 approved changesets -- score normalized to 1
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More