@malloydata/cli 0.0.54-next.2026.5.7.d30df35 → 0.0.55
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/dist/index.js
CHANGED
|
@@ -492,6 +492,56 @@ query: recent_orders is orders_for_user -> {
|
|
|
492
492
|
|
|
493
493
|
`$` appears *only* at expression references. The other three sites where a given's name appears — declaration, import, and supply (caller side) — use the bare name, because syntactic position already disambiguates. Givens share the top-level declaration namespace with sources/queries/views, so `source: x is ...` plus `given: x :: string` is a name-conflict error.
|
|
494
494
|
|
|
495
|
+
### Set membership: `expr in $arrayGiven`
|
|
496
|
+
|
|
497
|
+
The RHS of `in` is either a parenthesized list of expressions (`in (1, 2, x, y * 7)`, same as SQL) or a given with an array value (`in $ARR`). A bare array-typed expression — a dimension, a joined array field, an inline `[a, b, c]` literal — is *not* legal on the RHS; arrays only reach the RHS via the given form.
|
|
498
|
+
|
|
499
|
+
When a given has array type, `expr in $ARR` tests `expr` against the runtime-bound array; `not in $ARR` is the negation. The left-hand side must match the array's element type (`string in $string[]`, `number in $number[]`, etc.); mismatches are translate-time errors. Records and nested arrays are out of scope.
|
|
500
|
+
|
|
501
|
+
```malloy
|
|
502
|
+
given:
|
|
503
|
+
ALLOWED_STATES :: string[]
|
|
504
|
+
URGENT_STATUSES :: string[]
|
|
505
|
+
|
|
506
|
+
source: orders extend {
|
|
507
|
+
where: state in $ALLOWED_STATES
|
|
508
|
+
dimension: is_urgent is order_status in $URGENT_STATUSES
|
|
509
|
+
}
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
At SQL emit, the array's contents land in a generated `IN (...)` clause. Empty or `null` arrays collapse to the obvious result (`IN` → `FALSE`, `NOT IN` → `TRUE`). NULL elements inside a non-empty array follow standard SQL `IN` semantics.
|
|
513
|
+
|
|
514
|
+
To derive a value from an array — typically a boolean gate — *without* the array itself reaching row-position SQL, use an inline given (below).
|
|
515
|
+
|
|
516
|
+
### Inline givens
|
|
517
|
+
|
|
518
|
+
An `inline` given is evaluated at **bind time**, before SQL is emitted: its default expression runs against the resolved given values and reduces to a literal, and that literal is what reaches SQL.
|
|
519
|
+
|
|
520
|
+
```malloy
|
|
521
|
+
given:
|
|
522
|
+
CAPABILITIES :: string[]
|
|
523
|
+
inline CAN_READ_ORDERS :: boolean is 'read_orders' in $CAPABILITIES
|
|
524
|
+
inline CAN_MUTATE :: boolean
|
|
525
|
+
is 'write_orders' in $CAPABILITIES or 'admin' in $CAPABILITIES
|
|
526
|
+
|
|
527
|
+
source: orders extend {
|
|
528
|
+
where: $CAN_READ_ORDERS -- SQL sees: WHERE ... AND TRUE (or FALSE)
|
|
529
|
+
}
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
This is the **row-level access-control gate** pattern: the host supplies a capability list as a regular given, an inline given derives a boolean from it, and only the boolean — not the list — crosses into row-position SQL. The query planner sees a constant predicate.
|
|
533
|
+
|
|
534
|
+
Rules:
|
|
535
|
+
|
|
536
|
+
- An inline given **must** have a default. `inline FOO :: number` with no `is` clause is a translate-time error.
|
|
537
|
+
- The default may use:
|
|
538
|
+
- Boolean and comparison operators: `and`, `or`, `not`, `=`, `!=`, `<`, `<=`, `>`, `>=`
|
|
539
|
+
- The `in $array` test against another given
|
|
540
|
+
- Literals (string, number, boolean, null, array) and references to other givens
|
|
541
|
+
- The default cannot call SQL functions, reference fields, or use any operator outside that list. Disallowed operators are reported at translate time with the offending operator names.
|
|
542
|
+
- Inline givens are filtered out of `Model.givens` and `PreparedQuery.givens` — they're computed, not supplied — so introspection-driven UIs don't render editors for them. A caller can still shadow one by binding it explicitly (useful in tests).
|
|
543
|
+
- `inline` is a context-sensitive modifier, not a reserved keyword: fields, sources, views, dimensions, and joins can still be named `inline`.
|
|
544
|
+
|
|
495
545
|
### Imports
|
|
496
546
|
|
|
497
547
|
Givens behave like every other top-level named thing under import:
|
|
@@ -94,6 +94,10 @@ Givens are model-level parameters (`given: TENANT :: string`, referenced as `$TE
|
|
|
94
94
|
|
|
95
95
|
A given with a default is optional in the `givens` map. A given without a default must be supplied or the run fails with a missing-given error.
|
|
96
96
|
|
|
97
|
+
**Inline givens** (declared `inline NAME :: T is …`) are evaluated at bind time and don't take supplied values, so they are filtered out of `model.givens[]` and the per-run `givens[]` lists. If you see `$X` referenced in source but missing from introspection, it's an inline.
|
|
98
|
+
|
|
99
|
+
**Array givens with `in`.** The RHS of `in` is either a parenthesized list of expressions (`in (1, 2, x, y * 7)`, as in SQL) or a given with an array value (`in $ARR`). Use the given form (`where: state in $ALLOWED_STATES`) when the values come from outside the model — bare array expressions (a dimension, joined field, `[a, b, c]` literal) are not legal on the RHS.
|
|
100
|
+
|
|
97
101
|
## Before writing non-trivial Malloy
|
|
98
102
|
|
|
99
103
|
Pull the `malloy-language-reference` prompt first. The language has real scoping and typing rules that the compiler will enforce; don't guess.
|
|
@@ -34346,7 +34346,7 @@ SOFTWARE.
|
|
|
34346
34346
|
-------
|
|
34347
34347
|
Package: @databricks/sql
|
|
34348
34348
|
Url: https://github.com/databricks/databricks-sql-nodejs#readme
|
|
34349
|
-
License(s): Apache
|
|
34349
|
+
License(s): Apache-2.0
|
|
34350
34350
|
License Text:
|
|
34351
34351
|
Apache License
|
|
34352
34352
|
Version 2.0, January 2004
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloydata/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.55",
|
|
4
4
|
"description": "Malloy CLI",
|
|
5
5
|
"bin": {
|
|
6
6
|
"malloy-cli": "dist/index.js",
|
|
@@ -72,14 +72,14 @@
|
|
|
72
72
|
"@commander-js/extra-typings": "^12.1.0",
|
|
73
73
|
"@duckdb/node-api": "1.4.4-r.1",
|
|
74
74
|
"@duckdb/node-bindings": "1.4.4-r.1",
|
|
75
|
-
"@malloydata/db-bigquery": "0.0.
|
|
76
|
-
"@malloydata/db-duckdb": "0.0.
|
|
77
|
-
"@malloydata/db-postgres": "0.0.
|
|
78
|
-
"@malloydata/db-snowflake": "0.0.
|
|
79
|
-
"@malloydata/db-trino": "0.0.
|
|
80
|
-
"@malloydata/malloy": "0.0.
|
|
81
|
-
"@malloydata/malloy-connections": "0.0.
|
|
82
|
-
"@malloydata/malloy-sql": "0.0.
|
|
75
|
+
"@malloydata/db-bigquery": "0.0.402",
|
|
76
|
+
"@malloydata/db-duckdb": "0.0.402",
|
|
77
|
+
"@malloydata/db-postgres": "0.0.402",
|
|
78
|
+
"@malloydata/db-snowflake": "0.0.402",
|
|
79
|
+
"@malloydata/db-trino": "0.0.402",
|
|
80
|
+
"@malloydata/malloy": "0.0.402",
|
|
81
|
+
"@malloydata/malloy-connections": "0.0.402",
|
|
82
|
+
"@malloydata/malloy-sql": "0.0.402",
|
|
83
83
|
"@types/jest": "^29.2.5",
|
|
84
84
|
"@types/node": "^14.11.2",
|
|
85
85
|
"@typescript-eslint/eslint-plugin": "^5.48.2",
|