org.eigenbase.reltype
Interface RelDataType

All Known Implementing Classes:
AbstractSqlType, BasicSqlType, IntervalSqlType, MultisetSqlType, ObjectSqlType, OJTypeFactoryImpl.OJScalarType, RelCrossType, RelDataTypeFactoryImpl.JavaType, RelDataTypeImpl, RelRecordType

public interface RelDataType

RelDataType represents the type of a scalar expression or entire row returned from a relational expression.

This is a somewhat "fat" interface which unions the attributes of many different type classes into one. Inelegant, but since our type system was defined before the advent of Java generics, it avoids a lot of typecasting.

Since:
May 29, 2003
Version:
$Id: //open/dev/farrago/src/org/eigenbase/reltype/RelDataType.java#15 $
Author:
jhyde

Method Summary
 Charset getCharset()
          Gets this type's character set, or null if this type cannot carry a character set or has no character set defined.
 SqlCollation getCollation()
          Gets this type's collation, or null if this type cannot carry a collation or has no collation defined.
 RelDataTypeComparability getComparability()
           
 RelDataType getComponentType()
          Gets the component type if this type is a collection, otherwise null.
 RelDataTypeFamily getFamily()
          Gets a canonical object representing the family of this type.
 RelDataTypeField getField(String fieldName)
          Looks up a field by name.
 int getFieldCount()
          Returns the number of fields in a struct type.
 List<RelDataTypeField> getFieldList()
          Gets the fields in a struct type.
 int getFieldOrdinal(String fieldName)
          Looks up the ordinal of a field by name.
 RelDataTypeField[] getFields()
          Gets the fields in a struct type.
 String getFullTypeString()
          Gets a string representation of this type with full detail such as character set and nullability.
 SqlIntervalQualifier getIntervalQualifier()
          Gets this type's interval qualifier, or null if this is not an interval type.
 RelDataTypePrecedenceList getPrecedenceList()
           
 int getPrecision()
          Gets the JDBC-defined precision for values of this type.
 int getScale()
          Gets the scale of this type.
 SqlIdentifier getSqlIdentifier()
          Gets the SqlIdentifier associated with this type.
 SqlTypeName getSqlTypeName()
          Gets the SqlTypeName of this type.
 boolean isNullable()
          Queries whether this type allows null values.
 boolean isStruct()
          Queries whether this is a structured type.
 String toString()
          Gets a string representation of this type without detail such as character set and nullability.
 

Method Detail

isStruct

boolean isStruct()
Queries whether this is a structured type.

Returns:
whether this type has fields; examples include rows and user-defined structured types in SQL, and classes in Java

getFieldList

List<RelDataTypeField> getFieldList()
Gets the fields in a struct type. The field count is equal to the size of the returned list.

Returns:
read-only list of fields
"Precondition:"
this.isStruct()

getFields

RelDataTypeField[] getFields()
Gets the fields in a struct type. The field count is equal to the length of the returned array.

NOTE jvs 17-Dec-2004: this method will become deprecated once we move to Java generics, and eventually eliminated

Returns:
array of fields
"Precondition:"
this.isStruct()

getFieldCount

int getFieldCount()
Returns the number of fields in a struct type.

This method is equivalent to getFieldList() ().size().


getFieldOrdinal

int getFieldOrdinal(String fieldName)
Looks up the ordinal of a field by name.

Parameters:
fieldName - name of field to find
Returns:
0-based ordinal of named field, or -1 if not found
"Precondition:"
this.isStruct()

getField

RelDataTypeField getField(String fieldName)
Looks up a field by name.

Parameters:
fieldName - name of field to find
Returns:
named field, or null if not found
"Precondition:"
this.isStruct()

isNullable

boolean isNullable()
Queries whether this type allows null values.

Returns:
whether type allows null values

getComponentType

RelDataType getComponentType()
Gets the component type if this type is a collection, otherwise null.

Returns:
canonical type descriptor for components

getCharset

Charset getCharset()
Gets this type's character set, or null if this type cannot carry a character set or has no character set defined.

Returns:
charset of type

getCollation

SqlCollation getCollation()
Gets this type's collation, or null if this type cannot carry a collation or has no collation defined.

Returns:
collation of type

getIntervalQualifier

SqlIntervalQualifier getIntervalQualifier()
Gets this type's interval qualifier, or null if this is not an interval type.

Returns:
interval qualifier

getPrecision

int getPrecision()
Gets the JDBC-defined precision for values of this type. Note that this is not always the same as the user-specified precision. For example, the type INTEGER has no user-specified precision, but this method returns 10 for an INTEGER type.

Returns:
number of decimal digits for exact numeric types; number of decimal digits in mantissa for approximate numeric types; number of decimal digits for fractional seconds of datetime types; length in characters for character types; length in bytes for binary types; length in bits for bit types; 1 for BOOLEAN

getScale

int getScale()
Gets the scale of this type.

Returns:
number of digits of scale

getSqlTypeName

SqlTypeName getSqlTypeName()
Gets the SqlTypeName of this type.

Returns:
SqlTypeName, or null if this is not an SQL predefined type

getSqlIdentifier

SqlIdentifier getSqlIdentifier()
Gets the SqlIdentifier associated with this type. For a predefined type, this is a simple identifier based on getSqlTypeName(). For a user-defined type, this is a compound identifier which uniquely names the type.

Returns:
SqlIdentifier, or null if this is not an SQL type

toString

String toString()
Gets a string representation of this type without detail such as character set and nullability.

Overrides:
toString in class Object
Returns:
abbreviated type string

getFullTypeString

String getFullTypeString()
Gets a string representation of this type with full detail such as character set and nullability. The string must serve as a "digest" for this type, meaning two types can be considered identical iff their digests are equal.

Returns:
full type string

getFamily

RelDataTypeFamily getFamily()
Gets a canonical object representing the family of this type. Two values can be compared if and only if their types are in the same family.

Returns:
canonical object representing type family

getPrecedenceList

RelDataTypePrecedenceList getPrecedenceList()
Returns:
precedence list for this type

getComparability

RelDataTypeComparability getComparability()
Returns:
the category of comparison operators which make sense when applied to values of this type