<html><body><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000"><div>Hi Theresa,</div><div><br data-mce-bogus="1"></div><div>I am pretty set in considering NATURAL JOINS an anti-pattern (mostly due to being opaque) and far from being elegant.</div><div>Personally, I always use aliases since they are very explicit, precise and reduce redundancy in typing as well.</div><div><br></div><div>But I don't want to start a religious discussion.</div><div><br data-mce-bogus="1"></div><div>We too are using Gregory's parser and have encountered a couple of cases where the specific syntax of queries generated by TopCAT seems to not sit well with the library's ADQL parser or our native back-end's (PostgreSQL 9.2) capabilities, so when you contribute your changes back into the project maybe we should try to see if the changes / extensions solve any of our own issues as well. But our benchmark is not TopCAT but rather the RegTAP validation suite by Markus where we effectively score something like 59/61 (as of release r3726 of the suite). We also check that we can handle all the example queries as given in the RegTAP specification.<br></div><div><br data-mce-bogus="1"></div><div>For what is worth, I tried all your example queries (and their suggested translations) <a href="http://registry2.euro-vo.org/eurovo/" data-mce-href="http://registry2.euro-vo.org/eurovo/">in our beta system </a>(to be pushed to the production URL tomorrow according to the latest estimates):</div><div><br data-mce-bogus="1"></div><div><strong>1nd. sample query (TAP Access URLs)</strong></div><div>* natural join works</div><div>* non-natural join doesn't work and has to be re-written with aliases as:<br></div><div><br data-mce-bogus="1"></div><div><span style="font-family: 'courier new', courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;">SELECT a.ivoid, b.access_url</span><br><span style="font-family: 'courier new', courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;">FROM rr.capability a, rr.interface b</span><br><span style="font-family: 'courier new', courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;">WHERE a.ivoid = b.ivoid</span><br><span style="font-family: 'courier new', courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;">AND a.standard_id like 'ivo://ivoa.net/std/tap%'</span><br><span style="font-family: 'courier new', courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;">AND b.intf_type='vs:paramhttp'</span></div><div><br data-mce-bogus="1"></div><div>Or, alternatively and much closer to your own version, as:</div><div><br data-mce-bogus="1"></div><div><span style="font-family: 'courier new', courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;">SELECT rr.capability.ivoid, access_url</span><br><span style="font-family: 'courier new', courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;">FROM rr.capability, rr.interface</span><br><span style="font-family: 'courier new', courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;">WHERE rr.capability.ivoid = rr.interface.ivoid</span><br><span style="font-family: 'courier new', courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;">AND standard_id like 'ivo://ivoa.net/std/tap%'</span><br><span style="font-family: 'courier new', courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;">AND intf_type='vs:paramhttp'</span></div><div><br data-mce-bogus="1"></div><div><strong>2nd. sample query (SIA with spirals)</strong></div><div>* both versions work</div><div><br data-mce-bogus="1"></div><div><strong>3rd sample query (Infrared SIA)</strong></div><div>* both version work (if one accounts for some obvious typos that the non-natural version has)</div><div><br></div><div><strong>4th sample query (Cone Search with Red Shifts)</strong></div><div>* both versions work</div><div><br data-mce-bogus="1"></div><div><strong>5th sample query (records from registry)</strong></div><div>* natural query works</div><div>! I am not sure the non-natural version of the query corresponds to the same query (semantically) - maybe a copy-paste mistake?</div><div><br data-mce-bogus="1"></div><div><strong>6th sample query (locate RegTAP services)</strong></div><div>* both version work but the non-natural join returns 5 records (instead of the 2 that the natural join version does)</div><div><br data-mce-bogus="1"></div><div><strong>7th sample query (TAP with physics)</strong></div><div>* natural JOIN version works</div><div>* non-natural JOIN returns many more records</div><div><br data-mce-bogus="1"></div><div><strong>8th sample query (Theoretical SSA)</strong></div><div>* natural JOIN version works</div><div>* non-natural version returns 5 rows instead of two.</div><div><br data-mce-bogus="1"></div><div><strong>9th sample query (Find Contact Persons)</strong></div><div>* both versions work</div><div><br data-mce-bogus="1"></div><div>Cheers,</div><div>Menelaus.</div><div><br data-mce-bogus="1"></div><hr id="zwchr" data-marker="__DIVIDER__"><div data-marker="__HEADERS__"><b>From: </b>"Theresa Dower" <dower@stsci.edu><br><b>To: </b>registry@ivoa.net<br><b>Sent: </b>Wednesday, February 24, 2016 9:11:36 PM<br><b>Subject: </b>Problems with RegTAP, ADQL, natural joins, and MS SQL Server<br></div><div><br></div><div data-marker="__QUOTED_TEXT__"><div class="WordSection1"><p class="MsoNormal">Hello,</p><p class="MsoNormal"> </p><p class="MsoNormal">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.</p><p class="MsoNormal"> </p><p class="MsoNormal">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.</p><p class="MsoNormal"> </p><p class="MsoNormal">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.</p><p class="MsoNormal"> </p><p class="MsoNormal">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.</p><p class="MsoNormal"> </p><p class="MsoNormal">For the morbidly curious, all of the example queries requiring translation for SQL Server and our substitutions follow. They are quite simple, just numerous.</p><p class="MsoNormal"> </p><p class="MsoNormal">--Theresa Dower</p><p class="MsoNormal"> </p><p class="MsoNormal">----------------------------------------------</p><p class="MsoNormal"> </p><p class="MsoNormal"><b>TAP Access URLS:</b></p><p class="MsoNormal"> </p><p class="MsoNormal">SELECT ivoid, access_url</p><p class="MsoNormal">FROM rr.capability</p><p class="MsoNormal">NATURAL JOIN rr.interface</p><p class="MsoNormal">WHERE standard_id like 'ivo://ivoa.net/std/tap%'</p><p class="MsoNormal"> AND intf_type='vs:paramhttp'</p><p class="MsoNormal"> </p><p class="MsoNormal">SELECT ivoid, access_url<br> FROM rr.capability, rr.interface<br> WHERE rr.capability.ivoid = rr.interface.ivoid<br> AND standard_id like 'ivo://ivoa.net/std/tap%'<br> AND intf_type='vs:paramhttp'</p><p class="MsoNormal"> </p><p class="MsoNormal"><b>SIA with spirals:</b></p><p class="MsoNormal"> </p><p class="MsoNormal">SELECT ivoid, access_url</p><p class="MsoNormal">FROM rr.capability</p><p class="MsoNormal"> NATURAL JOIN rr.resource</p><p class="MsoNormal"> NATURAL JOIN rr.interface</p><p class="MsoNormal"> NATURAL JOIN rr.res_subject</p><p class="MsoNormal">WHERE standard_id='ivo://ivoa.net/std/sia'</p><p class="MsoNormal"> AND intf_type='vs:paramhttp'</p><p class="MsoNormal"> AND (</p><p class="MsoNormal"> 1=ivo_nocasematch(res_subject, '%spiral%')</p><p class="MsoNormal"> OR 1=ivo_hasword(res_description, 'spiral')</p><p class="MsoNormal"> OR 1=ivo_hasword(res_title, 'spiral'))</p><p class="MsoNormal"> </p><p class="MsoNormal">SELECT rr.capability.ivoid, access_url</p><p class="MsoNormal">FROM rr.capability, rr.resource, rr.interface, rr.res_subject</p><p class="MsoNormal">where rr.capability.ivoid = rr.resource.ivoid</p><p class="MsoNormal">AND rr.resource.ivoid = rr.interface.ivoid</p><p class="MsoNormal">AND rr.interface.ivoid = rr.res_subject.ivoid</p><p class="MsoNormal">AND standard_id='ivo://ivoa.net/std/sia'</p><p class="MsoNormal">AND intf_type='vs:paramhttp'</p><p class="MsoNormal">AND (</p><p class="MsoNormal">1=ivo_nocasematch(res_subject, '%spiral%')</p><p class="MsoNormal">OR 1=ivo_hasword(res_description, 'spiral')</p><p class="MsoNormal">OR 1=ivo_hasword(res_title, 'spiral'))</p><p class="MsoNormal"><b> </b></p><p class="MsoNormal"><b>Infrared SIA:</b></p><p class="MsoNormal"> </p><p class="MsoNormal">SELECT ivoid, access_url</p><p class="MsoNormal">FROM rr.capability</p><p class="MsoNormal"> NATURAL JOIN rr.resource</p><p class="MsoNormal"> NATURAL JOIN rr.interface</p><p class="MsoNormal">WHERE standard_id='ivo://ivoa.net/std/sia'</p><p class="MsoNormal"> AND intf_type='vs:paramhttp'</p><p class="MsoNormal"> AND 1=ivo_hashlist_has('infrared', waveband)</p><p class="MsoNormal"> </p><p class="MsoNormal">SELECT rr.capability.ivoid, access_url<br> FROM rr.capability, rr.resource, rr.interface<br> AND rr.capability.ivoid = rr.resource.ivoid<br> AND rr.resource.ivoid = rr.interface.ivoid<br> AND standard_id='ivo://ivoa.net/std/sia'<br> AND intf_type='vs:paramhttp'<br> AND 1=ivo_hashlist_has('infrared', waveband)</p><p class="MsoNormal"> </p><p class="MsoNormal"><b>ConeSearch with redshift:</b></p><p class="MsoNormal"> </p><p class="MsoNormal">SELECT ivoid, access_url</p><p class="MsoNormal">FROM rr.capability</p><p class="MsoNormal"> NATURAL JOIN rr.table_column</p><p class="MsoNormal"> NATURAL JOIN rr.interface</p><p class="MsoNormal">WHERE standard_id='ivo://ivoa.net/std/conesearch'</p><p class="MsoNormal"> AND intf_type='vs:paramhttp'</p><p class="MsoNormal"> AND ucd='src.redshift'</p><p class="MsoNormal"> </p><p class="MsoNormal">SELECT rr.capability.ivoid, access_url<br> FROM rr.capability, rr.table_column, rr.interface<br> where rr.capability.ivoid = rr.table_column.ivoid<br> AND rr.table_column.ivoid = rr.interface.ivoid<br> AND standard_id='ivo://ivoa.net/std/conesearch'<br> AND intf_type='vs:paramhttp'<br> AND ucd='src.redshift'</p><p class="MsoNormal"> </p><p class="MsoNormal"><b>Records from registry:</b></p><p class="MsoNormal"> </p><p class="MsoNormal">SELECT access_url</p><p class="MsoNormal">FROM rr.interface</p><p class="MsoNormal">NATURAL JOIN rr.capability</p><p class="MsoNormal">NATURAL JOIN rr.res_detail</p><p class="MsoNormal">WHERE standard_id='ivo://ivoa.net/std/tap'</p><p class="MsoNormal"> AND intf_type='vs:paramhttp'</p><p class="MsoNormal"> AND detail_xpath='/capability/dataModel/@ivo-id'</p><p class="MsoNormal"> AND 1=ivo_nocasematch(detail_value,</p><p class="MsoNormal"> 'ivo://ivoa.net/std/regtap#1.%')</p><p class="MsoNormal"> </p><p class="MsoNormal">SELECT ivoid FROM rr.resource<br> RIGHT OUTER JOIN (<br> SELECT 'ivo://' || detail_value || '%' AS pat<br> FROM rr.res_detail<br> WHERE detail_xpath='/managedAuthority'<br> AND ivoid='ivo://cds.vizier/registry')<br> AS authpatterns<br> ON (resource.ivoid LIKE authpatterns.pat)</p><p class="MsoNormal"> </p><p class="MsoNormal"><b>Locate RegTAP services:</b></p><p class="MsoNormal"> </p><p class="MsoNormal">SELECT access_url</p><p class="MsoNormal">FROM rr.interface</p><p class="MsoNormal">NATURAL JOIN rr.capability</p><p class="MsoNormal">NATURAL JOIN rr.res_detail</p><p class="MsoNormal">WHERE standard_id='ivo://ivoa.net/std/tap'</p><p class="MsoNormal"> AND intf_type='vs:paramhttp'</p><p class="MsoNormal"> AND detail_xpath='/capability/dataModel/@ivo-id'</p><p class="MsoNormal"> AND 1=ivo_nocasematch(detail_value,</p><p class="MsoNormal"> 'ivo://ivoa.net/std/regtap#1.%')</p><p class="MsoNormal"> </p><p class="MsoNormal">SELECT access_url<br> FROM rr.interface, rr.capability, rr.res_detail<br> where rr.interface.ivoid = rr.capability.ivoid<br> AND rr.capability.ivoid = rr.res_detail.ivoid<br> AND standard_id='ivo://ivoa.net/std/tap'<br> AND intf_type='vs:paramhttp'<br> AND detail_xpath='/capability/dataModel/@ivo-id'<br> AND 1=ivo_nocasematch(detail_value, <br> 'ivo://ivoa.net/std/regtap#1.%')</p><p class="MsoNormal"> </p><p class="MsoNormal"><b>TAP with Physics:</b></p><p class="MsoNormal"> </p><p class="MsoNormal">SELECT ivoid, access_url, name, ucd, column_description</p><p class="MsoNormal">FROM rr.capability</p><p class="MsoNormal"> NATURAL JOIN rr.interface</p><p class="MsoNormal"> NATURAL JOIN rr.table_column</p><p class="MsoNormal"> NATURAL JOIN rr.res_table</p><p class="MsoNormal">WHERE standard_id='ivo://ivoa.net/std/tap'</p><p class="MsoNormal"> AND intf_type='vs:paramhttp'</p><p class="MsoNormal"> AND 1=ivo_hasword(table_description, 'quasar')</p><p class="MsoNormal"> AND ucd='phot.mag;em.opt.v'</p><p class="MsoNormal"> </p><p class="MsoNormal">SELECT rr.capability.ivoid, access_url, name, ucd, column_description<br> FROM rr.capability, rr.interface, rr.table_column, rr.res_table<br> where rr.capability.ivoid = rr.interface.ivoid<br> and rr.interface.ivoid = rr.table_column.ivoid<br> and rr.table_column.ivoid = rr.res_table.ivoid<br> and standard_id='ivo://ivoa.net/std/tap'<br> AND intf_type='vs:paramhttp'<br> AND 1=ivo_hasword(table_description, 'quasar')<br> AND ucd='phot.mag;em.opt.v'</p><p class="MsoNormal"> </p><p class="MsoNormal"><b>Theoretical SSA:</b></p><p class="MsoNormal"> </p><p class="MsoNormal">SELECT access_url</p><p class="MsoNormal">FROM rr.res_detail</p><p class="MsoNormal"> NATURAL JOIN rr.capability</p><p class="MsoNormal"> NATURAL JOIN rr.interface</p><p class="MsoNormal">WHERE detail_xpath='/capability/dataSource'</p><p class="MsoNormal"> AND intf_type='vs:paramhttp'</p><p class="MsoNormal"> AND standard_id='ivo://ivoa.net/std/ssa'</p><p class="MsoNormal"> AND detail_value='theory'</p><p class="MsoNormal"> </p><p class="MsoNormal">SELECT access_url</p><p class="MsoNormal">FROM rr.res_detail, rr.capability, rr.interface</p><p class="MsoNormal">where rr.res_detail.ivoid = rr.capability.ivoid</p><p class="MsoNormal">and rr.capability.ivoid = rr.interface.ivoid</p><p class="MsoNormal">and detail_xpath='/capability/dataSource'</p><p class="MsoNormal">AND intf_type='vs:paramhttp'</p><p class="MsoNormal">AND standard_id='ivo://ivoa.net/std/ssa'</p><p class="MsoNormal">AND detail_value='theory'</p><p class="MsoNormal"><b> </b></p><p class="MsoNormal"><b>Find Contact Persons:</b></p><p class="MsoNormal"> </p><p class="MsoNormal">SELECT DISTINCT base_role, role_name, email</p><p class="MsoNormal">FROM rr.res_role</p><p class="MsoNormal"> NATURAL JOIN rr.interface</p><p class="MsoNormal">WHERE access_url='http://dc.zah.uni-heidelberg.de/tap'</p><p class="MsoNormal"> </p><p class="MsoNormal">SELECT DISTINCT access_url, base_role, role_name, email<br> FROM rr.res_role, rr.interface<br> where rr.res_role.ivoid = rr.interface.ivoid<br> and access_url='http://dc.zah.uni-heidelberg.de/tap'</p><p class="MsoNormal"> </p><p class="MsoNormal"> </p></div><br></div></div><PRE>This message and any attachments are intended for the use of the addressee or addressees only.
The unauthorised disclosure, use, dissemination or copying (either in whole or in part) of its
content is not permitted.
If you received this message in error, please notify the sender and delete it from your system.
Emails can be altered and their integrity cannot be guaranteed by the sender.
Please consider the environment before printing this email.
</PRE></body></html>