Working with Lifecycle Query Engine relational store reports
Making reports available in Report Builder
Procedure
To test the reports in Report Builder, there are a couple of options:
- Use existing Report Builder to switch between SPARQL or SQL.
- Import reports to Report Builder. For more information, see Exporting Report Builder reports to compressed files and Importing Report Builder reports from compressed files.
Editing queries to create advanced reports
About this task
Converting a SPARQL query to an SQL query in Report Builder
Procedure
To convert an Lifecycle Query Engine report to use the new Lifecycle Query Engine relational store:
Manually converting SPARQL to SQL
Procedure
SQL is a standardized language for defining and manipulating data in a relational database.
In accordance with the relational model of data:
- The database is treated as a set of tables.
- Relationships are represented by values in tables.
- Data is retrieved by specifying a result table that can be derived from one or more base tables.
All executable SQL statements must be prepared before they can be executed. The result of preparation is the executable. The method of preparing an SQL statement and the persistence of its operational form distinguish static SQL from dynamic SQL. See Db2 SQL for additional details.
To convert SPARQL to SQL, the manual approach is the hardest but usually the fastest. The following are examples for converting SQARQL to Db2 SQL:
Resources
About this task
If you are looking for assistance with converting SPARQL to SQL, see the database vendor reference for database vendor-specific implementations:
- For Db2 SQL built-in functions, see https://www.ibm.com/docs/en/db2/11.5?topic=sql-built-in-functions
- For Oracle SQL built-in functions, see https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/Functions.html
- For SQL Server built-in functions, see https://www.w3schools.com/sql/sql_ref_sqlserver.asp
Comparing query results between SPARQL and SQL
About this task
You can manually check and compare the SPARQL and SQL query results, but it is not a reliable way of establishing if the results are similar. There might be visible differences in the ordering of results, even when sorting is well defined. For instance, an equivalent result might be on a different page of the reports that are generated from SPARQL versus SQL. Even if the ordering of results is identical, visually checking many rows and columns is not a reliable method to compare.
Instead of manually checking results that are generated from SPARQL versus SQL, you can click Compare query results in the Advanced section of the Format results tab or Run report page to compare the query. The comparison service in Report Builder generates the SPARQL and executes it, generates SQL and executes it, and then compares the query results between SPARQL and SQL for semantic equivalence. Based on the comparison, a warning or successful message is displayed on the screen with Expand and Collapse buttons. When you expand the message, a table with number of results and the execution time for SPARQL and SQL queries is displayed. You can also download the comparison report in text format by clicking Download comparison report. This can be used to test if the LQE rs delivers equivalent results to the existing Jena TDB-based solution. However, for this to be possible, there are some requirements and constraints. For more information, see Limitations of the Lifecycle Query Engine relational store.
To further assist with LQE rs, a new feature was introduced allowing Report Builder users to add custom expression with both SPARQL and SQL. This allows users to further take advantage of the Comparing query results service. To take advantage of this feature, users need to enclose SPARQL or SQL with the #if_sparql or #if_sql and #endif_sparql or #endif_sql. See the following example:#if_sparql
AVG(<Replace with Attribute>)
#endif_sparql
#if_sql
AVG(<Replace with Attribute>)
#endif_sql
Once custom expression contains both SPARQL and SQL, user would use validation service to update custom expression. Validation service validates either SPARQL or SQL based on the report query language selection. To validate both SPARQL and SQL, user would need to validate default query language first, for example SPARQL, and then update query language to SQL, and run custom expression validation. This would ensure both SPARQL and SQL are validated before report with custom expression or Compare query results is run.