Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

C3.ai Types 

There are many categories of C3.ai Types. 

We will cover the most commonly used categories in this tutorial:

  • Primitive Types 
  • Persistable Types 
  • Generic (Parametric) Types 
  • Abstract Types 

Primitive Types

As a basis for many fieldsLike many programming languages, the C3 AI Suite defines many 'primitive' types. These are basic types like 'int' and 'double. Primitive Types are given to the developer by the platform and new ones require backend C3 support to define. Most DTI researchers will not be defining these, but using those that already exist.We list them here for reference.has primitives. Primitives define the units (or data types) of fields on a C3.ai Type (e.g., "int", "double", "float"). The C3 AI Suite includes a number of primitive, listed below for reference. Adding new primitives will require support from the C3.ai engineering team. However, most DTI researchers should be able to progress their research projects with the C3 AI Suite's existing primitives. 

C3 AI Suite Primitives

  • binary
  • boolean
  • byte
  • char
  • datetime
  • decimal
  • double
  • float
  • int
  • json
  • long int
  • string

To learn more about primitives, see the C3.ai resources on Primitive TypesResources here:

Persistable Types

The most common type a C3 developer C3.ai Type you will define is a 'Persistable' type. A Persistable type is any type which inherits the 'Persistable' Type. This can be specified either by directly mixing in 'Persistable', or using the keyword 'entity'. All persistable types live within the C3 AI Suite stored in a table backed by some sort of database technology. Usually this is postgres, but depending on the data (Or annotations Persistable types store data in a C3 AI Suite database. By default, all Persistable types are stored in Postgres. However, Persistable types can also be stored in file systems (e.g., Azure Blob) or key-value stores (e.g., Cassandra), by adding an annotation to your .c3typ file (as will be discussed below), It can also be stored in a file blob or key-value store such as Cassandra.The C3 AI Suite also needs to know where to store this table. Thus when the user is creating an entirely new persistable type (that is one not extending an existing persistable type), they must use

When defining a Persistable type, you MUST add the following two key terms to your .c3typ file

  1. entity: The keyword 'entity' keyword tells the C3 AI Suite this is a 'Persistable' type
  2. schema name: The schema names is the name of the database table, where the C3.a Type's data are stored. When defining a new Persistable type, you need to add the keywords 'schema name' followed by

...

  1. your chosen table name, in your .c3type file. (e.g., in the

...

  1. C3.ai Type LightBulb, we have 'schema name "LGHT_BLB"', where "LGHT_BLB" is our chosen table name). Please note, extended C3.ai DO NOT NEED a scheme name.

To learn more about 'Persistable' Types, please see the C3.ai Resources below: "'.C3.ai resources on Persistable Types

Generic (Parametric) Types

Like a Java or C++ Class, C3.ai Types can also be made generic similar to Java generic Types and C++ generic classes. In fact, it uses the same syntax with angle brakets '<>' defining the generic parameters of the type. When defining a generic type, the Name of the type you're creating be parameterized (or genericized). In fact, the C3 AI Suite uses the exact same syntax as Java and C++ to define a type's parameters (i.e., angle brackets '<>' ). When defining a Generic (Parametric) type, your Type name will be followed by angle brackets and a comma-separated list of placeholder names to refer to the generic type parameters you want to use. parameters (usually other C3.ai Types).  For example:

Code Block
type TheType<V,U> {
	fieldA: V
	fieldB: [U]
}

Then, when you use using your type Parametric Type in other places, you must specify which type you mean in each type parameter slot. So later you might define a new type which has a field likethe arguments for each parameter in the angle brackets. As example, you may define a new C3.ai Type with the following field:

Code Block
type NewType {
	newField: TheType<TypeA, TypeB>
}

If your C3.ai types will be heavily re-used by other C3.ai developers, you should consider using Parametric (Generic) types.

To learn more about Generic Types, please see the C3.ai Resources here resources on Generic Types:

...