本文整理汇总了Java中org.apache.calcite.avatica.util.TimeUnit类的典型用法代码示例。如果您正苦于以下问题:Java TimeUnit类的具体用法?Java TimeUnit怎么用?Java TimeUnit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TimeUnit类属于org.apache.calcite.avatica.util包,在下文中一共展示了TimeUnit类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createCalciteTypeWithNullability
import org.apache.calcite.avatica.util.TimeUnit; //导入依赖的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);
}
开发者ID:skhalifa,项目名称:QDrill,代码行数:24,代码来源:DrillConstExecutor.java
示例2: FieldType
import org.apache.calcite.avatica.util.TimeUnit; //导入依赖的package包/类
@JsonCreator
public FieldType(
@JsonProperty("name") String name,
@JsonProperty("type") SqlTypeName type,
@JsonProperty("precision") Integer precision,
@JsonProperty("scale") Integer scale,
@JsonProperty("startUnit") TimeUnit startUnit,
@JsonProperty("endUnit") TimeUnit endUnit,
@JsonProperty("fractionalSecondPrecision") Integer fractionalSecondPrecision,
@JsonProperty("isNullable") Boolean isNullable) {
this.name = name;
this.type = type;
this.precision = precision;
this.scale = scale;
this.intervalQualifier =
null == startUnit
? null
: new SqlIntervalQualifier(
startUnit, precision, endUnit, fractionalSecondPrecision, SqlParserPos.ZERO );
// Property "isNullable" is not part of the initial view definition and
// was added in DRILL-2342. If the default value is null, consider it as
// "true". It is safe to default to "nullable" than "required" type.
this.isNullable = isNullable == null ? true : isNullable;
}
开发者ID:skhalifa,项目名称:QDrill,代码行数:26,代码来源:View.java
示例3: fieldTypesToView
import org.apache.calcite.avatica.util.TimeUnit; //导入依赖的package包/类
public static View fieldTypesToView(String name, String sql, List<ViewFieldType> fieldTypes, List<String> context) {
if (fieldTypes == null) {
throw new NullPointerException();
}
List<FieldType> fields = new ArrayList<>();
for (ViewFieldType sqlField : fieldTypes) {
FieldType fieldType = new View.FieldType(
sqlField.getName(),
en(SqlTypeName.class, sqlField.getType()),
sqlField.getPrecision(), sqlField.getScale(),
en(TimeUnit.class, sqlField.getStartUnit()),
en(TimeUnit.class, sqlField.getEndUnit()),
sqlField.getFractionalSecondPrecision(),
sqlField.getIsNullable()
);
fields.add(fieldType);
}
return new View(name, sql, fields, context);
}
开发者ID:dremio,项目名称:dremio-oss,代码行数:20,代码来源:Views.java
示例4: timeUnitInternalMultiplier
import org.apache.calcite.avatica.util.TimeUnit; //导入依赖的package包/类
/**
* @return internal multiplier of a TimeUnit, e.g. YEAR is 12, MINUTE is 60000
* @throws IllegalArgumentException if interval type is not supported
*/
public static BigDecimal timeUnitInternalMultiplier(final SqlTypeName sqlIntervalType) {
switch (sqlIntervalType) {
case INTERVAL_SECOND:
return TimeUnit.SECOND.multiplier;
case INTERVAL_MINUTE:
return TimeUnit.MINUTE.multiplier;
case INTERVAL_HOUR:
return TimeUnit.HOUR.multiplier;
case INTERVAL_DAY:
return TimeUnit.DAY.multiplier;
case INTERVAL_MONTH:
return TimeUnit.MONTH.multiplier;
case INTERVAL_YEAR:
return TimeUnit.YEAR.multiplier;
default:
throw new IllegalArgumentException("Interval " + sqlIntervalType
+ " cannot be converted to TimeUnit");
}
}
开发者ID:apache,项目名称:beam,代码行数:24,代码来源:TimeUnitUtils.java
示例5: timeUnitInternalMultiplier
import org.apache.calcite.avatica.util.TimeUnit; //导入依赖的package包/类
private static BigDecimal timeUnitInternalMultiplier(final SqlTypeName sqlIntervalType) {
switch (sqlIntervalType) {
case INTERVAL_SECOND:
return TimeUnit.SECOND.multiplier;
case INTERVAL_MINUTE:
return TimeUnit.MINUTE.multiplier;
case INTERVAL_HOUR:
return TimeUnit.HOUR.multiplier;
case INTERVAL_DAY:
return TimeUnit.DAY.multiplier;
case INTERVAL_MONTH:
return TimeUnit.MONTH.multiplier;
case INTERVAL_YEAR:
return TimeUnit.YEAR.multiplier;
default:
throw new IllegalArgumentException("Interval " + sqlIntervalType
+ " cannot be converted to TimeUnit");
}
}
开发者ID:apache,项目名称:beam,代码行数:20,代码来源:BeamSqlDatetimePlusExpressionTest.java
示例6: inferReturnType
import org.apache.calcite.avatica.util.TimeUnit; //导入依赖的package包/类
public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
final TimeUnit unit = (TimeUnit) opBinding.getOperandLiteralValue(0);
switch (unit) {
case HOUR:
case MINUTE:
case SECOND:
case MILLISECOND:
case MICROSECOND:
return typeFactory.createTypeWithNullability(
typeFactory.createSqlType(SqlTypeName.TIMESTAMP),
opBinding.getOperandType(1).isNullable()
|| opBinding.getOperandType(2).isNullable());
default:
return opBinding.getOperandType(2);
}
}
开发者ID:axbaretto,项目名称:flink,代码行数:18,代码来源:SqlTimestampAddFunction.java
示例7: createCalciteTypeWithNullability
import org.apache.calcite.avatica.util.TimeUnit; //导入依赖的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);
}
开发者ID:axbaretto,项目名称:drill,代码行数:32,代码来源:TypeInferenceUtils.java
示例8: getFactor
import org.apache.calcite.avatica.util.TimeUnit; //导入依赖的package包/类
private static long getFactor(TimeUnit unit) {
switch (unit) {
case DAY:
return 1L;
case HOUR:
return TimeUnit.DAY.multiplier.longValue();
case MINUTE:
return TimeUnit.HOUR.multiplier.longValue();
case SECOND:
return TimeUnit.MINUTE.multiplier.longValue();
case MONTH:
return TimeUnit.YEAR.multiplier.longValue();
case QUARTER:
return TimeUnit.YEAR.multiplier.longValue();
case YEAR:
case DECADE:
case CENTURY:
case MILLENNIUM:
return 1L;
default:
throw Util.unexpected(unit);
}
}
开发者ID:apache,项目名称:calcite,代码行数:24,代码来源:RexImpTable.java
示例9: isSecondaryFieldInRange
import org.apache.calcite.avatica.util.TimeUnit; //导入依赖的package包/类
private boolean isSecondaryFieldInRange(BigDecimal field, TimeUnit unit) {
// we should never get handed a negative field value
assert field.compareTo(ZERO) >= 0;
// YEAR and DAY can never be secondary units,
// nor can unit be null.
assert unit != null;
switch (unit) {
case YEAR:
case DAY:
default:
throw Util.unexpected(unit);
// Secondary field limits, as per section 4.6.3 of SQL2003 spec
case MONTH:
case HOUR:
case MINUTE:
case SECOND:
return unit.isValidValue(field);
}
}
开发者ID:apache,项目名称:calcite,代码行数:22,代码来源:SqlIntervalQualifier.java
示例10: inferReturnType
import org.apache.calcite.avatica.util.TimeUnit; //导入依赖的package包/类
public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
switch (opBinding.getOperandLiteralValue(0, TimeUnit.class)) {
case HOUR:
case MINUTE:
case SECOND:
case MILLISECOND:
case MICROSECOND:
return typeFactory.createTypeWithNullability(
typeFactory.createSqlType(SqlTypeName.TIMESTAMP),
opBinding.getOperandType(1).isNullable()
|| opBinding.getOperandType(2).isNullable());
default:
return opBinding.getOperandType(2);
}
}
开发者ID:apache,项目名称:calcite,代码行数:17,代码来源:SqlTimestampAddFunction.java
示例11: makeCastIntervalToExact
import org.apache.calcite.avatica.util.TimeUnit; //导入依赖的package包/类
private RexNode makeCastIntervalToExact(RelDataType toType, RexNode exp) {
final TimeUnit endUnit = exp.getType().getSqlTypeName().getEndUnit();
final TimeUnit baseUnit = baseUnit(exp.getType().getSqlTypeName());
final BigDecimal multiplier = baseUnit.multiplier;
final int scale = 0;
BigDecimal divider = endUnit.multiplier.scaleByPowerOfTen(-scale);
RexNode value = multiplyDivide(decodeIntervalOrDecimal(exp),
multiplier, divider);
if (scale > 0) {
RelDataType decimalType =
getTypeFactory().createSqlType(
SqlTypeName.DECIMAL,
scale + exp.getType().getPrecision(),
scale);
value = encodeIntervalOrDecimal(value, decimalType, false);
}
return ensureType(toType, value, false);
}
开发者ID:apache,项目名称:calcite,代码行数:19,代码来源:RexBuilder.java
示例12: intervalString
import org.apache.calcite.avatica.util.TimeUnit; //导入依赖的package包/类
private String intervalString(BigDecimal v) {
final List<TimeUnit> timeUnits = getTimeUnits(type.getSqlTypeName());
final StringBuilder b = new StringBuilder();
for (TimeUnit timeUnit : timeUnits) {
final BigDecimal[] result = v.divideAndRemainder(timeUnit.multiplier);
if (b.length() > 0) {
b.append(timeUnit.separator);
}
final int width = b.length() == 0 ? -1 : width(timeUnit); // don't pad 1st
pad(b, result[0].toString(), width);
v = result[1];
}
if (Util.last(timeUnits) == TimeUnit.MILLISECOND) {
while (b.toString().matches(".*\\.[0-9]*0")) {
if (b.toString().endsWith(".0")) {
b.setLength(b.length() - 2); // remove ".0"
} else {
b.setLength(b.length() - 1); // remove "0"
}
}
}
return b.toString();
}
开发者ID:apache,项目名称:calcite,代码行数:24,代码来源:RexLiteral.java
示例13: createCalciteTypeWithNullability
import org.apache.calcite.avatica.util.TimeUnit; //导入依赖的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);
}
开发者ID:dremio,项目名称:dremio-oss,代码行数:46,代码来源:TypeInferenceUtils.java
示例14: testEvaluateDiffSeconds
import org.apache.calcite.avatica.util.TimeUnit; //导入依赖的package包/类
@Test public void testEvaluateDiffSeconds() {
BeamSqlTimestampMinusTimestampExpression minusExpression =
minusExpression(
SqlTypeName.INTERVAL_SECOND,
timestamp(DATE),
timestamp(DATE_MINUS_2_SEC));
long expectedResult = applyMultiplier(2L, TimeUnit.SECOND);
assertEquals(expectedResult, eval(minusExpression));
}
开发者ID:apache,项目名称:beam,代码行数:11,代码来源:BeamSqlTimestampMinusTimestampExpressionTest.java
示例15: testEvaluateDiffMinutes
import org.apache.calcite.avatica.util.TimeUnit; //导入依赖的package包/类
@Test public void testEvaluateDiffMinutes() {
BeamSqlTimestampMinusTimestampExpression minusExpression =
minusExpression(
SqlTypeName.INTERVAL_MINUTE,
timestamp(DATE),
timestamp(DATE_MINUS_3_MIN));
long expectedResult = applyMultiplier(3L, TimeUnit.MINUTE);
assertEquals(expectedResult, eval(minusExpression));
}
开发者ID:apache,项目名称:beam,代码行数:11,代码来源:BeamSqlTimestampMinusTimestampExpressionTest.java
示例16: testEvaluateDiffHours
import org.apache.calcite.avatica.util.TimeUnit; //导入依赖的package包/类
@Test public void testEvaluateDiffHours() {
BeamSqlTimestampMinusTimestampExpression minusExpression =
minusExpression(
SqlTypeName.INTERVAL_HOUR,
timestamp(DATE),
timestamp(DATE_MINUS_4_HOURS));
long expectedResult = applyMultiplier(4L, TimeUnit.HOUR);
assertEquals(expectedResult, eval(minusExpression));
}
开发者ID:apache,项目名称:beam,代码行数:11,代码来源:BeamSqlTimestampMinusTimestampExpressionTest.java
示例17: testEvaluateDiffDays
import org.apache.calcite.avatica.util.TimeUnit; //导入依赖的package包/类
@Test public void testEvaluateDiffDays() {
BeamSqlTimestampMinusTimestampExpression minusExpression =
minusExpression(
SqlTypeName.INTERVAL_DAY,
timestamp(DATE),
timestamp(DATE_MINUS_7_DAYS));
long expectedResult = applyMultiplier(7L, TimeUnit.DAY);
assertEquals(expectedResult, eval(minusExpression));
}
开发者ID:apache,项目名称:beam,代码行数:11,代码来源:BeamSqlTimestampMinusTimestampExpressionTest.java
示例18: testEvaluateDiffMonths
import org.apache.calcite.avatica.util.TimeUnit; //导入依赖的package包/类
@Test public void testEvaluateDiffMonths() {
BeamSqlTimestampMinusTimestampExpression minusExpression =
minusExpression(
SqlTypeName.INTERVAL_MONTH,
timestamp(DATE),
timestamp(DATE_MINUS_2_MONTHS));
long expectedResult = applyMultiplier(2L, TimeUnit.MONTH);
assertEquals(expectedResult, eval(minusExpression));
}
开发者ID:apache,项目名称:beam,代码行数:11,代码来源:BeamSqlTimestampMinusTimestampExpressionTest.java
示例19: testEvaluateDiffYears
import org.apache.calcite.avatica.util.TimeUnit; //导入依赖的package包/类
@Test public void testEvaluateDiffYears() {
BeamSqlTimestampMinusTimestampExpression minusExpression =
minusExpression(
SqlTypeName.INTERVAL_YEAR,
timestamp(DATE),
timestamp(DATE_MINUS_1_YEAR));
long expectedResult = applyMultiplier(1L, TimeUnit.YEAR);
assertEquals(expectedResult, eval(minusExpression));
}
开发者ID:apache,项目名称:beam,代码行数:11,代码来源:BeamSqlTimestampMinusTimestampExpressionTest.java
示例20: testEvaluateNegativeDiffSeconds
import org.apache.calcite.avatica.util.TimeUnit; //导入依赖的package包/类
@Test public void testEvaluateNegativeDiffSeconds() {
BeamSqlTimestampMinusTimestampExpression minusExpression =
minusExpression(
SqlTypeName.INTERVAL_SECOND,
timestamp(DATE_MINUS_2_SEC),
timestamp(DATE));
long expectedResult = applyMultiplier(-2L, TimeUnit.SECOND);
assertEquals(expectedResult, eval(minusExpression));
}
开发者ID:apache,项目名称:beam,代码行数:11,代码来源:BeamSqlTimestampMinusTimestampExpressionTest.java
注:本文中的org.apache.calcite.avatica.util.TimeUnit类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论