Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WOQL group_by with sum throws error on decimals but not integers #2094

Open
hoijnet opened this issue Feb 16, 2024 · 0 comments
Open

WOQL group_by with sum throws error on decimals but not integers #2094

hoijnet opened this issue Feb 16, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@hoijnet
Copy link

hoijnet commented Feb 16, 2024

Describe the bug
WOQL group_by with sum throws error on decimals but not integers.

WOQL:

and(
    group_by(
        "v:week",
        "v:value",
        "v:list",
        and(
            triple("v:subject", "rdf:type", "@schema:DailyValueDecimal"),
            triple("v:subject", "@schema:value", "v:value"),
            triple("v:subject", "@schema:week", "v:week"),
        )
    ),
    sum("v:list", "v:result")
)

Schema element:

{
  "@type": "Class",
  "@key": {
    "@type": "Random"
  },
  "@id": "DailyValueDecimal",
  "@inherits": [
    "Entity"
  ],
  "weekday": {
    "@class": "xsd:unsignedShort",
    "@type": "Optional"
  },
  "week": {
    "@class": "xsd:unsignedShort",
    "@type": "Optional"
  },
  "value": {
    "@class": "xsd:decimal",
    "@type": "Optional"
  }
}

Add instance values for week 1-4 and random daily values (decimals) for weekday 1-7 (total of 28 values in my test).

When running the WOQL above, the below error is thrown:

{
  "api:message": "Type error for 1.42393795 which should be character",
  "api:status": "api:failure",
  "system:witnesses": [
    {
      "@type": "vio:ViolationWithDatatypeObject",
      "vio:literal": "1.42393795",
      "vio:message": "Type error for 1.42393795 which should be character",
      "vio:type": "character"
    }
  ]
}

To Reproduce
Steps to reproduce the behavior:

  1. Add schema
  2. Add instance data
  3. Run WOQL
  4. See error
  5. Run same query with integer in the definition for value and whole numbers, and the query works.

Expected behavior
The sum of the group_by should be summed the same way for integers and decimals. Have tried both floats and arbitrary precision and getting the same issue for decimals.

Screenshots
See above.

Info (please complete the following information):

  • OS: DFRNT/TerminusDB 11.1.11

Additional context
N/A

@hoijnet hoijnet added the bug Something isn't working label Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant