本文整理汇总了Java中org.apache.calcite.sql.SqlIntervalQualifier类的典型用法代码示例。如果您正苦于以下问题:Java SqlIntervalQualifier类的具体用法?Java SqlIntervalQualifier怎么用?Java SqlIntervalQualifier使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SqlIntervalQualifier类属于org.apache.calcite.sql包,在下文中一共展示了SqlIntervalQualifier类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createCalciteTypeWithNullability
import org.apache.calcite.sql.SqlIntervalQualifier; //导入依赖的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.sql.SqlIntervalQualifier; //导入依赖的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: convertCall
import org.apache.calcite.sql.SqlIntervalQualifier; //导入依赖的package包/类
@Override
public RexNode convertCall(SqlRexContext cx, SqlCall call) {
final RexBuilder rexBuilder = cx.getRexBuilder();
final List<SqlNode> operands = call.getOperandList();
final List<RexNode> exprs = new LinkedList<>();
String timeUnit = ((SqlIntervalQualifier) operands.get(0)).timeUnitRange.toString();
RelDataTypeFactory typeFactory = cx.getTypeFactory();
//RelDataType nullableReturnType =
for (SqlNode node: operands) {
exprs.add(cx.convertExpression(node));
}
final RelDataType returnType
= typeFactory.createTypeWithNullability(typeFactory.createSqlType(SqlTypeName.BIGINT), exprs.get(1).getType().isNullable());
return rexBuilder.makeCall(returnType, call.getOperator(), exprs);
}
开发者ID:dremio,项目名称:dremio-oss,代码行数:21,代码来源:ExtractConvertlet.java
示例4: createCalciteTypeWithNullability
import org.apache.calcite.sql.SqlIntervalQualifier; //导入依赖的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
示例5: intervalToMillis
import org.apache.calcite.sql.SqlIntervalQualifier; //导入依赖的package包/类
public static long intervalToMillis(
String literal,
SqlIntervalQualifier intervalQualifier) {
Preconditions.checkArgument(!intervalQualifier.isYearMonth(),
"interval must be day time");
int[] ret;
try {
ret = intervalQualifier.evaluateIntervalLiteral(literal,
intervalQualifier.getParserPosition(), RelDataTypeSystem.DEFAULT);
assert ret != null;
} catch (CalciteContextException e) {
throw new RuntimeException("while parsing day-to-second interval "
+ literal, e);
}
long l = 0;
long[] conv = new long[5];
conv[4] = 1; // millisecond
conv[3] = conv[4] * 1000; // second
conv[2] = conv[3] * 60; // minute
conv[1] = conv[2] * 60; // hour
conv[0] = conv[1] * 24; // day
for (int i = 1; i < ret.length; i++) {
l += conv[i - 1] * ret[i];
}
return ret[0] * l;
}
开发者ID:apache,项目名称:calcite,代码行数:27,代码来源:SqlParserUtil.java
示例6: intervalToMonths
import org.apache.calcite.sql.SqlIntervalQualifier; //导入依赖的package包/类
public static long intervalToMonths(
String literal,
SqlIntervalQualifier intervalQualifier) {
Preconditions.checkArgument(intervalQualifier.isYearMonth(),
"interval must be year month");
int[] ret;
try {
ret = intervalQualifier.evaluateIntervalLiteral(literal,
intervalQualifier.getParserPosition(), RelDataTypeSystem.DEFAULT);
assert ret != null;
} catch (CalciteContextException e) {
throw new RuntimeException("Error while parsing year-to-month interval "
+ literal, e);
}
long l = 0;
long[] conv = new long[2];
conv[1] = 1; // months
conv[0] = conv[1] * 12; // years
for (int i = 1; i < ret.length; i++) {
l += conv[i - 1] * ret[i];
}
return ret[0] * l;
}
开发者ID:apache,项目名称:calcite,代码行数:25,代码来源:SqlParserUtil.java
示例7: createCalciteTypeWithNullability
import org.apache.calcite.sql.SqlIntervalQualifier; //导入依赖的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
示例8: convertCall
import org.apache.calcite.sql.SqlIntervalQualifier; //导入依赖的package包/类
@Override
public RexNode convertCall(SqlRexContext cx, SqlCall call) {
final RexBuilder rexBuilder = cx.getRexBuilder();
final List<SqlNode> operands = call.getOperandList();
final List<RexNode> exprs = new LinkedList<>();
String timeUnit = ((SqlIntervalQualifier) operands.get(0)).timeUnitRange.toString();
RelDataTypeFactory typeFactory = cx.getTypeFactory();
//RelDataType nullableReturnType =
for (SqlNode node: operands) {
exprs.add(cx.convertExpression(node));
}
final RelDataType returnType;
if(call.getOperator() == SqlStdOperatorTable.EXTRACT) {
// Legacy code:
// The return type is wrong!
// Legacy code choose SqlTypeName.BIGINT simply to avoid conflicting against Calcite's inference mechanism
// (, which chose BIGINT in validation phase already)
// Determine NULL-able using 2nd argument's Null-able.
returnType = typeFactory.createTypeWithNullability(typeFactory.createSqlType(SqlTypeName.BIGINT), exprs.get(1).getType().isNullable());
} else {
// Determine NULL-able using 2nd argument's Null-able.
returnType = typeFactory.createTypeWithNullability(
typeFactory.createSqlType(
TypeInferenceUtils.getSqlTypeNameForTimeUnit(timeUnit)),
exprs.get(1).getType().isNullable());
}
return rexBuilder.makeCall(returnType, call.getOperator(), exprs);
}
开发者ID:axbaretto,项目名称:drill,代码行数:35,代码来源:DrillExtractConvertlet.java
示例9: add
import org.apache.calcite.sql.SqlIntervalQualifier; //导入依赖的package包/类
/**
* Adds a field with an interval type.
*/
public Builder add(String name, TimeUnit startUnit, int startPrecision,
TimeUnit endUnit, int fractionalSecondPrecision) {
final SqlIntervalQualifier q =
new SqlIntervalQualifier(startUnit, startPrecision, endUnit,
fractionalSecondPrecision, SqlParserPos.ZERO);
add(name, typeFactory.createSqlIntervalType(q));
return this;
}
开发者ID:apache,项目名称:calcite,代码行数:12,代码来源:RelDataTypeFactory.java
示例10: convertInterval
import org.apache.calcite.sql.SqlIntervalQualifier; //导入依赖的package包/类
public RexLiteral convertInterval(
SqlRexContext cx,
SqlIntervalQualifier intervalQualifier) {
RexBuilder rexBuilder = cx.getRexBuilder();
return rexBuilder.makeIntervalLiteral(intervalQualifier);
}
开发者ID:apache,项目名称:calcite,代码行数:8,代码来源:SqlNodeToRexConverterImpl.java
示例11: convertCall
import org.apache.calcite.sql.SqlIntervalQualifier; //导入依赖的package包/类
public RexNode convertCall(SqlRexContext cx, SqlCall call) {
// TIMESTAMPADD(unit, count, timestamp)
// => timestamp + count * INTERVAL '1' UNIT
final RexBuilder rexBuilder = cx.getRexBuilder();
final SqlLiteral unitLiteral = call.operand(0);
final TimeUnit unit = unitLiteral.symbolValue(TimeUnit.class);
return rexBuilder.makeCall(SqlStdOperatorTable.DATETIME_PLUS,
cx.convertExpression(call.operand(2)),
multiply(rexBuilder,
rexBuilder.makeIntervalLiteral(unit.multiplier,
new SqlIntervalQualifier(unit, null,
unitLiteral.getParserPosition())),
cx.convertExpression(call.operand(1))));
}
开发者ID:apache,项目名称:calcite,代码行数:15,代码来源:StandardConvertletTable.java
示例12: parseIntervalLiteral
import org.apache.calcite.sql.SqlIntervalQualifier; //导入依赖的package包/类
public static SqlIntervalLiteral parseIntervalLiteral(SqlParserPos pos,
int sign, String s, SqlIntervalQualifier intervalQualifier) {
final String intervalStr = parseString(s);
if (intervalStr.equals("")) {
throw SqlUtil.newContextException(pos,
RESOURCE.illegalIntervalLiteral(s + " "
+ intervalQualifier.toString(), pos.toString()));
}
return SqlLiteral.createInterval(sign, intervalStr, intervalQualifier, pos);
}
开发者ID:apache,项目名称:calcite,代码行数:11,代码来源:SqlParserUtil.java
示例13: rewriteCall
import org.apache.calcite.sql.SqlIntervalQualifier; //导入依赖的package包/类
@Override public SqlNode rewriteCall(SqlValidator validator, SqlCall call) {
final List<SqlNode> operands = call.getOperandList();
final SqlParserPos pos = call.getParserPosition();
return SqlStdOperatorTable.EXTRACT.createCall(pos,
new SqlIntervalQualifier(timeUnit, null, SqlParserPos.ZERO),
operands.get(0));
}
开发者ID:apache,项目名称:calcite,代码行数:8,代码来源:SqlDatePartFunction.java
示例14: IntervalSqlType
import org.apache.calcite.sql.SqlIntervalQualifier; //导入依赖的package包/类
/**
* Constructs an IntervalSqlType. This should only be called from a factory
* method.
*/
public IntervalSqlType(RelDataTypeSystem typeSystem,
SqlIntervalQualifier intervalQualifier,
boolean isNullable) {
super(intervalQualifier.typeName(), isNullable, null);
this.typeSystem = Preconditions.checkNotNull(typeSystem);
this.intervalQualifier = Preconditions.checkNotNull(intervalQualifier);
computeDigest();
}
开发者ID:apache,项目名称:calcite,代码行数:13,代码来源:IntervalSqlType.java
示例15: makeIntervalLiteral
import org.apache.calcite.sql.SqlIntervalQualifier; //导入依赖的package包/类
/**
* Creates a literal representing an interval value, for example
* {@code INTERVAL '3-7' YEAR TO MONTH}.
*/
public RexLiteral makeIntervalLiteral(
BigDecimal v,
SqlIntervalQualifier intervalQualifier) {
return makeLiteral(
v,
typeFactory.createSqlIntervalType(intervalQualifier),
intervalQualifier.typeName());
}
开发者ID:apache,项目名称:calcite,代码行数:13,代码来源:RexBuilder.java
示例16: getIntervalQualifier
import org.apache.calcite.sql.SqlIntervalQualifier; //导入依赖的package包/类
/**
* Gets the interval type qualifier of the interval data type descriptor of
* this field (<i>iff</i> interval type). */
@JsonIgnore
public SqlIntervalQualifier getIntervalQualifier() {
return intervalQualifier;
}
开发者ID:skhalifa,项目名称:QDrill,代码行数:8,代码来源:View.java
示例17: visit
import org.apache.calcite.sql.SqlIntervalQualifier; //导入依赖的package包/类
@Override public Void visit(SqlIntervalQualifier intervalQualifier) {
return format(intervalQualifier);
}
开发者ID:dremio,项目名称:dremio-oss,代码行数:4,代码来源:SqlNodes.java
示例18: visit
import org.apache.calcite.sql.SqlIntervalQualifier; //导入依赖的package包/类
@Override
public T visit(SqlIntervalQualifier qualifier) {
throw new UnsupportedOperationException("SqlIntervalQualifier " + qualifier);
}
开发者ID:dremio,项目名称:dremio-oss,代码行数:5,代码来源:BaseSqlVisitor.java
示例19: visit
import org.apache.calcite.sql.SqlIntervalQualifier; //导入依赖的package包/类
@Override
public List<SqlIdentifier> visit(SqlIntervalQualifier intervalQualifier) {
return Collections.emptyList();
}
开发者ID:dremio,项目名称:dremio-oss,代码行数:5,代码来源:AncestorsVisitor.java
示例20: convertInterval
import org.apache.calcite.sql.SqlIntervalQualifier; //导入依赖的package包/类
public RexNode convertInterval(SqlIntervalQualifier intervalQualifier) {
return exprConverter.convertInterval(this, intervalQualifier);
}
开发者ID:axbaretto,项目名称:flink,代码行数:4,代码来源:SqlToRelConverter.java
注:本文中的org.apache.calcite.sql.SqlIntervalQualifier类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论