gavo.adql.fieldinfos module

FieldInfos are collections of inferred metadata on the columns present within ADQL relations.

In generation, this module distinguishes between query-like (select…) and table-like (from table references) field infos. The functions here are called from the addFieldInfo methods of the respective nodes classes.

class gavo.adql.fieldinfos.FieldInfos(parent, context)[source]

Bases: object

A base class for field annotations.

Subclasses of those are attached to physical tables, joins, and subqueries.

The information on columns is kept in two places:

  • seq – a sequence of attributes of the columns in the

    order in which they are selected

  • columns – maps column names to attributes or None if a column

    name is not unique. Column names are normalized by lowercasing here (which, however, does not affect L{utils.QuotedName}s).

A FieldInfos object is instantiated with the object it will annotate, and the annotation (i.e., setting of the fieldInfos attribute on the parent) will happen during instantiation.

addColumn(label, info)[source]

adds a new visible column to this info.

This entails both entering it in self.columns and in self.seq.


raises an IncompatibleTables if the FieldInfos other have different length or names from self.


returns a deep copy self, parented to newParent.

getFieldInfo(colName, refName=None)[source]

returns a FieldInfo object for colName.

Unknown columns result in a ColumnNotFound exception.

refName is ignored here; we may check that it’s identical with parent’s name later.


returns a table instance matching the node.TableName refName.

If no such table is in scope, the function raises a TableNotFound.

class gavo.adql.fieldinfos.QueryFieldInfos(parent, context)[source]

Bases: gavo.adql.fieldinfos.FieldInfos

FieldInfos inferred from a FROM clause.

To instantiate those, use the makeForNode class method below.

enclosingQuery = None
getFieldInfo(colName, refName=None)[source]

returns a field info for colName in self or any tables this query takes columns from.

To do that, it collects all fields of colName in self and subTables and returns the matching field if there’s exactly one. Otherwise, it will raise ColumnNotFound or AmbiguousColumn.

If the node.TableName instance refName is given, the search will be restricted to the matching tables.

getFieldInfoFromSources(colName, refName=None)[source]

returns a field info for colName from anything in the from clause.

That is, the columns in the select clause are ignored. Use this to resolve expressions from the queries’ select clause.

See getFieldInfo for refName

classmethod makeForNode(queryNode, context)[source]

cf. TableFieldInfos.makeForNode.

class gavo.adql.fieldinfos.TableFieldInfos(parent, context)[source]

Bases: gavo.adql.fieldinfos.FieldInfos

FieldInfos coming from something that’s basically a table in the DB.

This includes joins.

To instantiate those, use the makeForNode class method below.

classmethod makeForNode(tableNode, context)[source]

returns a TableFieldInfos instance for an ADQL tableNode.

context is an AnnotationContext.

Whatever tableNode actually is, it needs an originalTable attribute which is used to retrieve the column info.

gavo.adql.fieldinfos.tableNamesMatch(table, toName)[source]

returns true when table could be referred to by toName.

This means that either the name matches or toName is table’s original name.

toName is a qualified name (i.e., including schema), table is some node that has a tableName.