SCHEMA QUERY

In a data query, you can use the SCHEMA QUERY operator to introspect a data model.

This page discusses:

See Also
Expression Language
Defining Data Queries
MAP

General Parameters

Parameter Description
Label

Specify the label to display below the operator type in the data query.

Description

Add a description to display as tooltip on hover over the operator icon.

Tip: It is useful to explain what the operator does, especially when you share the data query with other users.

Clause Parameters

Configure a Clause with the following parameters:

Parameter Description
Variable The name of the variable.
Index unit The index unit that you want to introspect. To explore the index unit and find the class to use in Variable, click to open the Index Unit Browser.
Element type The element type that you want to stream. For example, a Class Definition, an Attribute Definition...

For more information, see Element Types.

Predicate A predicate to filter returned elements.

Element Types

The SCHEMA QUERY operator can stream different element types.

Type Description
Class Definition Represents the definition of a class. For example:
class Person {
  name: String
  age: Integer
}
With this element type, the operator streams all class definitions in your data model, using the Item<schema.ClassDefinition>.
Attribute Definition Represents the definition of a reusable attribute. For example:
attribute Age : Integer {
  @Positive
}
With this element type, the operator streams all attribute definitions in your data model, using the Item<schema.AttributeDefinition>.
Attribute Represents a class attribute. For example:
class Person {
  name: String // <-- a class attribute
  age: Integer // <-- another class attribute
}
With this element type, the operator streams all annotation definitions in your data model, using the Item<schema.AnnotationDefintion>.
Class definition Annotation and Attribute Annotation An annotation represents an annotation instance linked to a class or an attribute. For example:
class Person {
  @AnAnnotation // <-- annotation instance linked to a class definition

  name: String
  age: Integer {
    @DefaultValue(value: 12) // <-- annotation instance linked to an attribute         
  }
}
If you choose class definition annotation or attribute annotation, the operator streams all annotations, either linked to a class definition or to an attribute in your data model, using the Item<schema.Annotation>.

Output

This operator has one output that streams multiple elements. The element type depends on the configuration. The operator does not order the output stream.

Example

To get all class definitions with a numerical attribute, you need two operators:

  • A SCHEMA QUERY operator with the Attribute element type and the following Predicate:
    attribute->parentAttributes.anyMatch((attr) => attr.fqName == "core.Integer")
  • A MAP operator with the following Output expression: attribute.declarationClass