Restrictions on SQL92
Built-in Functions
ADQL allows users to call built-in functions defined on the server system, with a minimum set specified in the SkyNodeInterface These scalar-valued functions include utilities for calculating great circle distances and converting units, such as from sexagesimal to decimal The SkyNodeInterface also provides a method for discovering all available functions on the server Users can leverage these functions in ADQL if they are aware of their existence in the target system, such as SkyNode.
Select HEALPIXID(a.ra, a.dec), a.ra, a.dec from photobjall a
A concise set of common built-in functions that represent the necessary astronomical functionality, together with their standard function names, will be defined in later versions of the ADQL specification.
INTO clause
INTO is a supported feature for VOSpace, allowing users to utilize the 'select into' command in SQL to create new tables or insert data into existing ones In ADQL, a similar functionality is anticipated, enhancing data management capabilities within the system.
The VOSpace endpoint is where files or tables can be created or appended Specifying this endpoint is not included in ADQL, which only provides the syntax necessary for defining a destination.
Select g.* into VOS:/JHU/gal from galaxy g where g.redshift > 3.5
1 http://cui.unige.ch/db-research/Enseignement/analyseinfo/AboutBNF.html#Johnson75
Comments
Comments in code must be formatted using the /* */ syntax and can only be placed before or after the main query It is important to note that comments cannot be inserted within the actual query itself.
Extensions to SQL92
Aliases
All table names in ADQL must have an alias Aliasing tables is a part of standard SQL but we are enforcing this in ADQL/s.
This means queries in ADQL/s must take the form
This makes substitution of table names much easier as it must be done in only one place to change the alias.
Regions
ADQL supports the region specification as defined by the region.xsd [3] of the
IVOA/NVO For this and RegionXML specified below we shall create some default coordinate systems and units to simplify the regions initially See subsection 2.4 for its detailed specification.
Mathematical Funtions
JDBC [4] Mathematical functions shall be allowed in ADQL as follows:
Trigonometric functions: acos, asin, atan, atan2, cos, cot, sin, tan
Math functions: abs, ceiling, degrees, exp, floor, log, log10, mod, pi, power, radians, sqrt, rand, round, truncate.
XMATCH
XMATCH refers to the process of crossmatching multiple astronomical catalogs and is applicable at a portal or SkyNode that allows for table uploads for matching While the semantic definition of XMATCH is detailed in the SkyNodeInterface specification, this document focuses solely on its syntax In ADQL, XMATCH is used in the WHERE clause and functions similarly to a function, with each parameter representing a table to be crossmatched, and the final parameter indicating the sigma value for the chi-square match.
SELECT o.objId, o.ra, o.r, o.type, t.objId
Please note this is a change as of ADQL0.8 Prior to this the sigma value was outside the bracket as in XMATCH(o, t) 100 Jansky
Table Names with special chars\
ADQL allows the use of square brackets ‘[ ]’ to enclose literal names that might trigger parsing errors For instance, if a table name begins with a number, the parser may struggle to process it; however, using brackets makes it valid.
This is also true for table names with spaces in or tables whose names are reserved words Many database systems also support this syntax.
Version information
ADQL/x documents must include a version identifier, starting with 1.0, represented as a dot-separated string of numbers This version number allows the receiving node to determine whether to process the document or raise an exception It is anticipated that this feature will be particularly relevant during major version changes that may introduce incompatibilities Our goal is to maintain backward compatibility by adding new features without deprecating existing ones.
Sample applications and tutorials for development and deployment of ADQL services is available at http://skyservice.pha.jhu.edu/develop/vo/adql/
Regions
ADQL/s will include support for the Region keyword, allowing users to specify a region using a single quoted string This approach mirrors the existing SDSS coverage specification, providing a straightforward method for defining spatial areas in queries.
The conversion process is unidirectional: when an ADQL/s string is transformed into ADQL/x, the Region string is converted into XML format If the ADQL/x is subsequently converted back to ADQL/s, the Region must still be represented as inlined XML, utilizing the RegionXML keyword.
A comment section may be incorporated into the region.xsd, preserving the original string This section will serve display purposes in specific areas and should include a concise summary description of the region in English.
Other constructs mentioned in [5] are RECT, POLY, and CHULL are also supported.
As implied above it is possible to inline a region specification as in ADQL/s using the RegionXML keyword e.g (not a valid region spec )
RegionXML (‘ICRS19.5- 36.70.02’)
It is also possible to refer to a region specification as a URL in ADQL/s using the
RegionURL (‘http://aserver.edu/aregion.xml’)
An ADQL/s might be as follows:
This would be represented in ADQL/x as follows:
LPAREN searchCondition
// expression comparisonOperator expression comparisonOperator ( expression
| (ALL | SOME | ANY) LPAREN selectStatement RPAREN
LIKE expression (ESCAPE expression)? // only single char
| CONTAINS LPAREN (dbObject | STAR) COMMA (stringLiteral | Variable) RPAREN
| FREETEXT LPAREN (dbObject | STAR) COMMA (stringLiteral | Variable) RPAREN
); region: REGION LPAREN regionClause RPAREN {adqlb.StackRegion();}; regionClause: QuotedIdentifier; xMatch: XMATCH LPAREN xAlias (COMMA xAlias)* (
){adqlb.StackXMatch();}; xSigma: number; selectList : selectItem ( COMMA selectItem )*; selectItem :
(STAR // "*, *" is a valid select list
// starts with: "alias = column_name"
(alias2 dbObject COMMA) => alias2 column
| (alias2 dbObject (binaryOperator | LPAREN)) => alias2 expression
| (dbObject (alias1)? COMMA) => column (alias1)?
| (dbObject (binaryOperator | LPAREN) ) => expression (alias1)?
){adqlb.AddSelectItem();}; fromClause : {adqlb.from();}FROM tableSource (COMMA tableSource)*; tableSource : subTableSource (joinedTable)*; subTableSource :
| (archiveTable)? dbObject (alias1)? ( (WITH)? LPAREN tableHint (COMMA tableHint)* RPAREN )?
| (CONTAINSTABLE | FREETEXTTABLE) LPAREN dbObject COMMA (dbObject | STAR) COMMA (stringLiteral | Variable) (COMMA Integer)?
| COLON COLON function (alias1)? // built-in function
// "joinHint JOIN" is invalid join expression
| ( (INNER | (LEFT | RIGHT | FULL) (OUTER)? ) (joinHint)? )? JOIN tableSource ON searchCondition; joinedTables : subTableSource (joinedTable)+; joinHint : LOOP | HASH | MERGE | REMOTE; tableHint :
LPAREN (identifier | Integer) ( COMMA (identifier | Integer) )* RPAREN
| ASSIGNEQUAL identifier // old index hint syntax
; alias1 : // alias name can also be single-quoted literal (but not for table names)
ASSIGNEQUAL; xAlias: {adqlb.StackXAlias();} (NOT alias1 | QUESTIONMARK alias1 | alias1); tableColumns : dbObject DOT_STAR; column :
(PLUS)* // "++column_name" is valid and updatable column name
// for expression like "(column)" SQL Server returns updatable column
(collate)? // it is not well documented but COLLATE can be used almost anywhere
(selectStatement) => selectStatement // select statement returning a single value
(collate)?; // it is not well documented but COLLATE can be used almost everywhere expression2: expression; function : // LEFT and RIGHT keywords are also function names
(dbObject | LEFT | RIGHT ) LPAREN ( expression (COMMA expression)*
| STAR // aggregate functions like Count(), Checksum() accept "*" as a parameter
| (ALL | DISTINCT) (STAR | expression) // aggregate function
| Variable ASSIGNEQUAL expression (COMMA Variable ASSIGNEQUAL expression)*
RPAREN; starArg: STAR {adqlb.StackStar();};
//don't use these directly aggregateFunction: (AVG|MAX|MIN|SUM|COUNT)
{adqlb.StackAggregateOp();} LPAREN (starArg|expression) RPAREN; trigFunction: (SIN|COS|TAN|COT|ASIN|ACOS|ATAN|ATAN2)
{adqlb.StackTrigOp();} LPAREN expression RPAREN; mathFunction: (CEILING|DEGREES|EXP|FLOOR|LOG|PI|POWER|RADIANS|SQRT| SQUARE|LOG10|RAND|ROUND|TRUNCATE) {adqlb.StackMathOp();}
//use this one explicitFunction: (aggregateFunction | trigFunction | mathFunction) {adqlb.CloseFunction();}; archiveTable : {adqlb.StackArchiveTable();} identifier COLON; caseFunction :
CASE ( expression (WHEN expression THEN expression)+
| (WHEN searchCondition THEN expression)+ // boolean expression
; castFunction : CAST LPAREN expression AS identifier (LPAREN Integer (COMMA Integer)? RPAREN)? RPAREN; dbObject : {adqlb.StackDBObject();}
DOT (identifier | IDENTITYCOL | ROWGUIDCOL | keywordAsIdentifier)
| (DOT DOT) => DOT DOT (identifier | IDENTITYCOL | ROWGUIDCOL
; stringLiteral : UnicodeStringLiteral | ASCIIStringLiteral; identifier: NonQuotedIdentifier | QuotedIdentifier; constant :
ODBCDateTime | systemVariable; unaryOperator : PLUS | MINUS | TILDE
; binaryOperator : arithmeticOperator | bitwiseOperator; arithmeticOperator : {adqlb.StackArithmeticOperator();} (PLUS | MINUS | STAR | DIVIDE | MOD); bitwiseOperator : AMPERSAND | TILDE | BITWISEOR | BITWISEXOR
); logicalOperator : ALL | AND | ANY | BETWEEN | EXISTS | IN | LIKE | NOT | OR | SOME
************** class SqlLexer extends Lexer; options { testLiterals = false; k = 2; caseSensitive = false; caseSensitiveLiterals = false; charVocabulary='\u0000' '\uFFFE';
// Operators protected DOT:; // generated as a part of Number rule
// LITERALS protected Letter : 'a' 'z' | '_' | '#' | '@' | '\u0080' '\ufffe'; protected Digit : '0' '9'; protected Integer :; protected Real :; protected Exponent : 'e' (Sign)? (Digit)+ ; protected Sign : (PLUS | MINUS);
| '.' { _ttype = DOT; } ( (Digit)+ (Exponent)? { _ttype = Real; } )?
| "0x" ('a' 'f' | Digit)* { _ttype = HexLiteral; } // "0x" is valid hex literal
; protected Currency : // generated as a part of NonQuotedIdentifier rule
| ('a' 'z' | '_' | '#' | '\u0080' '\ufffe') (Letter | Digit)* // first char other than '@'
// test for literals in case of a function begining with '@' (eg "@@ERROR") options { testLiterals = true; }
HexLiteral // generated as a part of Number rule
The XML schema defines the structure for ADQL (Astronomical Data Query Language) version 0.9, utilizing namespaces such as tns for ADQL, xs for XML Schema, and reg for STC region specifications It ensures that elements are qualified under the specified target namespace, facilitating standardized data queries in astronomical contexts.
The base type for any of items to be selected in a query
The base type for a scalar expression
Represents an expression inside a bracket
Represents a binary expression such as a+b
Used for expressing operations like A+B
Represents an unary expression such as -(a.ra)
Operators for expressing a single element operation
Represents a column
Encapsulates basic literals such as Strings, Integers and Real numbers
The base type for all literals
The base type for all numbers
Represents a real number
Represents an integer
Represents a string literal
The base type for a function
Option of selecting all or distinct elements in a query
Enumeration for All and Distinct options
Represents a trigonometric function
Enumeration of allowed trigonometric functions
Represents a math function
Enumeration of allowed math functions
Represents an aggregate function
Enumeration of allowed aggregate functions
Used to select an expression as a new alias column
Represent all columns as in Select * query
The Comparison operators such as Less-than or More-than, etc
The base type for all tables used in the From clause of the query
Same as a tableType with an additional archive name
Represents a table with its name and its alias name
The base type for all table inclusion or drop types used in a cross match expression
Used for adding a table for the Xmatch operation
Used for avoiding a table in Xmatch
The base type for searches in Where and Having clauses of the query
Represents expressions like A And B
Represents expressions like A Or B
A cross match expression
The Like expression of a query
The Not Like expression of a query
Represents SQL NOT IN expression
The base type for selection set in a SQL IN expression
Represents the subquery in a SQL IN expression
Represents expressions like (A)
Represents the Comparison of two expressions
Represents the Between expression of a query
Represents the Not Between expression of a query
Represents expressions like Not A
Represents the Regions such as circle in Where clause
Represents the Having expression part of a query
Represents the Group By expression part of a query
Represents the Where part of the query
Represents the From part of the query
List of items to be selected in the Query
Represents the TOP part of a query
Represents the SQL INTO expression
Ascending or Descending order of an Order by term
Option for setting the direction for Order By
Represents the ORDER BY part of a query
List of expressions in which order the results should be provided
Represents a list of constants provided for a SQL IN expression
Represents SQL IN expression
The only permitted root element of a query, the SELECT element
The SELECT part of a query
Represents user defined function expressions
Denotes the type of a Join operation
Represents SQL JOIN expression
Represents an array of tables in the from expression