Package org.apache.calcite.rel.type
Class RelDataTypeFactory.Builder
- java.lang.Object
-
- org.apache.calcite.rel.type.RelDataTypeFactory.Builder
-
- Direct Known Subclasses:
RelDataTypeFactory.FieldInfoBuilder
- Enclosing interface:
- RelDataTypeFactory
public static class RelDataTypeFactory.Builder extends java.lang.Object
Fluid API to build a list of fields.
-
-
Field Summary
Fields Modifier and Type Field Description private StructKind
kind
private java.util.List<java.lang.String>
names
private RelDataTypeFactory
typeFactory
private java.util.List<RelDataType>
types
-
Constructor Summary
Constructors Constructor Description Builder(RelDataTypeFactory typeFactory)
Creates a Builder with the given type factory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RelDataTypeFactory.Builder
add(java.lang.String name, org.apache.calcite.avatica.util.TimeUnit startUnit, int startPrecision, org.apache.calcite.avatica.util.TimeUnit endUnit, int fractionalSecondPrecision)
Adds a field with an interval type.RelDataTypeFactory.Builder
add(java.lang.String name, RelDataType type)
Adds a field with given name and type.RelDataTypeFactory.Builder
add(java.lang.String name, SqlTypeName typeName)
Adds a field with a type created usingRelDataTypeFactory.createSqlType(org.apache.calcite.sql.type.SqlTypeName)
.RelDataTypeFactory.Builder
add(java.lang.String name, SqlTypeName typeName, int precision)
Adds a field with a type created usingRelDataTypeFactory.createSqlType(org.apache.calcite.sql.type.SqlTypeName, int)
.RelDataTypeFactory.Builder
add(java.lang.String name, SqlTypeName typeName, int precision, int scale)
Adds a field with a type created usingRelDataTypeFactory.createSqlType(org.apache.calcite.sql.type.SqlTypeName, int, int)
.RelDataTypeFactory.Builder
add(RelDataTypeField field)
Adds a field.RelDataTypeFactory.Builder
addAll(java.lang.Iterable<? extends java.util.Map.Entry<java.lang.String,RelDataType>> fields)
Adds all fields in a collection.RelDataType
build()
Creates a struct type with the current contents of this builder.RelDataType
buildDynamic()
Creates a dynamic struct type with the current contents of this builder.int
getFieldCount()
Returns the number of fields.java.lang.String
getFieldName(int index)
Returns the name of a given field.RelDataType
getFieldType(int index)
Returns the type of a given field.RelDataTypeFactory.Builder
kind(StructKind kind)
boolean
nameExists(java.lang.String name)
Returns whether a field exists with the given name.RelDataTypeFactory.Builder
nullable(boolean nullable)
Changes the nullability of the last field added.RelDataTypeFactory.Builder
uniquify()
Makes sure that field names are unique.
-
-
-
Field Detail
-
names
private final java.util.List<java.lang.String> names
-
types
private final java.util.List<RelDataType> types
-
kind
private StructKind kind
-
typeFactory
private final RelDataTypeFactory typeFactory
-
-
Constructor Detail
-
Builder
public Builder(RelDataTypeFactory typeFactory)
Creates a Builder with the given type factory.
-
-
Method Detail
-
getFieldCount
public int getFieldCount()
Returns the number of fields.- Returns:
- number of fields
-
getFieldName
public java.lang.String getFieldName(int index)
Returns the name of a given field.- Parameters:
index
- Ordinal of field- Returns:
- Name of given field
-
getFieldType
public RelDataType getFieldType(int index)
Returns the type of a given field.- Parameters:
index
- Ordinal of field- Returns:
- Type of given field
-
add
public RelDataTypeFactory.Builder add(java.lang.String name, RelDataType type)
Adds a field with given name and type.
-
add
public RelDataTypeFactory.Builder add(java.lang.String name, SqlTypeName typeName)
Adds a field with a type created usingRelDataTypeFactory.createSqlType(org.apache.calcite.sql.type.SqlTypeName)
.
-
add
public RelDataTypeFactory.Builder add(java.lang.String name, SqlTypeName typeName, int precision)
Adds a field with a type created usingRelDataTypeFactory.createSqlType(org.apache.calcite.sql.type.SqlTypeName, int)
.
-
add
public RelDataTypeFactory.Builder add(java.lang.String name, SqlTypeName typeName, int precision, int scale)
Adds a field with a type created usingRelDataTypeFactory.createSqlType(org.apache.calcite.sql.type.SqlTypeName, int, int)
.
-
add
public RelDataTypeFactory.Builder add(java.lang.String name, org.apache.calcite.avatica.util.TimeUnit startUnit, int startPrecision, org.apache.calcite.avatica.util.TimeUnit endUnit, int fractionalSecondPrecision)
Adds a field with an interval type.
-
nullable
public RelDataTypeFactory.Builder nullable(boolean nullable)
Changes the nullability of the last field added.- Throws:
java.lang.IndexOutOfBoundsException
- if no fields have been added
-
add
public RelDataTypeFactory.Builder add(RelDataTypeField field)
Adds a field. Field's ordinal is ignored.
-
addAll
public RelDataTypeFactory.Builder addAll(java.lang.Iterable<? extends java.util.Map.Entry<java.lang.String,RelDataType>> fields)
Adds all fields in a collection.
-
kind
public RelDataTypeFactory.Builder kind(StructKind kind)
-
uniquify
public RelDataTypeFactory.Builder uniquify()
Makes sure that field names are unique.
-
build
public RelDataType build()
Creates a struct type with the current contents of this builder.
-
buildDynamic
public RelDataType buildDynamic()
Creates a dynamic struct type with the current contents of this builder.
-
nameExists
public boolean nameExists(java.lang.String name)
Returns whether a field exists with the given name.
-
-