private void insertOperationDatatyping(Term term, Function atom, int position) throws UnknownDatatypeException {

        ImmutableTerm immutableTerm = immutabilityTools.convertIntoImmutableTerm(term);

        if (immutableTerm instanceof ImmutableFunctionalTerm) {
            ImmutableFunctionalTerm castTerm = (ImmutableFunctionalTerm) immutableTerm;
            Predicate functionSymbol = castTerm.getFunctionSymbol();
            if (functionSymbol instanceof OperationPredicate) {

                Optional<TermType> inferredType = termTypeInferenceTools.inferType(castTerm);
                if(inferredType.isPresent()){
                    // delete explicit datatypes of the operands
                    deleteExplicitTypes(term, atom, position);
                    // insert the datatype of the evaluated operation
                    atom.setTerm(
                            position,
                            termFactory.getTypedTerm(
                                    term,
                                    // TODO: refactor this cast
                                    (RDFDatatype) inferredType.get()
                            ));
                }
                else
                    {


                    if (defaultDatatypeInferred) {

                        atom.setTerm(position, termFactory.getTypedTerm(term, typeFactory.getXsdStringDatatype()));
                    } else {
                        throw new UnknownDatatypeException("Impossible to determine the expected datatype for the operation " + castTerm + "\n" +
                                "Possible solutions: \n" +
                                "- Add an explicit datatype in the mapping \n" +
                                "- Add in the .properties file the setting: ontop.inferDefaultDatatype = true\n" +
                                " and we will infer the default datatype (xsd:string)"
                        );
                    }
                }
            }
        }
    }
private void insertOperationDatatyping ( Term term , Function atom , int position ) throws UnknownDatatypeException { ImmutableTerm immutableTerm = immutabilityTools . convertIntoImmutableTerm ( term ) ; if ( immutableTerm instanceof ImmutableFunctionalTerm ) { ImmutableFunctionalTerm castTerm = ( ImmutableFunctionalTerm ) immutableTerm ; Predicate functionSymbol = castTerm . getFunctionSymbol ( ) ; if ( functionSymbol instanceof OperationPredicate ) { Optional < TermType > inferredType = termTypeInferenceTools . inferType ( castTerm ) ; if ( inferredType . isPresent ( ) ) { deleteExplicitTypes ( term , atom , position ) ; atom . setTerm ( position , termFactory . getTypedTerm ( term , ( RDFDatatype ) inferredType . get ( ) ) ) ; } else { if ( defaultDatatypeInferred ) { atom . setTerm ( position , termFactory . getTypedTerm ( term , typeFactory . getXsdStringDatatype ( ) ) ) ; } else { throw new UnknownDatatypeException ( "Impossible to determine the expected datatype for the operation " + castTerm + "\n" + "Possible solutions: \n" + "- Add an explicit datatype in the mapping \n" + "- Add in the .properties file the setting: ontop.inferDefaultDatatype = true\n" + " and we will infer the default datatype (xsd:string)" ) ; } } } } }
Following r2rml standard we do not infer the datatype for operation but we return the default value string