generated from ivoa-std/doc-template
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTAP.tex
1617 lines (1340 loc) · 72.8 KB
/
TAP.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
\documentclass[11pt,letter]{ivoa}
\input tthdefs
\usepackage{listings}
\usepackage{relsize}
\lstloadlanguages{XML,HTML}
\lstset{flexiblecolumns=true,basicstyle=\small,tagstyle=\ttfamily,
showstringspaces=False}
\usepackage[utf8]{inputenc}
\hyphenation{asyn-chro-n-ous-ly}
\title{Table Access Protocol}
\ivoagroup{Data Access Layer Working Group}
\author{Patrick Dowler, Guy Rixon, Doug Tody, Markus Demleitner}
\editor{Patrick Dowler}
\previousversion[https://www.ivoa.net/documents/TAP/20190927/]{TAP-1.1}
\previousversion[http://www.ivoa.net/Documents/TAP/20190826/]{PR-TAP-1.1-20190826}
\previousversion[http://www.ivoa.net/Documents/TAP/20190626/]{PR-TAP-1.1-20190626}
\previousversion[http://www.ivoa.net/Documents/TAP/20190420/]{PR-TAP-1.1-20190420}
\previousversion[http://www.ivoa.net/Documents/TAP/20181024/]{PR-TAP-1.1-20181024}
\previousversion[http://www.ivoa.net/Documents/TAP/20180830/]{PR-TAP-1.1-20180830}
\previousversion[http://www.ivoa.net/Documents/TAP/20180416/]{PR-TAP-1.1-20180416}
\previousversion[http://www.ivoa.net/Documents/TAP/20170830/]{PR-TAP-1.1-20170830}
\previousversion[http://www.ivoa.net/Documents/TAP/20170707/]{WD-TAP-1.1-20170707}
\previousversion[http://www.ivoa.net/Documents/TAP/20160428/]{WD-TAP-1.1-20160428}
\previousversion[http://www.ivoa.net/Documents/TAP/1.0]{TAP-1.0}
\iftth
\newcommand{\tapschema}{TAP\_SCHE\-MA}
\hyphenation{TAP\_SCHEMA}
\hyphenation{\tapschema}
\newcommand{\tapupload}{TAP\_UPLOAD}
\else
\newcommand{\tapschema}{\mbox{%
\relsize{-0.5}TAP\discretionary{-}{}{\kern-2pt\_}SCHEMA}}
\newcommand{\tapupload}{%
{\relsize{-0.5}TAP\discretionary{-}{}{\kern-2pt\_}UPLOAD}}
\fi
\begin{document}
\begin{abstract}
The Table Access Protocol (TAP) defines a service protocol for accessing general
table data, including astronomical catalogs as well as general database tables.
Access is provided for both database and table metadata as well as for actual
table data. This version of the protocol includes support for multiple query
languages, including queries specified using the Astronomical Data Query
Language ADQL within an integrated interface. It also includes
support
for both synchronous and asynchronous queries. Special support is provided for
spatially indexed queries using the spatial extensions in ADQL. A multi-position
query capability permits queries against an arbitrarily large list of
astronomical targets, providing a simple spatial cross-matching capability.
More sophisticated distributed cross-matching capabilities are possible by
orchestrating a distributed query across multiple TAP services.
\end{abstract}
\section*{Acknowledgments}
The authors would like to acknowledge all contributors to this and previous
versions of this standard, especially: K. Andrews, J. Good, R. Hanisch, G.
Lemson, T. McGlynn, K. Noddle, F. Ochsenbein, I. Ortiz, P. Osuna, R. Plante,
J. Salgado, A. Stebe, and A. Szalay.
\section*{Conformance-related definitions}
The words ``MUST'', ``SHALL'', ``SHOULD'', ``MAY'', ``RECOMMENDED'', and
``OPTIONAL'' (in upper or lower case) used in this document are to be
interpreted as described in IETF standard, \citet{std:RFC2119}.
The \emph{Virtual Observatory (VO)} is general term for a collection of
federated resources that can be used to conduct astronomical research,
education, and outreach. The \href{http://www.ivoa.net}{International
Virtual Observatory Alliance (IVOA)} is a global collaboration of separately
funded projects to develop standards and infrastructure that enable VO
applications.
\section{Introduction}
\label{sec:Introduction}
The Table Access Protocol (TAP) is a web-service protocol that gives access to
collections of tabular data referred to collectively as a tableset. TAP
services accept queries posed against the tableset available via the service and
return the query response as another table, in accord with the relational model.
Queries may be submitted using various query languages and may execute
synchronously or asynchronously. Support for the Astronomical Data Query
Language ADQL \citep{2023ivoa.spec.1215M} is mandatory; support for other query languages is
supported
but optional.
The result of a TAP query is another table, normally returned as a VOTable.
Support for VOTable output is mandatory; all other formats are optional.
The table collections made accessible via TAP are typically stored in relational
database management systems (RDBMS). A TAP service exposes the database schema
to client applications so that queries can be posed directly against arbitrary
data tables available via the service.
Multi-table operations such as joins or cross matches are possible provided the
tables are all managed by the local TAP service, and provided the service
supports these capabilities. Larger scale operations such as a distributed
cross match are also possible, but require combining the results of multiple TAP
services.
\subsection{Role within the VO Architecture}
\label{sec:Role}
% NOTE: not in TAP-1.0
\begin{figure}
\centering
% Get the architecture diagram from the TCG chair
% http://wiki.ivoa.net/twiki/bin/view/IVOA/IvoaTCG
% If they give you a PDF, for now dumb it down to a png by
% convert -antialias -density 72x72 archdiag.pdf archdiag.png
% Oh -- Notes don't need this; you'd have to remove archdiag.png
% from FIGURES in the Makefile, too.
\includegraphics[width=0.9\textwidth]{role_diagram.pdf}
\caption{Architecture diagram for this document}
\label{fig:archdiag}
\end{figure}
Fig.~\ref{fig:archdiag} shows the role this document plays within the
IVOA architecture \citep{2021ivoa.spec.1101D}.
TAP depends on the following other IVOA standards:
\begin{description}
\item[UWS \citep{2016ivoa.spec.1024H}] TAP services can be queried
asynchronously; the Universal Worker Service UWS defines the
corresponding communication pattern. Note that while TAP 1.1 does not
require the use of any particular minor version of the UWS standard,
UWS 1.1 can significantly streamline the communication, and
implementors of TAP 1.1 are encouraged to support UWS 1.1 or later.
\item[ADQL \citep{2023ivoa.spec.1215M}] A standards-compliant TAP
service must support queries written in the Astronomical Data Query
Language.
\item[VOSI \citep{2017ivoa.spec.0524G}] The VO Support Interfaces standard
defines endpoints for metadata discovery; for TAP, this is the tables,
capabilities, and availability endpoints. Note that while TAP 1.1 does not
require the use of any particular minor version of the VOSI standard,
the VOSI-tables resource in VOSI 1.1 provides important usability features, and
implementors of TAP 1.1 are encouraged to support VOSI 1.1 or later.
\item[VOTable \citep{2019ivoa.spec.1021O}] All TAP services must be able
to serve query results in the VOTable format. Note that while TAP 1.1 does not
require the use of any particular minor version of the VOTable standard, older
versions are missing features that are required and may be unusable in practice.
For example, the overflow reporting and xtype attribute were introduced in
VOTable 1.2 so that is the minimum viable version that must be used.
\item[SSO \citep{2017ivoa.spec.0524T}] TAP services that support authenticated
access declare this in their capabilities using recommendations and security method
identifiers from the SSO standard.
\end{description}
TAP is related in other ways to the following IVOA standards:
\begin{description}
\item[DALI \citep{2017ivoa.spec.0517D}] The Data Access Layer Interface standard
gives general rules for the construction of DAL standards. TAP has been
written against version 1.1 of DALI. In particular, TAP directly
references DALI 1.1's serialisation rules for geometries and timestamps
and recommends implementing the examples endpoint defined by DALI.
\item[Obscore \citep{2017ivoa.spec.0509L}] The Obscore data model
facilitates the publication of metadata of observational data products.
TAP is used to access compliant metadata collections.
\item[RegTAP \citep{2019ivoa.spec.1011D}] The relational model for the
VO Registry provides a data model for publishing service metadata.
TAP is used to access compliant metadata collections.
\item[TAPRegExt \citep{2012ivoa.spec.0827D}] While there is no formal
requirement to that effect, the response on a TAP service's capabilities
endpoint should contain instances of \xmlel{tr:TableAccess}-typed
capabilities in order to allow clients to discover several important
aspects of a TAP service's capabilities (e.g., resource limits, output
formats, user defined functions).
\item[CDP \citep{2010ivoa.spec.0218P}] TAP services that support authenticated requests may require
delegation of user credentials in order for some features to work; such services
will have an associated credential service and could use delegated credentials for
remote calls that require authentication. For example, a URL specified in the UPLOAD
parameter may require authentication and the service would use delegated credentials
to perform the retrieval.
\end{description}
\subsection{Motivating Use Cases}
Below are some of the more common use cases that have motivated the development
of the TAP specification. While this is not complete, it helps to understand the
problem area covered by this specification.
\subsubsection{Discover Metadata}
Since content in relational databases is often custom and project-specific,
users of a TAP service must be able to discover the names of tables and
columns, datatypes, units, and other information necessary to construct
meaningful correct queries.
\subsubsection{Query Custom Tables}
A large amount of astronomical data and metadata is stored in tables in
relational databases. Historically, users could query these tables through
custom user interfaces (usually web page forms), but such approaches could not
provide support for truly ad-hoc querying. A TAP service should enable users to
discover and query custom tables with a flexible and expressive input that
supports ad-hoc querying: selecting output, filtering the result, joining
multiple tables, computing aggregate quantities, etc.
\subsubsection{Query Standard Tables}
A TAP service should enable users to query externally defined standard tables
in a uniform way such that the same web service request can be sent to multiple
services. Services must be able to declare their support for standard tables in
the service metadata.
\subsubsection{Query Standard Data Models}
A TAP service should enable users to query (parts of) externally defined data
models that are (partially or fully) implemented by the service. Services must
be able to declare their support for data models as well as the way those model
elements are mapped to tables and columns.
\subsection{Query Languages}
\subsubsection{ADQL Queries}
The Astronomical Data Query Language ADQL \citep{2023ivoa.spec.1215M} is the standard
query language for the IVOA. Support for ADQL queries is mandatory. ADQL can be
used to specify queries that access one or more tables provided by the TAP
service, including the standard metadata tables. In general, the client must
access table metadata in order to discover the names of tables and columns and
then formulate queries. ADQL queries provide a direct (low-level) access to the
tables; a query will be written for a specific TAP service and will not be
usable with other services unless the query refers only to common tables and
columns. It is also possible that the service registration (in an IVOA Registry)
may include sufficient table metadata to enable queries to be written directly.
\subsubsection{Other Query Languages}
A TAP service implementor must be able to include support for other query languages, such as
pass-through of native SQL directly to an underlying DBMS or simple key-value
(parameter-based) constraints, without making their service non-compliant with the specification. The service interface must allow for
this and the service capabilities must be able to describe it. This mechanism
also allows future developments within and outside the IVOA to be used without
revising the TAP specification.
\subsection{Query Execution}
\subsubsection{Asynchronous Queries}
Asynchronous queries allow for long running queries to complete without
the client maintaining a connection to the service. Results are stored by
the service for later retrieval by the client. Asynchronous query
execution is generally more robust and not susceptible to time-outs or other
transient failures. They are especially suited to queries that run for a long
time before producing output (e.g. queries that compute or aggregate values).
\subsubsection{Synchronous Queries}
Synchronous queries execute immediately and the client must wait for the query
to finish. Synchronous query execution is generally simpler and provides a
faster (low latency) response and should be adequate when the query will execute
and start returning results quickly. Even with large query results, synchronous
queries are a good approach as long as the service can stream the output
and consume modest internal resources.
\section{Resources}
\label{sec:resources}
An implementation of a TAP service provides the following RESTful resources
under the base URL.
\medskip
\begin{inlinetable}
\begin{tabular}{l l l}
\sptablerule
\textbf{resource type} & \textbf{resource name} & \textbf{required} \\
\sptablerule
TAP-sync & /sync & must \\
TAP-async & /async & must \\
VOSI-availability & service specific & must (must be anonymous) \\
VOSI-capabilities & /capabilities & must (must be anonymous) \\
VOSI-tables & /tables & should \\
DALI-examples & /examples & should \\
\sptablerule
\end{tabular}
\end{inlinetable}
\medskip
A TAP service provides a single base URL with child resources for the various features in the table above.
As required by DALI \citep{2017ivoa.spec.0517D}, all resources (including the optional VOSI-tables
resource) except the VOSI-availability must be siblings of the VOSI-capabilities resource.
The fixed name resources above (async, sync, tables, and examples) are used for both anonymous and
authenticated access to the service; the consequences of having a single base URL are detailed below in
section~\ref{sec:vosi-capabilities}. The VOSI-availability and VOSI-capabilities resources must allow anonymous access as they can be used by clients to determine if the service is available and which resources to use with
available security (authentication) methods.
The web resource at the root of the tree represents the service as a whole.
This specification defines no standard representation for this root resource.
Implementations should return a human readable document (HTML) describing
the service as a whole. TAP clients should not depend on a specific representation
of the root resource.
\subsection{TAP-sync}
\label{sec:tap-sync}
A TAP service must provide one or more web resources that represent the results
of synchronous query execution. The /sync resources must conform to the general rules for
DALI-sync resources. The exact form of the query, and hence the
representation of the resource, is defined by the query parameters as listed in
section~\ref{sec:parameters}. The representation of results of queries is defined in
section~\ref{sec:RESPONSEFORMAT} and section~\ref{sec:votable}.
For query languages that produce a single result (e.g. ADQL) executed using the
/sync endpoint, the result of a successful query is returned in the response or
the response includes an HTTP redirect (303: See Other) to a resource from
which the result may be retrieved.
An HTTP-GET request to the /sync web resource may return a cached copy of the
representation. This cached copy might come from an HTTP cache between the
client and the service, and the service may also maintain its own cache. Clients
which require an up-to-date representation of volatile data or metadata must use
HTTP POST.
\subsection{TAP-async}
\label{sec:tap-async}
A TAP service must provide one or more web resource representing controls for
asynchronous queries. Specifically, the web resource must conform to the general rules
for DALI-async resources and thus represent a job-list
as specified in UWS \citep{2016ivoa.spec.1024H}.
The child web resources of the /async resource are as specified by UWS. These
are descendants of the /async web-resource, and they include a web resource that
represents the eventual result of an asynchronous query, e.g.:
\begin{verbatim}
http://example.com/tap/async/42/results/result
\end{verbatim}
where the base URL for the TAP service is:
\begin{verbatim}
http://example.com/tap
\end{verbatim}
the UWS job list is:
\begin{verbatim}
http://example.com/tap/async
\end{verbatim}
and the job resource is
\begin{verbatim}
http://example.com/tap/async/42
\end{verbatim}
where 42 is an example job identifier. A client making an asynchronous request
must use
the UWS facilities to monitor or control the job. In addition to the job list
and job resource above, UWS specifies the name and semantics of a small set
of child resources used to view and control the job, e.g.:
\begin{verbatim}
http://example.com/tap/async/42/phase
http://example.com/tap/async/42/quote
http://example.com/tap/async/42/executionduration
http://example.com/tap/async/42/destruction
http://example.com/tap/async/42/error
http://example.com/tap/async/42/parameters
http://example.com/tap/async/42/results
http://example.com/tap/async/42/owner
\end{verbatim}
Successful TAP queries produce results which must be accessible as resources
under the UWS result list, e.g.:
\begin{verbatim}
http://example.com/tap/async/42/results/
\end{verbatim}
Failed TAP queries produce an error document (see section~\ref{sec:query-error}) which must be accessible
as the error resource, e.g.:
\begin{verbatim}
http://example.com/tap/async/42/error
\end{verbatim}
For query languages that produce a single result executed using the /async
endpoint, the result of a successful query can be found within the result list
specified by UWS; the result must be named result and thus
clients can access it directly, e.g.:
\begin{verbatim}
http://example.com/tap/async/42/results/result
\end{verbatim}
Access of this resource must deliver the result, either directly or as an HTTP
redirect (303: See Other) to a resource from which the result may be retrieved.
For query languages that may produce multiple result resources, the names of the
results are not specified (they may be specified in the specification for the
language). The client can always access the result list resource as specified by
UWS.
If the query returned no rows, the result resource must exist and contain no
data rows. Details on interacting with these resources are specified in the UWS
standard; for examples specific to TAP see section~\ref{sec:examples} below.
\subsection{VOSI-availability}
\label{sec:vosi-availability}
The use of the VOSI-availability resource is described in DALI.
\subsection{VOSI-capabilities}
\label{sec:vosi-capabilities}
The TAP-1.0 standard is identified using
\begin{verbatim}
ivo://ivoa.net/std/TAP
\end{verbatim}
For TAP-1.1 we use the same standardID value. The version attribute of the interfaces
must use the minor version (e.g. \verb|version="1.1"|) of the TAP standard; clients
should treat a missing version attribute as equivalent to \verb|version="1.0"|.
The interface element within the TAP capability specifies the base URL of the service
under which the fixed-name resources specified above (section~\ref{sec:resources}) are located.
In addition to the accessURL element, the interface element may also contain zero or more securityMethod
elements that specify the supported authentication methods. Zero such elements and a securityMethod with no standardID attribute are both interpreted as meaning anonymous; the latter should only be used if other securityMethod(s) are also specified and zero such elements is preferable in an anonymous-only service.
Here is an example for a document as it might be returned from a VOSI
capabilities endpoint of a TAP service:
\lstinputlisting[language=XML,basicstyle=\footnotesize]
{sample-capability.xml}
This specification requires that exactly one capability with a
standardID of \nolinkurl{ivo://ivoa.net/std/TAP} is present.
In addition to this basic service description, production services
should use the TAPRegExt \citep{2012ivoa.spec.0827D} extension to provide
additional metadata within the TAP capability. Clients should create
the endpoint URLs by appending the fixed endpoint names to the access URL
given in the interface defined in the TAP capability. The TAP capability normally
has a single interface; multiple interfaces are permitted in order to support multiple
versions (different version attribute on the interface element and different
accessURL).
This specification does not require that the capabilities document includes a capability
description for the VOSI features themselves. However, these are needed in the document
and in registry records until such time that another standard (DALI or VOResource)
provides an alternative mechanism to convey required information to clients
(standardID or equivalent, version, accessURL(s), supported securityMethod(s), etc.).
In the example above, the VOSI-tables capability conveys the version (1.1) and that multiple
securityMethod(s) are supported. The version tells clients that a returned tableset may not
contain column metadata and that the detail parameter is supported. The securityMethod(s)
tell clients that authenticating may affect the output such as exposing metadata for
protected tables.
The example above describes a TAP service that can be accessed anonymously or by authenticating with a cookie
(\verb|ivo://ivoa.net/sso#cookie|) or an X509 client certificate (\verb|ivo://ivoa.net/sso#tls-with-certificate|).
The same URL (e.g. \verb|https://example.net/tap/sync| for a synchronous query) would be used for both anonymous and authenticated access.
As a consequence of using a single base URL with fixed name child resources, all supported authentication
methods must be able to co-exist on the same URL.
In the example above, the VOSI-availability and VOSI-capabilities interfaces are anonymous (no securityMethod).
The VOSI-tables interface is typically also anonymous-only, but in the example we show that it may also support
anonymous and/or authenticated access. In general, clients that support authentication should be prepared to discover and use anonymous-only endpoints for some requests.
\subsection{VOSI-tables}
\label{sec:vosi-tables}
The table metadata should be accessible from a web resource with relative URL
/tables that is a direct child of the root web resource. The /tables resource
implements the VOSI-tables capability and output described in VOSI.
The content is equivalent to the metadata from the
\tapschema{} described in section~\ref{sec:tap-schema}. The use of VOTableType
(rather than TAPType) in the VOSI-tables output is recommended because the values
map directly; TAPType may be used when VOTableType does not provide a suitable
alternative.
Services that do not implement the /tables resource must respond with an HTTP
response code of 404 when this resource is accessed.
\subsection{DALI-examples}
\label{sec:dali-examples}
A successful GET from this endpoint MUST yield a document with a MIME type of either
application/xhtml+xml or text/html. A service that does not provide examples
MUST return a 404 HTTP status on accessing this resource.
If present, the endpoint must be represented in a capability in the TAP
service's registry record. The capability's \xmlel{standardID} is defined by
DALI. A capability element could hence look like this:
\begin{lstlisting}[language=XML,basicstyle=\footnotesize]
<capability standardID="ivo://ivoa.net/std/DALI#examples">
<interface xsi:type="vr:WebBrowser">
<accessURL use="full"
>http://myarchive.net/myTAP/examples</accessURL>
</interface>
</capability>
\end{lstlisting}
TAP defines two additional properties for the examples vocabulary:
\begin{itemize}
\item query -- each example MUST have a unique child element with simple text
content having a \xmlel{property} attribute valued {\em query}. It contains the query itself,
preferably with extra whitespace for easy human consumption and editing. This
will usually be a HTML \xmlel{pre} element.
\item table -- examples MAY also have descendants with \xmlel{property} attributes having
the value {\em table}. These must have pure text content and contain fully qualified
table names to which the query is somehow ``pertaining''.
\end{itemize}
Although it might be tempting, examples authors should not put table
names into HTML \xmlel{a} elements (e.g., to link to the table
descriptions). As discussed in DALI 1.1, sect.~2.3, this would result
in invalid RDF statements.
An example of a response from a TAP service's examples endpoint is given
in section~\ref{sec:example-example}.
\subsection{Parameters}
\label{sec:parameters}
The \{async\} and \{sync\} web-resources must accept the parameters listed in
the following sub-sections. In a synchronous request, the parameters select the
representation returned in the response message. In an asynchronous request, the
parameters select the representation of the eventual query result rather than
the response to the initial request.
Requirements on the presence and values of parameters described below are
enforced only when the TAP request is executed (not when individual HTTP
requests are handled). Thus, for asynchronous TAP queries, the parameter
requirements must be satisfied (and errors returned if not) only when the query
is run (in the sense of UWS job execution). Specifically, asynchronous
queries may be created with no parameters and multiple, subsequent HTTP
POST actions may specify the parameters in any order.
Not all combinations of the parameters are meaningful. If a
service receives a spurious parameter in an otherwise correct request, then the
service must ignore the spurious parameter, must respond to the request normally
and must not report errors concerning the spurious parameter.
\subsubsection{LANG}
\label{sec:LANG}
The LANG parameter specifies the query language. The service must support the LANG
parameter and the client must provide a value. The only standard
value for the LANG parameter is ADQL. Support for other
languages and the LANG value to use with them can be described in
TAPRegExt service
capabilities \citep{2012ivoa.spec.0827D}.
For example, an ADQL query would be performed with
\begin{verbatim}
LANG=ADQL
QUERY=<ADQL query string>
\end{verbatim}
A query with a custom query language would be performed with
\begin{verbatim}
LANG=MySecretLang
<MySecretLang-specific parameters>
\end{verbatim}
The value of LANG is a string specifying the language and optionally the
language version used for the query parameter(s), as defined by the service
capabilities. The client may specify the version of the query language, e.g.
LANG=ADQL-2.0 (the syntax should be as shown) or it may omit the version, e.g.
LANG=ADQL. The service should return an “unknown query language” error as
described in section~\ref{sec:query-error} if an unsupported language or an incompatible
language version is specified.
\subsubsection{QUERY}
\label{sec:QUERY}
The QUERY parameter is used to specify queries that are serialised as a single character string, such as an ADQL query (with LANG=ADQL or some version thereof). The interpretation
of the value depends on the value of the LANG parameter. This parameter should also be used to
specify the query for other values of LANG (e.g. LANG=<some RDBMS-specific SQL
variant>) when appropriate.
A service must support the QUERY parameter because ADQL is a required language.
If timestamp comparisons are supported within ADQL queries, they must use the syntax
defined in DALI. Timestamp values may be used if there are columns with timestamp values,
including in uploaded tables if table upload is supported.
If the service supports the use of spatial coordinates in ADQL queries, the output of
geometry values should use the syntax defined in DALI. Services may output geometry values
using the STC-S convention described in the previous version of this standard, but we
strongly recommend switching to the DALI syntax.
If table upload is supported, values using the DALI syntax must be supported and values using
the previous STC-S convention may be supported for backwards compatibility. Input and output of
all values must be supported (e.g. selecting all columns from an uploaded table) for all types
even if comparisons are not supported.
Note: Although it is allowed by the ADQL-2.0 syntax, clients should be careful when
mixing constants and column references for coordinate system and coordinate
values. For example, POINT('ICRS', t.ra, t.dec) does not cause t.ra and t.dec to
be transformed to ICRS; it tells the service to treat the values as
being expressed in that coordinate system. Clients should avoid using the coordinate
system argument to geometric functions (supply the empty string, or use an
alternate function without the coordinate system argument if available).
\subsubsection{FORMAT and RESPONSEFORMAT}
\label{sec:RESPONSEFORMAT}
The RESPONSEFORMAT parameter is fully described in DALI. For
backwards
compatibility, TAP-1.1 must also accept the FORMAT parameter as equivalent to
RESPONSEFORMAT.
Specifying both FORMAT and RESPONSEFORMAT is undefined.
If both the FORMAT and RESPONSEFORMAT parameters are omitted, the
default format is VOTable. A TAP service must support VOTable as an
output format, should support CSV and TSV output, and may support other
formats.
\subsubsection{MAXREC}
\label{sec:MAXREC}
The MAXREC parameter and its effects on the query result are fully described in
DALI. If the result set is truncated in this fashion, it must
include an overflow indicator as specified in section~\ref{sec:query-overflow}.
For the special value of MAXREC=0, the service is not required to execute the
query; a successful MAXREC=0 request does not necessarily mean that the query
is valid and the overflow indicator does not necessarily mean that there is at
least one row satisfying the query. The service may perform validation and may
try to execute the query, in which case a MAXREC=0 request can fail. A query
with MAXREC=0 can be used with a simple query (e.g. SELECT * FROM
some\_table) to extract and examine the VOTable metadata (assuming
RESPONSEFORMAT=votable). Note: in this version of TAP, this is the only mechanism to
learn some of the detailed metadata, such as coordinate systems used.
The output truncation caused by non-zero values of the MAXREC parameter occurs after any
limitations imposed by the query and the overflow indicator is only added if
the query result is actually truncated. For example:
\begin{verbatim}
MAXREC=A
QUERY=select TOP B * from foo
\end{verbatim}
for integer values A and B. Assuming the table contains many rows, if A > B
then the result table will contain B rows and no overflow indicator. If A < B
then the result table will contain A rows and an overflow indicator. If the
table contains A or fewer rows then the result will not contain an overflow
indicator.
\subsubsection{RUNID}
The RUNID parameter is fully described in DALI.
\subsubsection{UPLOAD}
\label{sec:UPLOAD}
The UPLOAD parameter is described in DALI. Services should support
the
upload of temporary tables in VOTable \citep{2019ivoa.spec.1021O} format via the standard
UPLOAD
parameter. The table-name(s) must be legal table names as defined in
ADQL \citep{2023ivoa.spec.1215M} but restricted as described in section~\ref{sec:tap-schema-tables}.
URIs may be simple URLs (e.g. with a URI scheme of http or https) or
URIs that must be resolved (e.g. with a URI scheme of vos or param) to give
the location of the table content.
If table upload is supported, the service must accept tables in VOTable format.
The client specifies the name of the uploaded table; this name must be a legal
ADQL table name with no catalog or schema (i.e., a string following the
regular identifier production of ADQL). Uploaded tables must be
referred
to in queries as \tapupload.<tablename>, where <tablename> is the name
specified by the user. Tables in the \tapupload{} schema are
transient and persist only for the lifetime of the query (although caching might
be used behind the scenes) and are never visible in the
\tapschema{} metadata.
For uploaded tables, the name attribute of the FIELD element is used as the column
name. Services must support delimited identifiers so that
FIELD names that are not valid ADQL column names work correctly.
The DALI UPLOAD parameter supports both external resources and
in-line
content. For external resources, one provides a URI (usually an HTTP URL) the
TAP service can use to obtain the table content. For example,
\begin{verbatim}
HTTP POST http://example.com/tap/async/42
UPLOAD=mytable,http://otherplace.com/path/votable.xml
\end{verbatim}
The service would retrieve the table from the provided URL and
make it visible to the query as \tapupload.mytable.
If the TAP service supports VOSpace URIs, one may
specify an upload table using a URI to a table stored in a VOSpace, for example:
\begin{verbatim}
HTTP POST http://example.com/tap/async/42
UPLOAD=mytable,vos://space/path/votable.xml
\end{verbatim}
The service would resolve the URI, contact the VOSpace, retrieve the table, and
make it visible to the query as \tapupload.mytable.
UPLOADs are accumulating, i.e., each UPLOAD parameter given will create one or
more tables in \tapupload. When the table names from two or more
upload items agree after case folding, the service behaviour is unspecified.
Clients thus cannot reliably overwrite uploaded tables; to correct errors, they
have to tear down the existing job and create a new one. In principle, any
number of tables can be uploaded using the UPLOAD parameter and any combination
of URI schemes supported by the service as long as they are assigned unique
table names within the query. Services may limit the size and number of
uploaded tables; if the service refuses to accept the entire table it must
respond with an error as described in section~\ref{sec:query-error}.
Table upload must support all valid VOTable content even if they do not support
all features and uses of extended data types; clients must be able to upload and then
query a valid table and round-trip all values. Services should store extended types (e.g.
timestamp) in an appropriate database column type in order to facilitate predictable use
in queries.
\section{Use of VOTable}
\label{sec:votable}
VOTable \citep{2019ivoa.spec.1021O} is the standard format for output (query
results) and input (table upload) in a TAP service so most of this section
deals with how VOTable is used. However, rules about serialising column values
also apply to other formats (e.g. CSV and TSV).
The use of VOTable is described in DALI, with additional clarifications
or advice below.
\subsection{INFO elements}
\label{sec:vot-info}
The RESOURCE element must contain INFO element(s) as described in DALI.
Additional INFO elements may be provided, e.g., to echo the input parameters
back to the client in the query response (a useful feature for debugging or
self-documenting the query response), but clients should not depend on these.
\begin{verbatim}
<RESOURCE type="results">
...
<INFO name="QUERY" value="select * from stuff.items" />
...
</RESOURCE>
\end{verbatim}
\subsection{Successful Queries}
\label{sec:query-ok}
The result of a query depends on the query language used and may be one or more
tables in one or more resources. Unsupportable combinations of query results and
RESPONSEFORMAT (e.g. queries that produce multiple tables and an inherently
single-table format like CSV) will cause the request to fail. Currently, an ADQL
query result must be a single table (in a single file).
The output table must include the same number and order of columns as specified
in the SELECT clause of the query. For VOTable output, the name attribute of
FIELD elements must be the same as the column names (or aliases if specified)
in the query and the datatype, arraysize, and xtype
attributes of FIELD elements must be set using the values from the \tapschema.
In cases where items in the select list do not
have names (e.g. expression or function invocation without an alias) the service
must generate a name;
generated names must be unique (within the output table) and should be valid
ADQL identifiers.
CSV formatted data should represent the output table with one row of text per
table row, with the table column values rendered as text.
If a column value contains a comma, the entire column value should be
enclosed in double quotes. Text lines may be arbitrarily long. The first data
row should give the column name(s) as the data value. CSV data must be returned
with a MIME type of text/csv; if the optional header line (with column names)
is included, the MIME type must be text/csv;header=present. Full details of CSV
format are defined in \citet{std:CSV}.
TSV formatted data should represent the output table with one row of text per
table row, with the table column values rendered as text and separated by the
TAB character. TSV data must be returned with a MIME type of
text/tab-separated-values as described in
\citet{std:TSV}. Column values may not contain the
TAB
character.
\subsection{Errors}
\label{sec:query-error}
If the service detects an exceptional condition, it must return an error
document with an appropriate HTTP-status code. TAP distinguishes three classes
of exceptions.
\begin{itemize}
\item Errors in the use of the HTTP protocol.
\item TAP-level errors: Invalid TAP requests
\item TAP-level errors: Failure of the service to complete a valid request.
\end{itemize}
Error documents for HTTP-level errors are not specified in the TAP protocol.
Responses to these errors are typically generated by service containers and
cannot be controlled by TAP implementations. There are several cases where a
TAP
service could return an HTTP error. First, the /async endpoint could return a
404 (not found) error if the client accesses a job within the UWS job list that
does not exist. Second, access to a resource could result in an HTTP 401 (not
authorized) error if authentication is required or an HTTP 403 (forbidden)
error if the client is not allowed to access the resource.
Error documents should be in a format that matches the requested
format where possible; see DALI for details.
If the error document is being retrieved
from the /async/<jobid>/error resource (specified by UWS) after an asynchronous
query, the HTTP status code should be 200. If the error document is being
returned directly after a synchronous query, the service may use an appropriate
HTTP status code, including 200 (successfully returning a response to the
request) and various 4xx and 5xx values.
\subsection{Overflows}
\label{sec:query-overflow}
If a query is executed by a TAP service, the number of rows in the table of
results may exceed a limit requested by the user (using the MAXREC parameter)
or a limit set by the service implementation (the default or maximum value of
MAXREC). In these cases, the query is said to have ``overflowed''. Typically, a
TAP service will not detect an overflow until some part of the table of results
has been sent to the client.
If an overflow occurs, the TAP service must produce a table of results that is
valid, in the required output format, and which contains all the results up to
the point of overflow. Since an output overflow is not an error condition, the
MIME type of the output must be the same as for any successful query and the
HTTP status-code must be as for a successful, complete query.
Reporting of overflow depends on the output format and is described in DALI.
\subsection{Mapping Table Datatypes}
\label{sec:vot-rdbms}
The mapping between VOTable and database tables uses the datatype, arraysize, and xtype values from
the VOTable FIELD elements and the TAP\kern-3pt\_SCHEMA.columns table. Mapping for primitive types
(numbers and strings) is straightforward; services should ensure that input values behave as
expected in query processing and output values should have correct and complete metadata. Mapping for specially
structured values use xtype(s) as specified in DALI. The behaviour and usability of such structured values in
queries depends on the query language (section~\ref{sec:LANG}) being used and support for optional features
of the language.
Datatype mapping rules apply to input tables supplied via an UPLOAD parameter (see section~\ref{sec:UPLOAD})
and to result tables after successful query execution. TAP services should at least be able to round-trip all
values from an uploaded VOTable to the database and back when columns in the uploaded table are selected (e.g.
\verb|SELECT * from TAP_UPLOAD.mytable|).
\section{Metadata: TAP\kern-3pt\_SCHEMA}
\label{sec:tap-schema}
There are several approaches to getting metadata for a given TAP service. All
TAP services must support a set of tables in a schema named
\tapschema\ that describes the tables and columns included in the
service. In addition to the \tapschema, there are two other ways
to get metadata from a TAP service. First, the VOSI tables resource provides
metadata on all tables and columns; this resource is described in
section~\ref{sec:vosi-tables}. The
VOSI tables resource provides the same metadata as the \tapschema{}
but in a rigorously controlled format; the information in the
\tapschema{} is equivalent to that defined by VODataService
\citep{2021ivoa.spec.1102D}. Second, the client may specify a query of one or more
tables setting the
MAXREC parameter to 0 so that only the metadata regarding the requested fields
is returned. Use of MAXREC is described in section~\ref{sec:MAXREC}.
The \tapschema{} provides access to table, column, and join key
metadata through the TAP query mechanisms themselves. Users can discover tables
or columns that meet their specific criteria by querying the tables described
below. The service may enhance the \tapschema{} with additional
metadata where that seems appropriate; since it is self-describing, the
\tapschema{} may be queried to determine if any extended schema
metadata is defined by the service. Services must provide these tables and make
them accessible by all supported query mechanisms.
Column datatypes in the \tapschema{} are specified using the same concepts used in
VOTable: datatype, arraysize, and xtype. For backward compatibility, implementors
must also include the \verb|"size"| column and populate it where possible. In the details
below, \tapschema{} column types are either string or integer; implementers may choose an
appropriate data type that behaves the same way in queries and output (e.g. varchar(16) or
varchar(64) for string and smallint, int, or bigint for integer.
Implementors should use datatype and arraysize values
that best describe their implementation of the \tapschema{} tables (e.g., datatype char
and arraysize 64* to describe a column with database type varchar(64)).
Implementors may include additional tables in the
\tapschema{} to describe additional aspects of their service not
covered by this specification. Implementors may also include additional columns
in the standard tables described below. For example, one could include a column
with a timestamp saying when metadata values were last modified.
\subsection{Schemas}
\label{sec:tap-schema-schemas}
The table \tapschema.schemas must contain the following columns:
\begin{inlinetable}
\begin{tabular}{l l l}
\sptablerule
\textbf{column name} & \textbf{type} & \textbf{not-null} \\
\sptablerule
schema\_name & string & true \\
utype & string & false \\
description & string & false \\
schema\_index & integer & false \\
\sptablerule
\end{tabular}
\end{inlinetable}
The schema\_name values must be unique and may be qualified by the
catalog name or not depending on the implementation requirements. The fully
qualified schema name is defined by the ADQL language and follows the pattern
[catalog.]schema. The schema metadata are included for reference and are not
used directly to construct queries.
\subsection{Tables}
\label{sec:tap-schema-tables}
The table \tapschema.tables must contain the following columns:
\begin{inlinetable}
\begin{tabular}{l l l}
\sptablerule
\textbf{column name} & \textbf{type} & \textbf{not-null} \\
\sptablerule
schema\_name & string & true \\
table\_name & string & true \\
table\_type & string & true \\
utype & string & false \\
description & string & false \\
table\_index & integer & false \\
\sptablerule
\end{tabular}
\end{inlinetable}
The table\_name values must be unique. The value of the
table\_name should be the string that is recommended for use in
querying the table; it may or may not be qualified by schema and catalog name(s)
depending on the implementation requirements. The fully qualified table name is
defined by the ADQL language and follows the pattern [[catalog.]schema.]table.
If the table name is such that the name must be quoted (delimited identifier in
ADQL) then the value must include the quotes.
The table\_type value must be either table or view.
The table\_index is used to recommend table ordering for clients. Clients
may order by table\_index (ascending) so lower index tables would appear
earlier in a listing.
\subsection{Columns}
\label{sec:tap-schema-columns}
The table \tapschema.columns must contain the following columns:
\begin{inlinetable}
\begin{tabular}{l l l}
\sptablerule
\textbf{column name} & \textbf{type} & \textbf{not-null} \\
\sptablerule
table\_name & string & true \\
column\_name & string & true \\
datatype & string & true \\
arraysize & string & false \\
xtype & string & false \\
``size'' & integer & false \\
description & string & false \\
utype & string & false \\
unit & string & false \\
ucd & string & false \\
indexed & integer & true \\
principal & integer & true \\
std & integer & true \\
column\_index & integer & false \\
\sptablerule
\end{tabular}
\end{inlinetable}
The table\_name,column\_name (pair) values must be unique. If the column name is such that
the name must be quoted (delimited identifier in ADQL) then the value must include the quotes.
The type of a database column is described in the \tapschema.columns
table using three columns with an additional (deprecated) column from TAP-1.0
for backwards compatibility. The allowed values for datatype and the syntax for arraysize
are specified in VOTable \citep{2019ivoa.spec.1021O}. Values for xtype are not restricted per se but
implementors should use standard values such as those defined in DALI before
inventing new xtype(s).
The arraysize column gives the length of fixed and variable length datatypes using the VOTable
array shape syntax. For example, a database column of type varchar(256) would be
described with datatype ``char'' and arraysize ``256*''. Arrays, including multi-dimensional
arrays, are permitted for all VOTable primitive types. The \verb|"size"| column is retained for backwards
compatibility to TAP-1.0 and must contain the integer value equivalent to arraysize when
possible (ignoring the variable-size indicator in arraysize) and must be null if arraysize is null or
represents a multi-dimensional array. For example, a column description with arraysize=``256*'' must also have
\verb|"size"|=``256''. Both arraysize and \verb|"size"| must be null for scalar numeric columns.
To use the \verb|"size"| column in a query, the column name must be put in double quotes since
it collides with an ADQL reserved word. Since delimited identifiers are case-sensitive, for the