Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
d049f1a
dax: crate scaffolding, README and workspace wiring (#2228)
alosslessdev Nov 5, 2026
4f65003
dax: lexer, Pratt parser, AST, canonical printer and query statements…
alosslessdev Nov 5, 2026
5c0e27c
dax: function catalog for every dax.guide category (#2228)
alosslessdev Nov 5, 2026
a89acaa
dax: static types, binder and call validation (#2228)
alosslessdev Nov 5, 2026
81a593d
dax: scalar values, columnar storage, evaluator framework and scalar …
alosslessdev Nov 5, 2026
a7abdde
dax: evaluator, storage and pivot test suites (#2228)
alosslessdev Nov 5, 2026
4ff7407
dax: keep the SUMMARIZE subtotal row context beside the evaluator's o…
alosslessdev Nov 5, 2026
faab395
dax: align the README and validate docs with the implemented surface …
alosslessdev Nov 5, 2026
4e2fe32
dax: find relationship cycles that close through a bidirectional reve…
alosslessdev Nov 5, 2026
c24fe0d
dax: bind every documented CROSSFILTER direction and RANK reset keywo…
alosslessdev Nov 5, 2026
40350ba
dax: fix the evaluator core's rounding, aggregation types, blank memb…
alosslessdev Nov 5, 2026
eebfbf5
dax: give each evaluator family its own registry marker line (#2228)
alosslessdev Nov 5, 2026
7332a12
dax: follow DAX equality and the documented CROSSFILTER contract (#2228)
alosslessdev Nov 5, 2026
5a73c66
dax: fold text in filter matching and harden keywords, months and piv…
alosslessdev Nov 5, 2026
21212be
Merge remote-tracking branch 'upstream/main' into coreL3406
alosslessdev Nov 5, 2026
d1cc151
dax: bind the documented ASC/DESC slots of RANK.EQ, TOPNSKIP, SAMPLE …
alosslessdev Nov 5, 2026
3f5c55a
dax: join numeric keys by value in strict equality (#2228)
alosslessdev Nov 5, 2026
934561c
dax: make the README example compile as Rust and drop the CLI sentenc…
alosslessdev Nov 5, 2026
e96107d
dax: keep exact whole inputs, folded groups and exact relationship ke…
alosslessdev Nov 5, 2026
9e74972
dax: let a large numeric key match itself in strict equality (#2228)
alosslessdev Nov 5, 2026
6dbb9e3
dax: take the pivot, integrity and functions-reference files into the…
alosslessdev Nov 5, 2026
278f95e
dax: replay the umbrella's hop index, blank-key orphan rule and CONCA…
alosslessdev Nov 5, 2026
5e1b519
dax: carry the grouping scope, read integer columns exactly and put I…
alosslessdev Nov 5, 2026
292f0a3
dax: bind every repeated order pair of SAMPLE and TOPNSKIP (#2228)
alosslessdev Nov 5, 2026
c37fa6a
dax: read the browser clock for NOW/TODAY on wasm (#2228)
alosslessdev Nov 5, 2026
f00e1da
dax: document the variable index and look through VAR/RETURN in opera…
alosslessdev Nov 5, 2026
14916f6
dax: drop the unused manifest dependency and align the pivot filter d…
alosslessdev Nov 5, 2026
2af770d
dax: document IN at the comparison tier (#2228)
alosslessdev Nov 5, 2026
d24deba
dax: give families a per-evaluation memo slot and state the CUSTOMDAT…
alosslessdev Nov 5, 2026
a8e8bd7
dax: normalize numeric relationship joins, scope keyword shadowing an…
alosslessdev Nov 5, 2026
707cbc0
dax: compare same-variant integers exactly (#2228)
alosslessdev Nov 5, 2026
b4c8238
dax: count every non-blank value in the implicit Count measure (#2228)
alosslessdev Nov 5, 2026
88717cd
dax: compare integers exactly across variants and keep DATATABLE type…
alosslessdev Nov 5, 2026
b3e2543
dax: normalize numeric keys in propagation, integrity and hop lookups…
alosslessdev Nov 5, 2026
39ece86
dax: keep NaN and inexact currency keys out of the normalized join (#…
alosslessdev Nov 5, 2026
10a2c02
dax: exclude NaN keys from joins and apply the currency rule to stric…
alosslessdev Nov 5, 2026
c040089
dax: clear NAMEOF's volatile flag, infer Pow as Decimal and widen the…
alosslessdev Nov 5, 2026
68389e8
dax: report NaN foreign keys as orphans and name the supported ALL fu…
alosslessdev Nov 5, 2026
581b085
dax: make exponentiation left-associative like every DAX operator (#2…
alosslessdev Nov 5, 2026
6f96571
dax: keep non-finite finding keys JSON-safe and count NaN foreign key…
alosslessdev Nov 5, 2026
0f074e4
dax: note that Excel agrees on left-associative exponentiation (#2228)
alosslessdev Nov 5, 2026
682d777
dax: count nonblank dimension NaN keys in the integrity report (#2228)
alosslessdev Nov 5, 2026
a8b9913
dax: give CONTAINSROW evaluable documented examples (#2228)
alosslessdev Nov 5, 2026
1198e1d
dax: state the valid WEEKNUM codes and name the real pivot remedy (#2…
alosslessdev Nov 5, 2026
8662072
Merge remote-tracking branch 'upstream/main' into coreL3406
alosslessdev Nov 5, 2026
94bdc71
dax: fold numeric variants in filter and distinct keys, and guard non…
alosslessdev Nov 5, 2026
0ade51f
dax: keep filter keys in their own variant and fold at comparison (#2…
alosslessdev Nov 5, 2026
2464b4f
dax: intersect filters and narrow pivot cells under folded equality (…
alosslessdev Nov 5, 2026
ccb757d
dax: align the storage and functions-reference docs with the typed ag…
alosslessdev Nov 5, 2026
f9921b9
dax: blank a repeated Outline label under folded equality (#2228)
alosslessdev Nov 5, 2026
9fab68f
dax: list exponentiation as left-associative in the operator table (#…
alosslessdev Nov 5, 2026
77c6bfb
Merge remote-tracking branch 'upstream/main' into coreL3406
alosslessdev Nov 5, 2026
98d7238
dax: document the flat-chain depth limit and clear the wrong sugar li…
alosslessdev Nov 5, 2026
f94413a
dax: answer the alphabetical extremum for MIN/MAX over a text column …
alosslessdev Nov 6, 2026
1c2d4ce
dax: drop the stale DISTINCTCOUNTNOBLANK sugar row from the README (#…
alosslessdev Nov 6, 2026
3334512
dax: derive singletons from the visible column and skip NaN extrema (…
alosslessdev Nov 6, 2026
4c2257b
dax: qualify the DISTINCTCOUNTNOBLANK Excel claim and use the storage…
alosslessdev Nov 6, 2026
7904742
dax: validate a measure's home table while parsing the model (#2228)
alosslessdev Nov 7, 2026
62abd0e
dax: validate pivot fields before grouping so empty tables report mis…
alosslessdev Nov 7, 2026
415c715
dax: format Currency text from the exact scaled integer (#2228)
alosslessdev Nov 7, 2026
3769d34
dax: skip NaN candidates in the storage extremum scan (#2228)
alosslessdev Nov 8, 2026
40bfb1b
dax: keep a variable from shadowing the documented interval keywords …
alosslessdev Nov 8, 2026
c32aac3
dax: print negative zero as zero in DAX text (#2228)
alosslessdev Nov 8, 2026
c5cc91f
dax: drop the one-name INFO overload the evaluator rejects (#2228)
alosslessdev Nov 8, 2026
2aeba77
dax: cover the extreme month offsets EOMONTH and EDATE saturate (#2228)
alosslessdev Nov 8, 2026
5a12205
dax: give time-intelligence intervals precedence over table and measu…
alosslessdev Nov 9, 2026
7eb0698
dax: format the interval table-name test (#2228)
alosslessdev Nov 9, 2026
3039a9c
dax: bind only documented enum words as keywords, saturate extreme DA…
alosslessdev Nov 9, 2026
60ca297
dax: restrict RANKX Ties and DATEDIFF slots to documented words, drop…
alosslessdev Nov 9, 2026
c0953eb
dax: rustfmt the DATEDIFF clause_keyword call (#2228)
alosslessdev Nov 9, 2026
04021c8
dax: model INFO restrictions as repeating pairs, reject odd arities (…
alosslessdev Nov 9, 2026
e90c408
dax: drop accidental worktree link from INFO-pairs commit (#2228)
alosslessdev Nov 9, 2026
fd01ea9
dax: restrict CONVERT and DATATABLE type slots, reject Boolean-number…
alosslessdev Nov 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ repository = "https://github.com/storytold/gridcraft"
gridcraft-core = { path = "crates/core" }
gridcraft-numfmt = { path = "crates/numfmt" }
gridcraft-formula = { path = "crates/formula" }
gridcraft-dax = { path = "crates/dax" }
gridcraft-functions = { path = "crates/functions" }
gridcraft-model = { path = "crates/model" }
gridcraft-calc = { path = "crates/calc" }
Expand Down
35 changes: 35 additions & 0 deletions crates/dax/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[package]
name = "gridcraft-dax"
# A first release of this crate, not the workspace release line: nothing depends on a published
# version of it yet, and 0.1.0 says what it is — new.
version = "0.1.0"
edition.workspace = true
license.workspace = true
description = "GridCraft DAX language: lexer, Pratt parser, syntax tree and canonical printer"

[lints]
workspace = true

[dependencies]
serde = { workspace = true }
serde_json = { workspace = true }
thiserror = { workspace = true }
# Calendar arithmetic (date serials, month lengths, leap years) goes through chrono on every
# target, as AGENTS.md requires. The web build has no clock and uses the fixed fallback in
# `eval/support.rs`, but the date types it needs build for wasm too (`gridcraft-core` does the
# same with the same workspace dependency).
chrono = { workspace = true }

[target.'cfg(target_arch = "wasm32")'.dependencies]
# The browser clock for NOW/TODAY under wasm, the same dependency `crates/core` uses: the standard
# library clock traps there, and `eval/support.rs` would otherwise freeze at 1970.
js-sys = "0.3"

[[example]]
name = "parse"
# Cargo does not test examples by default; this one carries assertions on the query-to-expression
# fallback, so it has to run under `cargo test`.
test = true

[dev-dependencies]
serde_json = { workspace = true }
432 changes: 432 additions & 0 deletions crates/dax/README.md

Large diffs are not rendered by default.

69 changes: 69 additions & 0 deletions crates/dax/examples/parse.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
//! Parse DAX from the command line (or stdin), print its syntax tree and canonical text.
//!
//! ```text
//! cargo run -p gridcraft-dax --example parse -- "1 + 2 * 3"
//! echo "EVALUATE SUM('Sales'[Amount])" | cargo run -p gridcraft-dax --example parse
//! ```

use std::io::{self, Read};

use gridcraft_dax::{TokenKind, parse_expression, parse_query, print_expression, print_query, tokenize};

fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut text = std::env::args().skip(1).collect::<Vec<_>>().join(" ");
if text.trim().is_empty() {
io::stdin().read_to_string(&mut text)?;
}
let text = text.trim();
if text.is_empty() {
return Err("no DAX expression supplied; pass it as an argument or on stdin".into());
}
print!("{}", render(text)?);
Ok(())
}

/// Parses and renders one input. Queries are preferred; when the query parser fails, a valid
/// expression is still accepted (`DEFINE` is a legal bare name), and the query diagnostic is kept
/// only when both parsers fail for input that starts with a query keyword.
fn render(text: &str) -> Result<String, String> {
match parse_query(text) {
Ok(query) => Ok(format!("Query\n{query:#?}\nCanonical: {}\n", print_query(&query))),
Err(query_error) => {
let expr = match parse_expression(text) {
Ok(expr) => expr,
Err(expr_error) => {
if starts_with_query_keyword(text) {
return Err(query_error.to_string());
}
return Err(expr_error.to_string());
}
};
Ok(format!("AST\n{expr:#?}\nCanonical: {}\n", print_expression(&expr)))
}
}
}

fn starts_with_query_keyword(text: &str) -> bool {
tokenize(text).is_ok_and(|tokens| match tokens.first().map(|token| &token.kind) {
Some(TokenKind::Evaluate) => true,
Some(TokenKind::Ident(word)) => word.eq_ignore_ascii_case("DEFINE"),
_ => false,
})
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn query_only_keywords_stay_on_the_query_parser() {
assert!(starts_with_query_keyword("EVALUATE Sales"));
assert!(starts_with_query_keyword("DEFINE MEASURE Sales[M] = 1 EVALUATE Sales"));
assert!(starts_with_query_keyword(" define measure Sales[M] = 1"));
assert!(!starts_with_query_keyword("SUM(Sales[Amount])"));
// `DEFINE` alone is a valid expression, so the expression parser wins.
assert!(render("DEFINE").expect("bare name expression").starts_with("AST"));
let error = render("DEFINE MEASURE").expect_err("malformed query");
assert!(error.contains("measure name"), "{error}");
}
}
Comment thread
alosslessdev marked this conversation as resolved.
Resolved
Loading
Loading