From c24fe0d1054eb4fa0414e5725abe7fde9b8fe942 Mon Sep 17 00:00:00 2001 From: alosslessdev Date: Thu, 5 Nov 2026 02:12:23 -0500 Subject: [PATCH] dax: bind every documented CROSSFILTER direction and RANK reset keyword (#2228) --- crates/dax/src/binder.rs | 10 +++++++++- crates/dax/src/functions/relationships.rs | 9 +++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/crates/dax/src/binder.rs b/crates/dax/src/binder.rs index c138dca59..1307d65c3 100644 --- a/crates/dax/src/binder.rs +++ b/crates/dax/src/binder.rs @@ -267,10 +267,18 @@ impl<'a> Binder<'a> { "CONVERT" if index == 1 => keyword_name(arg), // RANKX's Ties argument is documented as `Dense` but catalogued as a Scalar. "RANKX" if index == 4 => keyword_name(arg), + // RANKX's Order argument is catalogued as a Scalar too, but it is `ASC`/`DESC`. + "RANKX" if index == 3 => clause_keyword(arg, &["ASC", "DESC"]), "DATEDIFF" if index == 2 => keyword_name(arg), // TOPN's `(expression, Order)` pairs: ASC/DESC sit at every odd index from 3. "TOPN" if index >= 3 && index % 2 == 1 => clause_keyword(arg, &["ASC", "DESC"]), - "CROSSFILTER" if index == 2 => clause_keyword(arg, &["ONE", "ONEWAY", "BOTH", "TWOWAY", "NONE"]), + "CROSSFILTER" if index == 2 => { + clause_keyword(arg, &["NONE", "ONE", "ONEWAY", "BOTH", "TWOWAY", "ONEWAY_LEFTFILTERSRIGHT", "ONEWAY_RIGHTFILTERSLEFT"]) + } + // RANK/ROWNUMBER's Reset argument is `NONE`, `LOWESTPARENT` or `HIGHESTPARENT`, + // catalogued as `Any` so that a relation expression still binds there. + "RANK" if index == 6 => clause_keyword(arg, &["NONE", "LOWESTPARENT", "HIGHESTPARENT"]), + "ROWNUMBER" if index == 5 => clause_keyword(arg, &["NONE", "LOWESTPARENT", "HIGHESTPARENT"]), // Window/relation clauses take bare enum words: `ORDERBY(x, DESC)`, // `WINDOW(1, ABS, 1, ABS, ...)`, `INDEX(..., KEEP, PARTITIONBY(...))`, and the // LOOKUP associated-columns behaviour (`INFERRED`). diff --git a/crates/dax/src/functions/relationships.rs b/crates/dax/src/functions/relationships.rs index 9956ce7d0..0c13fd00f 100644 --- a/crates/dax/src/functions/relationships.rs +++ b/crates/dax/src/functions/relationships.rs @@ -37,10 +37,11 @@ pub static FUNCTIONS: &[FunctionSpec] = &[ RELATIONSHIP_FLAGS, "Overrides the cross-filter direction of an existing relationship for the duration of \ the filter context it modifies. The two column arguments identify the relationship \ - endpoints; the third argument is 0/1/2/3/4 or the words NONE, ONEWAY, BOTH or \ - TWOWAY. It changes filter propagation in both directions, never which relationship is \ - active, so it is used as a filter modifier inside CALCULATE and similar functions and \ - returns no value.", + endpoints; the third argument is 0/1/2/3/4 or the words NONE, ONE, ONEWAY, BOTH, \ + TWOWAY, ONEWAY_LEFTFILTERSRIGHT or ONEWAY_RIGHTFILTERSLEFT (the last two flow from the \ + first column argument's table to the second's, or back). It changes filter propagation \ + in both directions, never which relationship is active, so it is used as a filter \ + modifier inside CALCULATE and similar functions and returns no value.", &[ "CALCULATE ( [Sales Amount], CROSSFILTER ( Sales[CustomerKey], Customer[CustomerKey], BOTH ) )", "CALCULATE ( COUNTROWS ( Customer ), CROSSFILTER ( Sales[ProductKey], 'Product'[ProductKey], NONE ) )",