Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 4 additions & 2 deletions src/vtlengine/Operators/Aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,10 @@ def validate( # type: ignore[override]
for comp_name, comp in operand.components.items():
if comp.role == Role.ATTRIBUTE:
del result_components[comp_name]
# TimeInterval is not supported as a measure in aggregate operations
if any(
# TimeInterval is not supported as a measure in aggregate operations.
# count is exempt: it only reports the number of Data Points, so the Measures it
# is given are replaced by int_var below rather than aggregated (issue #937).
if cls.op != COUNT and any(
comp.role == Role.MEASURE and comp.data_type is TimeInterval
for comp in result_components.values()
):
Expand Down
4 changes: 4 additions & 0 deletions tests/Bugs/data/DataSet/input/GH_937_1-1.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Id_1,Id_2,Me_1,Me_2
1,a,1.0,2020-01-01/2020-12-31
1,b,2.0,2021-01-01/2021-12-31
2,a,3.0,2022-01-01/2022-12-31
2 changes: 2 additions & 0 deletions tests/Bugs/data/DataSet/output/GH_937_1-1.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
int_var
3
3 changes: 3 additions & 0 deletions tests/Bugs/data/DataSet/output/GH_937_1-2.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Id_1,int_var
1,2
2,1
33 changes: 33 additions & 0 deletions tests/Bugs/data/DataStructure/input/GH_937_1-1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"datasets": [
{
"name": "DS_1",
"DataStructure": [
{
"name": "Id_1",
"role": "Identifier",
"type": "Integer",
"nullable": false
},
{
"name": "Id_2",
"role": "Identifier",
"type": "String",
"nullable": false
},
{
"name": "Me_1",
"role": "Measure",
"type": "Number",
"nullable": true
},
{
"name": "Me_2",
"role": "Measure",
"type": "Time",
"nullable": true
}
]
}
]
}
15 changes: 15 additions & 0 deletions tests/Bugs/data/DataStructure/output/GH_937_1-1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"datasets": [
{
"name": "DS_r1",
"DataStructure": [
{
"name": "int_var",
"role": "Measure",
"type": "Integer",
"nullable": true
}
]
}
]
}
21 changes: 21 additions & 0 deletions tests/Bugs/data/DataStructure/output/GH_937_1-2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"datasets": [
{
"name": "DS_r2",
"DataStructure": [
{
"name": "Id_1",
"role": "Identifier",
"type": "Integer",
"nullable": false
},
{
"name": "int_var",
"role": "Measure",
"type": "Integer",
"nullable": true
}
]
}
]
}
2 changes: 2 additions & 0 deletions tests/Bugs/data/vtl/GH_937_1.vtl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DS_r1 <- count(DS_1);
DS_r2 <- count(DS_1 group by Id_1);
18 changes: 18 additions & 0 deletions tests/Bugs/test_bugs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2067,6 +2067,24 @@ def test_GL_410(self):
code=code, number_inputs=number_inputs, exception_code=message
)

def test_GH_937_1(self):
"""
Status: OK
Description: count only reports the number of Data Points, so it does not
aggregate the Measures it is given: the reference manual types its
operand as a plain dataset, states no Additional Constraints, and
counts a String Measure in its own example. A Time Measure was
rejected anyway, because the guard against aggregating one ran
before count replaced every Measure with int_var.
Git Issue: https://github.com/Meaningful-Data/vtlengine/issues/937
Goal: Check Result.
"""
code = "GH_937_1"
number_inputs = 1
references_names = ["1", "2"]

self.BaseTest(code=code, number_inputs=number_inputs, references_names=references_names)


class DataValidationBugs(BugHelper):
""" """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,9 @@ def test_13(self):
"""
code = "10-1-13"
number_inputs = 1
exception_code = "1-1-19-12"
references_names = ["DS_r"]

self.NewSemanticExceptionTest(
code=code, number_inputs=number_inputs, exception_code=exception_code
)
self.BaseTest(code=code, number_inputs=number_inputs, references_names=references_names)

def test_14(self):
"""
Expand Down Expand Up @@ -1506,11 +1504,9 @@ def test_12(self):
"""
code = "10-2-12"
number_inputs = 1
exception_code = "1-1-19-12"
references_names = ["DS_r"]

self.NewSemanticExceptionTest(
code=code, number_inputs=number_inputs, exception_code=exception_code
)
self.BaseTest(code=code, number_inputs=number_inputs, references_names=references_names)

def test_13(self):
"""
Expand Down
Loading