本文整理汇总了Java中org.apache.calcite.rel.type.RelDataTypeFactory.createSqlIntervalType方法的典型用法代码示例。如果您正苦于以下问题:Java RelDataTypeFactory.createSqlIntervalType方法的具体用法?Java RelDataTypeFactory.createSqlIntervalType怎么用?Java RelDataTypeFactory.createSqlIntervalType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.rel.type.RelDataTypeFactory
的用法示例。
在下文中一共展示了RelDataTypeFactory.createSqlIntervalType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCalciteTypeWithNullability
import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
private RelDataType createCalciteTypeWithNullability(RelDataTypeFactory typeFactory,
SqlTypeName sqlTypeName,
boolean isNullable) {
RelDataType type;
if (sqlTypeName == SqlTypeName.INTERVAL_DAY_TIME) {
type = typeFactory.createSqlIntervalType(
new SqlIntervalQualifier(
TimeUnit.DAY,
TimeUnit.MINUTE,
SqlParserPos.ZERO));
} else if (sqlTypeName == SqlTypeName.INTERVAL_YEAR_MONTH) {
type = typeFactory.createSqlIntervalType(
new SqlIntervalQualifier(
TimeUnit.YEAR,
TimeUnit.MONTH,
SqlParserPos.ZERO));
} else if (sqlTypeName == SqlTypeName.VARCHAR) {
type = typeFactory.createSqlType(sqlTypeName, TypeHelper.VARCHAR_DEFAULT_CAST_LEN);
} else {
type = typeFactory.createSqlType(sqlTypeName);
}
return typeFactory.createTypeWithNullability(type, isNullable);
}
示例2: createCalciteTypeWithNullability
import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
/**
* Given a {@link SqlTypeName} and nullability, create a RelDataType from the RelDataTypeFactory
*
* @param typeFactory RelDataTypeFactory used to create the RelDataType
* @param sqlTypeName the given SqlTypeName
* @param isNullable the nullability of the created RelDataType
* @return RelDataType Type of call
*/
public static RelDataType createCalciteTypeWithNullability(RelDataTypeFactory typeFactory,
SqlTypeName sqlTypeName,
boolean isNullable) {
RelDataType type;
if (sqlTypeName == SqlTypeName.INTERVAL_DAY_TIME) {
type = typeFactory.createSqlIntervalType(
new SqlIntervalQualifier(
TimeUnit.DAY,
TimeUnit.MINUTE,
SqlParserPos.ZERO));
} else if (sqlTypeName == SqlTypeName.INTERVAL_YEAR_MONTH) {
type = typeFactory.createSqlIntervalType(
new SqlIntervalQualifier(
TimeUnit.YEAR,
TimeUnit.MONTH,
SqlParserPos.ZERO));
} else if (sqlTypeName == SqlTypeName.VARCHAR) {
type = typeFactory.createSqlType(sqlTypeName, Types.MAX_VARCHAR_LENGTH);
} else {
type = typeFactory.createSqlType(sqlTypeName);
}
return typeFactory.createTypeWithNullability(type, isNullable);
}
示例3: getRowType
import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
public RelDataType getRowType(RelDataTypeFactory factory) {
// if there are no fields defined, this is a dynamic view.
if (isDynamic()) {
return new RelDataTypeDrillImpl(new RelDataTypeHolder(), factory);
}
List<RelDataType> types = Lists.newArrayList();
List<String> names = Lists.newArrayList();
for (FieldType field : fields) {
names.add(field.getName());
RelDataType type;
if ( SqlTypeFamily.INTERVAL_YEAR_MONTH == field.getType().getFamily()
|| SqlTypeFamily.INTERVAL_DAY_TIME == field.getType().getFamily() ) {
type = factory.createSqlIntervalType( field.getIntervalQualifier() );
} else if (field.getPrecision() == null && field.getScale() == null) {
type = factory.createSqlType(field.getType());
} else if (field.getPrecision() != null && field.getScale() == null) {
type = factory.createSqlType(field.getType(), field.getPrecision());
} else {
type = factory.createSqlType(field.getType(), field.getPrecision(), field.getScale());
}
if (field.getIsNullable()) {
types.add(factory.createTypeWithNullability(type, true));
} else {
types.add(type);
}
}
return factory.createStructType(types, names);
}
示例4: getRowType
import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
public RelDataType getRowType(RelDataTypeFactory factory) {
List<RelDataType> types = Lists.newArrayList();
List<String> names = Lists.newArrayList();
for (FieldType field : fields) {
names.add(field.getName());
RelDataType type;
if ( SqlTypeFamily.INTERVAL_YEAR_MONTH == field.getType().getFamily()
|| SqlTypeFamily.INTERVAL_DAY_TIME == field.getType().getFamily() ) {
type = factory.createSqlIntervalType( field.getIntervalQualifier() );
} else if (field.getType().equals(SqlTypeName.ARRAY) || field.getType().equals(SqlTypeName.MAP)) {
type = factory.createSqlType(SqlTypeName.ANY);
} else if (field.getPrecision() == null && field.getScale() == null) {
type = factory.createSqlType(field.getType());
} else if (field.getPrecision() != null && field.getScale() == null) {
type = factory.createSqlType(field.getType(), field.getPrecision());
} else {
type = factory.createSqlType(field.getType(), field.getPrecision(), field.getScale());
}
if (field.getIsNullable()) {
types.add(factory.createTypeWithNullability(type, true));
} else {
types.add(type);
}
}
return factory.createStructType(types, names);
}
示例5: createCalciteTypeWithNullability
import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
/**
* Given a {@link SqlTypeName} and nullability, create a RelDataType from the RelDataTypeFactory
*
* @param typeFactory RelDataTypeFactory used to create the RelDataType
* @param sqlTypeName the given SqlTypeName
* @param isNullable the nullability of the created RelDataType
* @return RelDataType Type of call
*/
public static RelDataType createCalciteTypeWithNullability(RelDataTypeFactory typeFactory,
SqlTypeName sqlTypeName,
boolean isNullable) {
RelDataType type;
switch (sqlTypeName) {
case INTERVAL_YEAR:
case INTERVAL_YEAR_MONTH:
case INTERVAL_MONTH:
type = typeFactory.createSqlIntervalType(
new SqlIntervalQualifier(
TimeUnit.YEAR,
TimeUnit.MONTH,
SqlParserPos.ZERO));
break;
case INTERVAL_DAY:
case INTERVAL_DAY_HOUR:
case INTERVAL_DAY_MINUTE:
case INTERVAL_DAY_SECOND:
case INTERVAL_HOUR:
case INTERVAL_HOUR_MINUTE:
case INTERVAL_HOUR_SECOND:
case INTERVAL_MINUTE:
case INTERVAL_MINUTE_SECOND:
case INTERVAL_SECOND:
type = typeFactory.createSqlIntervalType(
new SqlIntervalQualifier(
TimeUnit.DAY,
TimeUnit.MINUTE,
SqlParserPos.ZERO));
break;
case VARCHAR:
type = typeFactory.createSqlType(sqlTypeName, TypeHelper.VARCHAR_DEFAULT_CAST_LEN);
default:
type = typeFactory.createSqlType(sqlTypeName);
}
return typeFactory.createTypeWithNullability(type, isNullable);
}
示例6: createSqlType
import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
public RelDataType createSqlType(RelDataTypeFactory typeFactory) {
BitString bitString;
switch (typeName) {
case NULL:
case BOOLEAN:
RelDataType ret = typeFactory.createSqlType(typeName);
ret = typeFactory.createTypeWithNullability(ret, null == value);
return ret;
case BINARY:
bitString = (BitString) value;
int bitCount = bitString.getBitCount();
return typeFactory.createSqlType(SqlTypeName.BINARY, bitCount / 8);
case CHAR:
NlsString string = (NlsString) value;
Charset charset = string.getCharset();
if (null == charset) {
charset = typeFactory.getDefaultCharset();
}
SqlCollation collation = string.getCollation();
if (null == collation) {
collation = SqlCollation.COERCIBLE;
}
RelDataType type =
typeFactory.createSqlType(
SqlTypeName.CHAR,
string.getValue().length());
type =
typeFactory.createTypeWithCharsetAndCollation(
type,
charset,
collation);
return type;
case INTERVAL_YEAR:
case INTERVAL_YEAR_MONTH:
case INTERVAL_MONTH:
case INTERVAL_DAY:
case INTERVAL_DAY_HOUR:
case INTERVAL_DAY_MINUTE:
case INTERVAL_DAY_SECOND:
case INTERVAL_HOUR:
case INTERVAL_HOUR_MINUTE:
case INTERVAL_HOUR_SECOND:
case INTERVAL_MINUTE:
case INTERVAL_MINUTE_SECOND:
case INTERVAL_SECOND:
SqlIntervalLiteral.IntervalValue intervalValue =
(SqlIntervalLiteral.IntervalValue) value;
return typeFactory.createSqlIntervalType(
intervalValue.getIntervalQualifier());
case SYMBOL:
return typeFactory.createSqlType(SqlTypeName.SYMBOL);
case INTEGER: // handled in derived class
case TIME: // handled in derived class
case VARCHAR: // should never happen
case VARBINARY: // should never happen
default:
throw Util.needToImplement(toString() + ", operand=" + value);
}
}