labkey.getQueryDetails: Retrieve detailed information on a LabKey query

View source: R/labkey.getQueryInfo.R

labkey.getQueryDetailsR Documentation

Retrieve detailed information on a LabKey query

Description

Fetch a list of output columns and their attributes that are avaialble from a given query

Usage

labkey.getQueryDetails(baseUrl, folderPath, schemaName, queryName)

Arguments

baseUrl

a string specifying the address of the LabKey Server, including the context root

folderPath

a string specifying the hierarchy of folders to the current folder (container) for the operation, starting with the project folder

schemaName

a string specifying the schema name in which the query object is defined

queryName

a string specifying the name of the query

Details

Queries have a default output list of fields defined by the "default view" of the query. To retrieve that set of fields with their detailed properties such as type and nullability, use labkey.getQueryDetails function. Function arguments are the components of the url that identify the location of the server, the folder path, the schema, and the name of the query.

The results from getQueryDetails describe the “field names” that are used to build the colSelect, colFilter and colSort parameters to selectRows. Each column in the data frame returned from selectRows corresponds to a field in the colSelect list.
There are two types of fieldNames that will be reported by the server in the output of this function. For fields that are directly defined in the query corresponding the queryName parameter for this function, the fieldName is simply the name assigned by the query. Because selectRows returns the results specified by the default view, however, there may be cases where this default view incorporates data from other queries that have a defined 1-M relationship with the table designated by the queryName. Such fields in related tables are referred to as “lookup” fields. Lookup fields have multi-part names using a forward slash as the delimiter. For example, in a samples data set, if the ParticipantId identifies the source of the sample, ParticipantId/CohortId/CohortName could be a reference to a CohortName field in a Cohorts data set.

These lookup fieldNames can appear in the default view and show up in the selectRows result. If a field from a lookup table is not in the default view, it can still be added to the output column list of labkey.selectRows. Use the labkey.getLookups to discover what additional fields are available via lookups, and then put their multipart fieldName values into the colSelect list. Lookup fields have the semantics of a LEFT JOIN in SQL, such that every record from the target queryName appears in the output whether or not there is a matching lookup field value.

Value

The available schemas are returned as a data frame:

queryName

the name of the query, repeated n times, where n is the number of output fields from the query


fieldName

the fully qualified name of the field, relative to the specified queryName.


caption

a more readable label for the data field, appears as a column header in grids


fieldKey

the name part that identifies this field within its containing table, independent of its use as a lookup target.


type

a string specifying the field type, e.g. Text, Number, Date, Integer


isNullable

TRUE if the field can be left empty (null)


isKeyField

TRUE if the field is part of the primary key


isAutoIncrement

TRUE if the system will automatically assign a sequential integer in this on inserting a record


isVersionField

TRUE if the field issued to detect changes since last read


isHidden

TRUE if the field is not displayed by default


isSelectable

reserved for future use.


isUserEditable

reserved for future use.


isReadOnly

reserved for future use


isMvEnabled

reserved for future use


lookupKeyField

for a field defined as a lookup the primary key column of the query referenced by the lookup field; NA for non-lookup fields


lookupSchemaName

the schema of the query referenced by the lookup field; NA for non-lookup fields


lookupDisplayField

the field from the query referenced by the lookup field that is shown by default in place of the lookup field; NA for non-lookup fields


lookupQueryName

the query referenced by the lookup field; NA for non-lookup fields. A non-NA value indicates that you can use this field in a call to getLookups


lookupIsPublic

reserved for future use


Author(s)

Peter Hussey, peter@labkey.com

See Also

labkey.selectRows, makeFilter, labkey.executeSql, labkey.updateRows, labkey.insertRows, labkey.importRows, labkey.deleteRows, labkey.getSchemas, labkey.getQueries, labkey.getQueryViews, labkey.getDefaultViewDetails, labkey.getLookupDetails

Examples

## Not run: 

## Details  of fields of a query
# library(Rlabkey)

queryDF<-labkey.getQueryDetails(
	baseUrl="http://localhost:8080/labkey",
	folderPath="/apisamples",
	schemaName="lists",
	queryName="AllTypes")


## End(Not run)

Rlabkey documentation built on Oct. 23, 2024, 5:06 p.m.