Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 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
2c04e06
dax: date/time, time-intelligence and math/trig functions (#2228)
alosslessdev Nov 5, 2026
5647e98
dax: pick a calendar table's typed date column for the total function…
alosslessdev Nov 5, 2026
292f0a3
dax: bind every repeated order pair of SAMPLE and TOPNSKIP (#2228)
alosslessdev Nov 5, 2026
74014cc
dax: one date-column rule for tables and keep same-day timestamps in …
alosslessdev Nov 5, 2026
c37fa6a
dax: read the browser clock for NOW/TODAY on wasm (#2228)
alosslessdev Nov 5, 2026
8cc7cc4
dax: keep single-date range functions to one cell of the day (#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
63a9c92
Merge remote-tracking branch 'upstream/main' into dax/eval-datetime
alosslessdev Nov 5, 2026
c824ae7
Merge remote-tracking branch 'origin/dax/core' into dax/eval-datetime
alosslessdev Nov 5, 2026
bb0d997
dax: choose FIRSTDATE and LASTDATE among the visible cells (#2228)
alosslessdev Nov 5, 2026
230bf23
dax: seed the wasm PRNG from the browser clock and fold nonblank cand…
alosslessdev Nov 5, 2026
2a0183e
dax: order same-day axis cells by time and share the YearEndDate pars…
alosslessdev Nov 5, 2026
5b19af3
Merge remote-tracking branch 'upstream/main' into dax/eval-datetime
alosslessdev Nov 5, 2026
a72b928
dax: reject empty YearEndDate components (#2228)
alosslessdev Nov 5, 2026
e7f9d00
Merge remote-tracking branch 'upstream/main' into dax/eval-datetime
alosslessdev Nov 5, 2026
62260e6
dax: join numeric relationship keys across variants and keep DATEADD …
alosslessdev Nov 10, 2026
53403bc
dax: keep DATESINPERIOD intervals as keywords and NaN relationship ke…
alosslessdev Nov 10, 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
29 changes: 29 additions & 0 deletions crates/dax/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[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"

[dev-dependencies]
serde_json = { workspace = true }
426 changes: 426 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}");
}
}
Loading
Loading