Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The SPARQL endpoint does not return a row if any column contains a null value #788

Open
arvindmn01 opened this issue Jan 25, 2024 · 1 comment

Comments

@arvindmn01
Copy link

arvindmn01 commented Jan 25, 2024

I am using this SPARQL Query to fetech the data from PostgreSQL database.

PREFIX dcim: <http://www.w3.org/ns/r2rml/dcim_location#>
                SELECT *
                WHERE {
                ?dcim_location dcim:created ?created ;
                                dcim:custom_field_data ?custom_field_data ;
                                dcim:description ?description ;
                                dcim:last_updated ?last_updated ;
                                dcim:level ?level ;
                                dcim:lft ?lft ;
                                dcim:name ?name ;
                                dcim:parent_id ?parent_id ;
                                dcim:rght ?rght ;
                                dcim:site_id ?site_id ;
                                dcim:slug ?slug ;
                                dcim:tenant_id ?tenant_id ;
                                dcim:tree_id ?tree_id .
                }

It returns an empty table because the parent_id column contains only null values. If I replace all the nulls with some data (integers), then this query works and returns the expected table.

Additionally, I tested by replacing some of the null values with data, and in this case, the query skipped those rows that contained null values.
PS: How to add the run the command in debugging mode.

@bcogrel
Copy link
Member

bcogrel commented Jan 25, 2024

Hi @arvindmn01, you need to use an OPTIONAL block around the triple pattern defining the variable ?parent_id to handle the case it is missing.

See https://www.w3.org/TR/sparql11-query/#optionals .

Regarding logging, if you use the Docker, just define the environment ONTOP_DEBUG. With the CLI, you can adjust the logging level by editing the file log/logback.xml.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants