Skip to content

feat(query): implement scalar functions and XML Schema casts (#563) - #585

Merged
remiceres merged 1 commit into
feature/corese-nextfrom
feature/563-scalar-functions-casting
Sep 10, 2026
Merged

feat(query): implement scalar functions and XML Schema casts (#563)#585
remiceres merged 1 commit into
feature/corese-nextfrom
feature/563-scalar-functions-casting

Conversation

@remiceres

@remiceres remiceres commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements #563 in the native core.next.query pipeline: SPARQL scalar built-ins, XML Schema constructors and SPARQL expression type-error handling.

  • Enable scalar SELECT expressions through the existing AST/compiler and KGRAM projection machinery; aggregate projections remain explicitly unsupported.
  • Implement the seven standard XML Schema casts and ISNUMERIC, validate numeric lexical forms/value spaces, preserve source RDF terms and handle exact integer truncation, signed zero and canonical numeric-to-string casts.
  • Complete string/language, Unicode substring, URI, BNODE scoping, date/time, numeric and hash behavior. Accept empty CONCAT/COALESCE argument lists in the existing ANTLR grammar; no parser dependency is added.
  • Distinguish absorbable SPARQL type errors from engine/infrastructure failures in FILTER, BIND, projection, IF, COALESCE and boolean expressions.
  • Add 118 regression cases, including source-term preservation for all four disputed upstream cast-decimal bindings.

Validation

  • ./gradlew test: 2,934 tests, zero failures/errors/skips.
  • SonarLint: 20/20 changed Java files analyzed, zero diagnostics.
  • Full sibling W3C run: all 73 harness unit tests pass; all active non-SPARQL suites pass. EARL parsing, 15 validation queries and JSON/EARL coverage checks pass.
  • Same 978 official SPARQL test identifiers compared against the pre-[Query] Implement SPARQL 1.1 scalar built-in functions and casting operators #563 baseline: 644 → 738 passed (+94), zero regressions, no missing tests with the companion harness fix. Core-only with the unchanged harness gives 730 passes.
  • SPARQL 1.0: 398 → 415/483. SPARQL 1.1: 246 → 323/495.
  • functions: 75/75 pass. Cast evaluation: 5 pass + 1 indeterminate; all seven cast syntax tests also pass.

The 239 remaining SPARQL failures are pre-existing cases outside this issue. The additional indeterminate case is not claimed as passing: upstream cast-decimal.srx rewrites four directly projected source literals. The companion harness PR continues executing it, recognizes only that exact discrepancy and preserves the original JUnit failure. No official fixture is changed and no core behavior is tailored to its erroneous expected source terms.

Integration order

Merge this PR into feature/corese-next first, then merge corese-stack/corese-w3c#27. The harness uses the existing native parser only to identify computed numeric projections; numeric value comparison remains independent of Corese's numeric implementation. Its scoped comparison is justified by the upstream discussion, without relaxing directly projected RDF-term identity.

@github-actions

Copy link
Copy Markdown
Overall Project 54.2% -0.08% 🍏
Files changed 82.51% 🍏

File Coverage
QueryTypeErrorException.java 100% 🍏
NativeExpressionEvaluator.java 95.7% 🍏
CoreseAstQueryBuilder.java 93.31% 🍏
ASTConstants.java 92.45% 🍏
NativeStringExpressionEvaluator.java 91.88% -3.35% 🍏
SparqlExpressionBuilder.java 86.27% 🍏
NativeCastExpressionEvaluator.java 81.87% -18.13% 🍏
NativeEvaluationContext.java 81.66% -7.96% 🍏
NativeNumericValues.java 72.06% -27.94% 🍏
NativeNumericExpressionEvaluator.java 70.94% -2.66% 🍏
SparqlTermResolver.java 68.59% 🍏
IsNumericAst.java 66.67% -33.33% 🍏
NativeTemporalExpressionEvaluator.java 62.89% -5.03% 🍏
NativeBooleanExpressionEvaluator.java 62.28% -0.6% 🍏
NativeIriExpressionEvaluator.java 61.76% -6.86% 🍏
NativeValueComparison.java 44.94% -6.33%
Eval.java 44.52% 🍏
Memory.java 43.57% -0.34% 🍏

@github-actions

Copy link
Copy Markdown

Test Results

  427 files    427 suites   25s ⏱️
2 915 tests 2 915 ✅ 0 💤 0 ❌
2 934 runs  2 934 ✅ 0 💤 0 ❌

Results for commit 4dd4a38.

@remiceres
remiceres merged commit 23d66b3 into feature/corese-next Sep 10, 2026
2 checks passed
@remiceres
remiceres deleted the feature/563-scalar-functions-casting branch September 10, 2026 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant