org.apache.calcite.rel.type.RelDataTypeFactory.createSqlType()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(87)

本文整理了Java中org.apache.calcite.rel.type.RelDataTypeFactory.createSqlType方法的一些代码示例,展示了RelDataTypeFactory.createSqlType的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RelDataTypeFactory.createSqlType方法的具体详情如下:
包路径:org.apache.calcite.rel.type.RelDataTypeFactory
类名称:RelDataTypeFactory
方法名:createSqlType

RelDataTypeFactory.createSqlType介绍

[英]Creates a SQL type with no precision or scale.
[中]创建没有精度或比例的SQL类型。

代码示例

代码示例来源:origin: apache/flink

private void handleOffsetFetch(SqlNode offset, SqlNode fetch) {
  if (offset instanceof SqlDynamicParam) {
    setValidatedNodeType(offset,
      typeFactory.createSqlType(SqlTypeName.INTEGER));
  }
  if (fetch instanceof SqlDynamicParam) {
    setValidatedNodeType(fetch,
      typeFactory.createSqlType(SqlTypeName.INTEGER));
  }
}

代码示例来源:origin: apache/storm

public TableBuilderInfo field(String name, SqlTypeName type) {
  return field(name, typeFactory.createSqlType(type));
}

代码示例来源:origin: apache/hive

public List<RelDataType> getParameterTypes(RelDataTypeFactory typeFactory) {
 return ImmutableList.of(
   typeFactory.createTypeWithNullability(
     typeFactory.createSqlType(SqlTypeName.ANY), true));
}

代码示例来源:origin: apache/hive

public RelDataType getReturnType(RelDataTypeFactory typeFactory) {
 return typeFactory.createTypeWithNullability(
   typeFactory.createSqlType(SqlTypeName.ANY), true);
}

代码示例来源:origin: apache/storm

public TableBuilderInfo field(String name, SqlTypeName type, ColumnConstraint constraint) {
  interpretConstraint(constraint, fields.size());
  return field(name, typeFactory.createSqlType(type));
}

代码示例来源:origin: apache/incubator-druid

private RexNode integerLiteral(final int integer)
{
 return rexBuilder.makeLiteral(new BigDecimal(integer), typeFactory.createSqlType(SqlTypeName.INTEGER), true);
}

代码示例来源:origin: apache/hive

/** Creates an expression that casts an expression to a given type. */
public RexNode cast(RexNode expr, SqlTypeName typeName) {
 final RelDataType type = cluster.getTypeFactory().createSqlType(typeName);
 return cluster.getRexBuilder().makeCast(type, expr);
}

代码示例来源:origin: apache/hive

/** Creates an expression that casts an expression to a type with a given name
 * and precision or length. */
public RexNode cast(RexNode expr, SqlTypeName typeName, int precision) {
 final RelDataType type =
   cluster.getTypeFactory().createSqlType(typeName, precision);
 return cluster.getRexBuilder().makeCast(type, expr);
}

代码示例来源:origin: apache/hive

/** Creates an expression that casts an expression to a type with a given
 * name, precision and scale. */
public RexNode cast(RexNode expr, SqlTypeName typeName, int precision,
          int scale) {
 final RelDataType type =
   cluster.getTypeFactory().createSqlType(typeName, precision, scale);
 return cluster.getRexBuilder().makeCast(type, expr);
}

代码示例来源:origin: apache/hive

@Override
public AggregateCall other(RelDataTypeFactory typeFactory, AggregateCall e) {
 return AggregateCall.create(
   new HiveSqlCountAggFunction(isDistinct, returnTypeInference, operandTypeInference, operandTypeChecker),
   false, ImmutableIntList.of(), -1,
   typeFactory.createTypeWithNullability(typeFactory.createSqlType(SqlTypeName.BIGINT), true), "count");
}

代码示例来源:origin: apache/drill

@Override
 public AggregateCall other(RelDataTypeFactory typeFactory, AggregateCall e) {
  return AggregateCall.create(
    new HiveSqlCountAggFunction(isDistinct, returnTypeInference, operandTypeInference, operandTypeChecker),
    false, ImmutableIntList.of(), -1,
    typeFactory.createTypeWithNullability(typeFactory.createSqlType(SqlTypeName.BIGINT), true), "count");
 }
}

代码示例来源:origin: apache/hive

@Override
public AggregateCall other(RelDataTypeFactory typeFactory, AggregateCall e) {
 RelDataType countRetType = typeFactory.createTypeWithNullability(typeFactory.createSqlType(SqlTypeName.BIGINT), true);
 return AggregateCall.create(
  new HiveSqlCountAggFunction(isDistinct, ReturnTypes.explicit(countRetType), operandTypeInference, operandTypeChecker),
  false, ImmutableIntList.of(), -1, countRetType, "count");
}

代码示例来源:origin: apache/hive

private RexNode makeCast(SqlTypeName typeName, final RexNode child) {
 RelDataType sqlType = cluster.getTypeFactory().createSqlType(typeName);
 RelDataType nullableType = cluster.getTypeFactory().createTypeWithNullability(sqlType, true);
 return cluster.getRexBuilder().makeCast(nullableType, child);
}

代码示例来源:origin: apache/drill

@Override
public AggregateCall other(RelDataTypeFactory typeFactory, AggregateCall e) {
 RelDataType countRetType = typeFactory.createTypeWithNullability(typeFactory.createSqlType(SqlTypeName.BIGINT), true);
 return AggregateCall.create(
  new HiveSqlCountAggFunction(isDistinct, ReturnTypes.explicit(countRetType), operandTypeInference, operandTypeChecker),
  false, ImmutableIntList.of(), -1, countRetType, "count");
}

代码示例来源:origin: apache/incubator-druid

@Test
public void testTimeMinusDayTimeInterval()
{
 final Period period = new Period("P1DT1H1M");
 testExpression(
   rexBuilder.makeCall(
     typeFactory.createSqlType(SqlTypeName.TIMESTAMP),
     SqlStdOperatorTable.MINUS_DATE,
     ImmutableList.of(
       inputRef("t"),
       rexBuilder.makeIntervalLiteral(
         new BigDecimal(period.toStandardDuration().getMillis()), // DAY-TIME literals value is millis
         new SqlIntervalQualifier(TimeUnit.DAY, TimeUnit.MINUTE, SqlParserPos.ZERO)
       )
     )
   ),
   DruidExpression.of(
     null,
     "(\"t\" - 90060000)"
   ),
   DateTimes.of("2000-02-03T04:05:06").minus(period).getMillis()
 );
}

代码示例来源:origin: apache/incubator-druid

@Test
public void testConcat()
{
 testExpression(
   rexBuilder.makeCall(
     typeFactory.createSqlType(SqlTypeName.VARCHAR),
     SqlStdOperatorTable.CONCAT,
     ImmutableList.of(
       inputRef("s"),
       rexBuilder.makeLiteral("bar")
     )
   ),
   DruidExpression.fromExpression("concat(\"s\",'bar')"),
   "foobar"
 );
}

代码示例来源:origin: apache/incubator-druid

@Test
public void testTimeMinusYearMonthInterval()
{
 final Period period = new Period("P1Y1M");
 testExpression(
   rexBuilder.makeCall(
     typeFactory.createSqlType(SqlTypeName.TIMESTAMP),
     SqlStdOperatorTable.MINUS_DATE,
     ImmutableList.of(
       inputRef("t"),
       rexBuilder.makeIntervalLiteral(
         new BigDecimal(13), // YEAR-MONTH literals value is months
         new SqlIntervalQualifier(TimeUnit.YEAR, TimeUnit.MONTH, SqlParserPos.ZERO)
       )
     )
   ),
   DruidExpression.of(
     null,
     "timestamp_shift(\"t\",concat('P', 13, 'M'),-1)"
   ),
   DateTimes.of("2000-02-03T04:05:06").minus(period).getMillis()
 );
}

代码示例来源:origin: apache/incubator-druid

@Test
public void testCastAsDate()
{
 testExpression(
   rexBuilder.makeAbstractCast(
     typeFactory.createSqlType(SqlTypeName.DATE),
     inputRef("t")
   ),
   DruidExpression.fromExpression("timestamp_floor(\"t\",'P1D',null,'UTC')"),
   DateTimes.of("2000-02-03").getMillis()
 );
 testExpression(
   rexBuilder.makeAbstractCast(
     typeFactory.createSqlType(SqlTypeName.DATE),
     inputRef("dstr")
   ),
   DruidExpression.fromExpression(
     "timestamp_floor(timestamp_parse(\"dstr\",null,'UTC'),'P1D',null,'UTC')"
   ),
   DateTimes.of("2000-02-03").getMillis()
 );
}

代码示例来源:origin: apache/incubator-druid

@Test
public void testCastAsTimestamp()
{
 testExpression(
   rexBuilder.makeAbstractCast(
     typeFactory.createSqlType(SqlTypeName.TIMESTAMP),
     inputRef("t")
   ),
   DruidExpression.of(
     SimpleExtraction.of("t", null),
     "\"t\""
   ),
   DateTimes.of("2000-02-03T04:05:06Z").getMillis()
 );
 testExpression(
   rexBuilder.makeAbstractCast(
     typeFactory.createSqlType(SqlTypeName.TIMESTAMP),
     inputRef("tstr")
   ),
   DruidExpression.of(
     null,
     "timestamp_parse(\"tstr\",null,'UTC')"
   ),
   DateTimes.of("2000-02-03T04:05:06Z").getMillis()
 );
}

代码示例来源:origin: apache/incubator-druid

@Test
public void testTimeShift()
{
 testExpression(
   rexBuilder.makeCall(
     new TimeShiftOperatorConversion().calciteOperator(),
     inputRef("t"),
     rexBuilder.makeLiteral("PT2H"),
     rexBuilder.makeLiteral(-3, typeFactory.createSqlType(SqlTypeName.INTEGER), true)
   ),
   DruidExpression.fromExpression("timestamp_shift(\"t\",'PT2H',-3)"),
   DateTimes.of("2000-02-02T22:05:06").getMillis()
 );
}

相关文章