private RDFDatatype getDataType ( Map < String , List < IndexedPosition > > termOccurenceIndex , Variable variable ) throws UnknownDatatypeException { List < IndexedPosition > list = termOccurenceIndex . get ( variable . getName ( ) ) ; if ( list == null ) throw new UnboundTargetVariableException ( variable ) ; // ROMAN (10 Oct 2015): this assumes the first occurrence is a database relation! // AND THAT THERE ARE NO CONSTANTS IN ARGUMENTS! IndexedPosition ip = list . get ( 0 ) ; RelationID tableId = relation2Predicate . createRelationFromPredicateName ( metadata . getQuotedIDFactory ( ) , ip . atom . getFunctionSymbol ( ) ) ; RelationDefinition td = metadata . getRelation ( tableId ) ; Attribute attribute = td . getAttribute ( ip . pos ) ; Optional < RDFDatatype > type ; //we want to assign the default value or throw an exception when the type of the attribute is missing (case of view) if ( attribute . getType ( ) == 0 ) { type = Optional . empty ( ) ; } else { // TODO: refactor this (unsafe)!!! type = Optional . of ( ( RDFDatatype ) attribute . getTermType ( ) ) ; } if ( defaultDatatypeInferred ) return type . orElseGet ( typeFactory :: getXsdStringDatatype ) ; else { return type . orElseThrow ( ( ) -> new UnknownDatatypeException ( "Impossible to determine the expected datatype for the column " + variable + "\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)" ) ) ; } }
returns COL_TYPE for one of the datatype ids