Problems with RegTAP, ADQL, natural joins, and MS SQL Server
Gregory Mantelet
gmantele at ari.uni-heidelberg.de
Thu Mar 17 10:57:14 CET 2016
Hi Theresa,
If you are using my ADQL Library, it is fairly possible to translate the
ADQL query into an SQL compatible with MS SQL Server. In this case, no
adaptation would be required in the ADQL standard, TOPCAT or any other
ADQL/TAP client. Actually, I have already a function that would do most
of the trick. All I need is to know whether you already have written an
SQL Server translator with my library (particularly to have the
geometrical functions working). If not, I can try to provide you a basic
one solving your problem. Let me know if you are interesting.
Cheers,
Grégory
On Wed, Mar 09, 2016 at 04:50:39PM +0000, Theresa Dower wrote:
>> Just a further note on this topic, to continue in my role as little black raincloud:
>>
>>
>>
>> It seems we've dropped on-list discussion of database back-end issues with RegTAP example queries in TOPCAT, which began with my frustration with MS SQL Server and NATURAL JOINs. Unfortunately, there is another instance where TOPCAT is using the same joins, which is even more problematic for us at STScI: the basic RegTAP keyword queries under "By Service Properties" use these joins under the hood, where a user can't rewrite them. Can this be altered as well? Can we go over this in some hack time at the interop?
>>
>>
>>
>> I know Menelaus was also having issues with some stock queries, so I'm posting on list again in case anyone else discovers cross-compatibility issues with the keyword searches.
>>
>>
>>
>> Thanks for the continued patience and support,
>>
>> --Theresa
>>
>> From: Theresa Dower
>> Sent: Wednesday, February 24, 2016 2:12 PM
>> To: registry at ivoa.net
>> Subject: Problems with RegTAP, ADQL, natural joins, and MS SQL Server
>>
>> Hello,
>>
>> As some of you know from prior discussions and database work of your own, there is an issue with the ADQL standard and the capabilities of MS SQL Server, namely that by design it does not support the NATURAL JOIN syntax. The design decision was based on the ambiguity in how the natural join finds keys in generic schemas. Even with known schemas such as RegTAP's, parsing and rewriting generic queries with natural joins is far from trivial.
>>
>> At this time, TAP services at NAVO institutions and the Royal Observatory Edinburgh are using Microsoft SQL Server as a back end to TAP services. STScI and ROE are extending Gregory Mantele's Java ADQL parser for this work and will share it back to his project. STScI have put together a RegTAP service which will be operational before the Spring 2016 interop. (An ObsTAP service with basic spatial query support comes next.) The problem is that with our available resources we cannot support natural joins, yet they are used extensively by the example RegTAP queries in TOPCAT, the most commonly used TAP client.
>>
>> For our testing, Sarah Weissman at ST created translations of example TOPCAT queries avoiding the natural join syntax. They are a longer and uglier, which is the general argument for the elegance of natural joins in the first place, but they do work. I've proposed to Mark Taylor that we could provide these in TOPCAT and I agreed with his suggestion that while we can certainly use them, we should bring this to the mailing list so you are all aware of the issue.
>>
>> How do we want to balance using the more elegant query syntax in our specs yet support major architectures that don't allow them? Should we avoid using them in documentation examples and/or provide sample translations? What do we add in terms of notes about the issue in future specs? Should we help out clients with an agreed-upon error note for unsupported functionality, given some TAP providers have a similar issue with unsupported geometry already? I think we should do all of this and I welcome thoughts on the issue.
>>
>> For the morbidly curious, all of the example queries requiring translation for SQL Server and our substitutions follow. They are quite simple, just numerous.
>>
>> --Theresa Dower
>>
>> ----------------------------------------------
>>
>> TAP Access URLS:
>>
>> SELECT ivoid, access_url
>> FROM rr.capability
>> NATURAL JOIN rr.interface
>> WHERE standard_id like 'ivo://ivoa.net/std/tap%'
>> AND intf_type='vs:paramhttp'
>>
>> SELECT ivoid, access_url
>> FROM rr.capability, rr.interface
>> WHERE rr.capability.ivoid = rr.interface.ivoid
>> AND standard_id like 'ivo://ivoa.net/std/tap%'
>> AND intf_type='vs:paramhttp'
>>
>> SIA with spirals:
>>
>> SELECT ivoid, access_url
>> FROM rr.capability
>> NATURAL JOIN rr.resource
>> NATURAL JOIN rr.interface
>> NATURAL JOIN rr.res_subject
>> WHERE standard_id='ivo://ivoa.net/std/sia'
>> AND intf_type='vs:paramhttp'
>> AND (
>> 1=ivo_nocasematch(res_subject, '%spiral%')
>> OR 1=ivo_hasword(res_description, 'spiral')
>> OR 1=ivo_hasword(res_title, 'spiral'))
>>
>> SELECT rr.capability.ivoid, access_url
>> FROM rr.capability, rr.resource, rr.interface, rr.res_subject
>> where rr.capability.ivoid = rr.resource.ivoid
>> AND rr.resource.ivoid = rr.interface.ivoid
>> AND rr.interface.ivoid = rr.res_subject.ivoid
>> AND standard_id='ivo://ivoa.net/std/sia'
>> AND intf_type='vs:paramhttp'
>> AND (
>> 1=ivo_nocasematch(res_subject, '%spiral%')
>> OR 1=ivo_hasword(res_description, 'spiral')
>> OR 1=ivo_hasword(res_title, 'spiral'))
>>
>> Infrared SIA:
>>
>> SELECT ivoid, access_url
>> FROM rr.capability
>> NATURAL JOIN rr.resource
>> NATURAL JOIN rr.interface
>> WHERE standard_id='ivo://ivoa.net/std/sia'
>> AND intf_type='vs:paramhttp'
>> AND 1=ivo_hashlist_has('infrared', waveband)
>>
>> SELECT rr.capability.ivoid, access_url
>> FROM rr.capability, rr.resource, rr.interface
>> AND rr.capability.ivoid = rr.resource.ivoid
>> AND rr.resource.ivoid = rr.interface.ivoid
>> AND standard_id='ivo://ivoa.net/std/sia'
>> AND intf_type='vs:paramhttp'
>> AND 1=ivo_hashlist_has('infrared', waveband)
>>
>> ConeSearch with redshift:
>>
>> SELECT ivoid, access_url
>> FROM rr.capability
>> NATURAL JOIN rr.table_column
>> NATURAL JOIN rr.interface
>> WHERE standard_id='ivo://ivoa.net/std/conesearch'
>> AND intf_type='vs:paramhttp'
>> AND ucd='src.redshift'
>>
>> SELECT rr.capability.ivoid, access_url
>> FROM rr.capability, rr.table_column, rr.interface
>> where rr.capability.ivoid = rr.table_column.ivoid
>> AND rr.table_column.ivoid = rr.interface.ivoid
>> AND standard_id='ivo://ivoa.net/std/conesearch'
>> AND intf_type='vs:paramhttp'
>> AND ucd='src.redshift'
>>
>> Records from registry:
>>
>> SELECT access_url
>> FROM rr.interface
>> NATURAL JOIN rr.capability
>> NATURAL JOIN rr.res_detail
>> WHERE standard_id='ivo://ivoa.net/std/tap'
>> AND intf_type='vs:paramhttp'
>> AND detail_xpath='/capability/dataModel/@ivo-id'
>> AND 1=ivo_nocasematch(detail_value,
>> 'ivo://ivoa.net/std/regtap#1.%')
>>
>> SELECT ivoid FROM rr.resource
>> RIGHT OUTER JOIN (
>> SELECT 'ivo://' || detail_value || '%' AS pat
>> FROM rr.res_detail
>> WHERE detail_xpath='/managedAuthority'
>> AND ivoid='ivo://cds.vizier/registry')
>> AS authpatterns
>> ON (resource.ivoid LIKE authpatterns.pat)
>>
>> Locate RegTAP services:
>>
>> SELECT access_url
>> FROM rr.interface
>> NATURAL JOIN rr.capability
>> NATURAL JOIN rr.res_detail
>> WHERE standard_id='ivo://ivoa.net/std/tap'
>> AND intf_type='vs:paramhttp'
>> AND detail_xpath='/capability/dataModel/@ivo-id'
>> AND 1=ivo_nocasematch(detail_value,
>> 'ivo://ivoa.net/std/regtap#1.%')
>>
>> SELECT access_url
>> FROM rr.interface, rr.capability, rr.res_detail
>> where rr.interface.ivoid = rr.capability.ivoid
>> AND rr.capability.ivoid = rr.res_detail.ivoid
>> AND standard_id='ivo://ivoa.net/std/tap'
>> AND intf_type='vs:paramhttp'
>> AND detail_xpath='/capability/dataModel/@ivo-id'
>> AND 1=ivo_nocasematch(detail_value,
>> 'ivo://ivoa.net/std/regtap#1.%')
>>
>> TAP with Physics:
>>
>> SELECT ivoid, access_url, name, ucd, column_description
>> FROM rr.capability
>> NATURAL JOIN rr.interface
>> NATURAL JOIN rr.table_column
>> NATURAL JOIN rr.res_table
>> WHERE standard_id='ivo://ivoa.net/std/tap'
>> AND intf_type='vs:paramhttp'
>> AND 1=ivo_hasword(table_description, 'quasar')
>> AND ucd='phot.mag;em.opt.v'
>>
>> SELECT rr.capability.ivoid, access_url, name, ucd, column_description
>> FROM rr.capability, rr.interface, rr.table_column, rr.res_table
>> where rr.capability.ivoid = rr.interface.ivoid
>> and rr.interface.ivoid = rr.table_column.ivoid
>> and rr.table_column.ivoid = rr.res_table.ivoid
>> and standard_id='ivo://ivoa.net/std/tap'
>> AND intf_type='vs:paramhttp'
>> AND 1=ivo_hasword(table_description, 'quasar')
>> AND ucd='phot.mag;em.opt.v'
>>
>> Theoretical SSA:
>>
>> SELECT access_url
>> FROM rr.res_detail
>> NATURAL JOIN rr.capability
>> NATURAL JOIN rr.interface
>> WHERE detail_xpath='/capability/dataSource'
>> AND intf_type='vs:paramhttp'
>> AND standard_id='ivo://ivoa.net/std/ssa'
>> AND detail_value='theory'
>>
>> SELECT access_url
>> FROM rr.res_detail, rr.capability, rr.interface
>> where rr.res_detail.ivoid = rr.capability.ivoid
>> and rr.capability.ivoid = rr.interface.ivoid
>> and detail_xpath='/capability/dataSource'
>> AND intf_type='vs:paramhttp'
>> AND standard_id='ivo://ivoa.net/std/ssa'
>> AND detail_value='theory'
>>
>> Find Contact Persons:
>>
>> SELECT DISTINCT base_role, role_name, email
>> FROM rr.res_role
>> NATURAL JOIN rr.interface
>> WHERE access_url='http://dc.zah.uni-heidelberg.de/tap'
>>
>> SELECT DISTINCT access_url, base_role, role_name, email
>> FROM rr.res_role, rr.interface
>> where rr.res_role.ivoid = rr.interface.ivoid
>> and access_url='http://dc.zah.uni-heidelberg.de/tap'
>>
>>
More information about the registry
mailing list