本文整理汇总了Java中org.apache.calcite.sql.SqlLiteral.createTime方法的典型用法代码示例。如果您正苦于以下问题:Java SqlLiteral.createTime方法的具体用法?Java SqlLiteral.createTime怎么用?Java SqlLiteral.createTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.sql.SqlLiteral
的用法示例。
在下文中一共展示了SqlLiteral.createTime方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseTimeLiteral
import org.apache.calcite.sql.SqlLiteral; //导入方法依赖的package包/类
public static SqlTimeLiteral parseTimeLiteral(String s, SqlParserPos pos) {
final String dateStr = parseString(s);
final DateTimeUtils.PrecisionTime pt =
DateTimeUtils.parsePrecisionDateTimeLiteral(dateStr,
Format.PER_THREAD.get().time, DateTimeUtils.UTC_ZONE, -1);
if (pt == null) {
throw SqlUtil.newContextException(pos,
RESOURCE.illegalLiteral("TIME", s,
RESOURCE.badFormat(DateTimeUtils.TIME_FORMAT_STRING).str()));
}
final TimeString t = TimeString.fromCalendarFields(pt.getCalendar())
.withFraction(pt.getFraction());
return SqlLiteral.createTime(t, pt.getPrecision(), pos);
}
示例2: convertLiteral
import org.apache.calcite.sql.SqlLiteral; //导入方法依赖的package包/类
public SqlNode convertLiteral(RexLiteral literal) {
// Numeric
if (SqlTypeFamily.EXACT_NUMERIC.getTypeNames().contains(
literal.getTypeName())) {
return SqlLiteral.createExactNumeric(
literal.getValue().toString(),
SqlParserPos.ZERO);
}
if (SqlTypeFamily.APPROXIMATE_NUMERIC.getTypeNames().contains(
literal.getTypeName())) {
return SqlLiteral.createApproxNumeric(
literal.getValue().toString(),
SqlParserPos.ZERO);
}
// Timestamp
if (SqlTypeFamily.TIMESTAMP.getTypeNames().contains(
literal.getTypeName())) {
return SqlLiteral.createTimestamp(
literal.getValueAs(TimestampString.class),
0,
SqlParserPos.ZERO);
}
// Date
if (SqlTypeFamily.DATE.getTypeNames().contains(
literal.getTypeName())) {
return SqlLiteral.createDate(
literal.getValueAs(DateString.class),
SqlParserPos.ZERO);
}
// Time
if (SqlTypeFamily.TIME.getTypeNames().contains(
literal.getTypeName())) {
return SqlLiteral.createTime(
literal.getValueAs(TimeString.class),
0,
SqlParserPos.ZERO);
}
// String
if (SqlTypeFamily.CHARACTER.getTypeNames().contains(
literal.getTypeName())) {
return SqlLiteral.createCharString(
((NlsString) (literal.getValue())).getValue(),
SqlParserPos.ZERO);
}
// Boolean
if (SqlTypeFamily.BOOLEAN.getTypeNames().contains(
literal.getTypeName())) {
return SqlLiteral.createBoolean(
(Boolean) literal.getValue(),
SqlParserPos.ZERO);
}
return null;
}