Skip to content

Enumeration support in ADQL #104

@tcivera

Description

@tcivera

An enumeration is a way to assign human-readable names to specific constant values (often integers). They improve query readability, make queries self-explanatory, and reduce errors, while they also can allow the underlying data to be stored efficiently as integers instead of text.

At CEFCA/OAJ, we have been using enumerations in our TAP service for years, and they are widely appreciated by our users. The syntax we use is:

enumeration_name::item_name

Examples of enumeration usage

  1. Accessing elements in array columns

In our service, object magnitudes are stored in arrays, where each position corresponds to a different filter. So, for example, if an user wants to access to the magnitude of filter rSDSS without enumerations, they must write:

SELECT mag_auto[1] ...

This is less readable and forces users to remember the position of each filter, whereas with enumerations they can write a clearer query that reduces the likelihood of mistakes, such as:

SELECT mag_auto[jplus::rSDSS] ...

Where:

jplus = enumeration defining the set of filters
rSDSS = specific filter in the enumeration

  1. Representing calibration methods, external catalogue names, etc.

In some of our data releases, we provide different image zero points obtained using different methods or we provide the crossmatch of our data with external catalogues. Instead of storing their names as text, we store them as integers, which is more efficient and avoids inconsistencies (e.g., slightly different strings referring to the same method or catalogue).

So, for example, if a user wants to retrieve only the zero points obtained using one of our calibration methods (the Stellar and White Dwarf Loci method), without enumerations they must write:
SELECT ZPT, ERRZPT,... FROM jplus.CalibTileImage WHERE CALIB_PROCEDURE = 8

Whereas with enumerations they can write:

SELECT ZPT, ERRZPT,... FROM jplus.CalibTileImage WHERE CALIB_PROCEDURE = calibration_method::SWDL

In conclusion, I would like this concept to be considered for inclusion in the ADQL standard, as I believe it could be useful not only in our case but also for other data centers and archives.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions