Translate Sparql to SQL without database connection

34 views
Skip to first unread message

Prateem Mandal

unread,
Aug 29, 2025, 1:09:45 PMAug 29
to ontop4obda
Hi,

I want to use OnTop as a SQL generator without connecting to any database. Is this possible? If so how? For ex. I was not able to figure out how to provide target SQL engine.

I found this thread https://groups.google.com/g/ontop4obda/c/Op_G3bmRJo8/m/1935Sf1zAQAJ where it is mentioned that this is not possible and that a connection to database is needed to extract the metadata. I would be happy to provide the metadata as a object (or serialized file).

If in order to do this I would need to modify OnTop, can you please outline how to achieve this?

Thanks
Prateem

Benjamin Cogrel

unread,
Sep 22, 2025, 9:14:41 AMSep 22
to Prateem Mandal, ontop4obda
Hi Prateem,

Sorry for the late reply.

Yes, there is a way to avoid having Ontop connecting to the data source. First, you can pass the DB metadata as a JSON document. If this metadata is sufficient (all the SQL queries are parsed by Ontop and the metadata is complete), Ontop won't fetch metadata from the data source directly. 

At runtime, you can just ask the system to reformulate the query for you, like for instance in https://github.com/ontop/ontop/pull/577 .

Please enable ontop.reformulateToFullNativeQuery. That way the SQL query will use the same variables as the SPARQL one.
Note that we may refactor this reformulation mechanism in the future and deprecate this configuration entry.

For the JDBC URL, you can create a fake one. Just make sure to URLs of the correct SQL dialect, as this information is used by Ontop for recognizing the dialect.

Best,
Benjamin

--
Please follow our guidelines on how to report a bug https://ontop-vkg.org/community/contributing/bug-report
---
You received this message because you are subscribed to the Google Groups "ontop4obda" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ontop4obda+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/ontop4obda/ec19ca8a-5054-42b1-a9de-6800e8016993n%40googlegroups.com.

Prateem Mandal

unread,
Sep 22, 2025, 2:51:13 PMSep 22
to Benjamin Cogrel, ontop4obda
Thanks Benjamin. I see your solution is more compact than what I ended up using (which I copied from one of the test cases).

ontop-lib-fragment.png

The exact code is here

I will try out your suggested approach and report back if I face issues.

Thanks
Prateem

PS:
I had considerable difficulty in resolving library conflicts with the rest of the poc application and ensuring a reproducible build but was able to muddle my way through it.

Reply all
Reply to author
Forward
0 new messages