TDengine Introduces Integration with Ontop

Jim Fan

August 12, 2025 /

TDengine is excited to announce support for connecting TDengine TSDB with Ontop as well as a partnership with Ontopic. Ontop is an open-source virtual knowledge graph system that dynamically transforms database content into knowledge graphs without requiring data migration from the original source.

This integration combines the strong logical reasoning of knowledge graphs with the generalization capabilities of large language models, providing intelligent analysis solutions with cognitive capabilities for complex IoT scenarios such as device failure root cause analysis and energy efficiency optimization.

The integration of TDengine TSDB and Ontop achieves the following:

  • Automatic conversion of time-series data to RDF, supporting SPARQL semantic queries.
  • Unified data access interface compliant with W3C standards.
  • Unlocking knowledge graph analysis and reasoning capabilities for industrial IoT.

Prerequisites

  • Install TDengine TSDB 3.3.6.0 or later. TDengine TSDB-OSS and TSDB-Enterprise are both supported. For installation instructions, visit our Download Center.
  • Ensure that TDengine TSDB and taosAdapter are running.
  • Download the TDengine JDBC Client Library 3.6.0 or later. Select the file ending in dist.jar.
  • Download and build the version5 branch of the Ontop source code according to the readme file.

Configure Data Source

  1. Copy the TDengine JDBC client library in the jdbc/ directory within Ontop.

  2. In the Ontop .properties file, configure the JDBC connection:

    jdbc.url = jdbc:TAOS-WS://<taosadapter-host>:<port>/<database>
    jdbc.user = <tdengine-username>
    jdbc.password = <tdengine-password>
    jdbc.driver = com.taosdata.jdbc.ws.WebSocketDriver

    For URL parameter details, see TDengine URL Specification.

  3. Define the mapping relationship between TDengine TSDB and Ontop in the .obda file. A smart meter scenario is given as an example.

    [PrefixDeclaration]
    :   http://example.org/tde
    ns: http://example.org/ns#
    
    [MappingDeclaration] @collection [[
      mappingId meters-mapping
      target ns:{ts} a ns:Meters ; ns:ts {ts} ; ns:voltage {voltage}; ns:phase {phase}; ns:groupid {groupid}; ns:location {location}^^xsd:string .
      source SELECT ts, voltage, phase, groupid, location  from test.meters
    ]]

    Format Description:

    Key FieldDescription
    mappingIdMapping ID, uniquely identifies the mapping relationship
    sourceTDengine TSDB SQL query statement (supports complex queries)
    targetField mapping relationship (uses default conversion rules when type not specified)

    You can specify mapping data types in the target. If not specified, the following conversion rules apply:

    TDengine JDBC Data TypeOntop Data Type
    java.sql.Timestampxsd:datetime
    java.lang.Booleanxsd:boolean
    java.lang.Bytexsd:byte
    java.lang.Shortxsd:short
    java.lang.Integerxsd:int
    java.lang.Longxsd:long
    java.math.BigIntegerxsd:nonNegativeInteger
    java.lang.Floatxsd:float
    java.lang.Doublexsd:double
    byte[]xsd:base64Binary
    java.lang.Stringxsd:string
    java.math.BigDecimalxsd:decimal

    For complete .obda file format documentation, refer to Ontop OBDA Documentation.

  4. Start the Ontop endpoint service to verify configuration:

    ontop endpoint -p db.properties -m db.obda --port 8080

In a web browser, access http://localhost:8080. If the SPARQL query interface appears, the configuration is successful.

Sample Scenario

In this scenario, smart meter data from a residential community is stored in TDengine TSDB. Ontop is used to transform this data into a virtual knowledge graph and identify overloaded equipment with voltage exceeding 240V.

Data Preparation

  1. Generate simulated data using taosBenchmark:

    taosBenchmark -t 100 -n 1000 -y
  2. Edit the Ontop .properties file and configure the connection:

    jdbc.url=jdbc:TAOS-WS://localhost:6041/test
    jdbc.user=root
    jdbc.password=taosdata
    jdbc.driver=com.taosdata.jdbc.ws.WebSocketDriver   
  3. Edit the Ontop .odba file and configure the table mapping:

    [PrefixDeclaration]
    :   http://example.org/tde
    ns: http://example.org/ns#
    
    [MappingDeclaration] @collection [[
      mappingId meters-mapping
      target ns:{ts} a ns:Meters ; ns:ts {ts} ; ns:voltage {voltage}; ns:phase {phase}; ns:groupid {groupid}; ns:location {location}^^xsd:string .
      source SELECT ts, voltage, phase, groupid, location  from test.meters
    ]]
  4. Create a SPARQL query statement to query smart meter devices with voltage exceeding 240V and display the top two results by voltage in descending order:

     PREFIX ns: <http://example.org/ns#>
    
     SELECT ?ts ?voltage ?phase ?groupid ?location
     WHERE {
         ?m a ns:Meters ;
                 ns:ts ?ts;
                 ns:voltage ?voltage;
                 ns:phase ?phase;         
                 ns:groupid ?groupid;
                 ns:location ?location.
         FILTER(?voltage > 240)
     }
     ORDER BY DESC(?voltage)
     LIMIT 2
  5. In a web browser, open the Ontop SPARQL endpoint and run the SPARQL statement.

    ontop-query

Results are returned in SPARQL JSON format, containing meter collection timestamps, voltage readings, phase, group ID, and device location information.

{
 "head" : {
     "vars" : [
     "ts",
     "voltage",
     "phase",
     "groupid",
     "location"
     ]
},
 "results" : {
     "bindings" : [
     {
         "ts" : {
         "datatype" : "http://www.w3.org/2001/XMLSchema#dateTime",
         "type" : "literal",
         "value" : "2025-07-02T15:22:55.098"
         },
         "voltage" : {
         "datatype" : "http://www.w3.org/2001/XMLSchema#integer",
         "type" : "literal",
         "value" : "263"
         },
         "phase" : {
         "datatype" : "http://www.w3.org/2001/XMLSchema#double",
         "type" : "literal",
         "value" : "143.2"
         },
         "groupid" : {
         "datatype" : "http://www.w3.org/2001/XMLSchema#integer",
         "type" : "literal",
         "value" : "2"
         },
         "location" : {
         "type" : "literal",
         "value" : "California.PaloAlto"
         }
     },
     {
         "ts" : {
         "datatype" : "http://www.w3.org/2001/XMLSchema#dateTime",
         "type" : "literal",
         "value" : "2025-07-02T15:23:30.186"
         },
         "voltage" : {
         "datatype" : "http://www.w3.org/2001/XMLSchema#integer",
         "type" : "literal",
         "value" : "259"
         },
         "phase" : {
         "datatype" : "http://www.w3.org/2001/XMLSchema#double",
         "type" : "literal",
         "value" : "132.1"
         },
         "groupid" : {
         "datatype" : "http://www.w3.org/2001/XMLSchema#integer",
         "type" : "literal",
         "value" : "2"
         },
         "location" : {
         "type" : "literal",
         "value" : "California.PaloAlto"
         }
     }
     ]
   }
}
  • Jim Fan
    Jim Fan

    Jim Fan is the VP of Product at TDengine. With a Master's Degree in Engineering from the University of Michigan and over 15 years of experience in manufacturing and Industrial IoT spaces, he brings expertise in digital transformation, smart manufacturing, autonomous driving, and renewable energy to drive TDengine's solution strategy. Prior to joining TDengine, he worked as the Director of Product Marketing for PTC's IoT Division and Hexagon's Smart Manufacturing Division. He is currently based in California, USA.