Package gavo :: Package adql :: Module fieldinfo
[frames] | no frames]

Module fieldinfo

source code

Field Infos -- annotations to ADQL parse nodes carrying values.

To do this, we have a set of naive heuristics how types, ucds, and units behave when such "fields" are combined. Since right now, we don't parse out enough and, at least for ucds and units we don't have enough data to begin with, much of this is conjecture.

Classes
  Coercions
A tree of types that can be used to infer common types.
  FieldInfo
is a container for meta information on columns.
Functions
 
getSubsumingType(sqlTypes)
returns an approximate sql type for a value composed of the types mentioned in the sequence sqlTypes.
source code
Variables
  __package__ = 'gavo.adql'
Function Details

getSubsumingType(sqlTypes)

source code 

returns an approximate sql type for a value composed of the types mentioned in the sequence sqlTypes.

Basically, we have the coercion sequence int -> float -> text, where earlier types get clobbered by later ones. And then there's messy stuff like dates. We don't want to fail here, so if all else fails, we just make it a text.

Since we don't know what operation is being performed, this can never be accurate; the idea is to come up with something usable to generate VOTables from ADQL results.

We do arrays (and subsume them by subsuming all types and gluing a [] to the result; the char(x) and friends are all subsumed to text.

All intput is supposed to be lower case.

>>> getSubsumingType(["smallint", "integer"])
'integer'