← cross_join operator page · join/cross_join/aggr_attribute/max_as_attribute

Max as attribute 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

aggr with two components: the sum of Me_1 by Id_1 as the measure Me_3, and its maximum as At_1, with the role attribute, as in the page's syntax example aggr Me1 := sum(Me1), attribute At20 := avg(Me2).

Manual:

Cross Join: the role of an aggregated component is aggrRole ::= { measure | attribute | viral attribute }, and "if omitted, the Measure role is assumed"; "All non-identifier components are removed, and only the components generated by the sub-expressions are kept".

Expected:

the cartesian product of DS_1 (Id_1 1, 2) and DS_2 (Id_2 A, B) has 2 × 2 = 4 data points: Id_1 = 1 groups Me_1 10 twice, giving Me_3 = 20 and At_1 = 10, and Id_1 = 2 gives 40 and 20. At_1 is a Number Attribute.

script.vtl ⇩

DS_r := cross_join(DS_1, DS_2 aggr Me_3 := sum(Me_1), attribute At_1 := max(Me_1) group by Id_1);

input/DS_1.csv ⇩

Id_1Me_1
110
220

input/DS_1.json ⇩

{
  "datasets": [
    {
      "name": "DS_1",
      "DataStructure": [
        {"name": "Id_1", "type": "Integer", "role": "Identifier", "nullable": false},
        {"name": "Me_1", "type": "Number", "role": "Measure", "nullable": true}
      ]
    }
  ]
}

input/DS_2.csv ⇩

Id_2Me_2
A1
B2

input/DS_2.json ⇩

{
  "datasets": [
    {
      "name": "DS_2",
      "DataStructure": [
        {"name": "Id_2", "type": "String", "role": "Identifier", "nullable": false},
        {"name": "Me_2", "type": "Number", "role": "Measure", "nullable": true}
      ]
    }
  ]
}

expected/DS_r.csv ⇩

Id_1Me_3At_1
12010
24020

expected/DS_r.json ⇩

{
  "datasets": [
    {
      "name": "DS_r",
      "DataStructure": [
        {"name": "Id_1", "type": "Integer", "role": "Identifier"},
        {"name": "Me_3", "type": "Number", "role": "Measure"},
        {"name": "At_1", "type": "Number", "role": "Attribute"}
      ]
    }
  ]
}