• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java SqlTypeFamily类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.calcite.sql.type.SqlTypeFamily的典型用法代码示例。如果您正苦于以下问题:Java SqlTypeFamily类的具体用法?Java SqlTypeFamily怎么用?Java SqlTypeFamily使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SqlTypeFamily类属于org.apache.calcite.sql.type包,在下文中一共展示了SqlTypeFamily类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: SqlDatePartOperator

import org.apache.calcite.sql.type.SqlTypeFamily; //导入依赖的package包/类
public SqlDatePartOperator() {
  super(
      "DATE_PART",
      SqlKind.OTHER_FUNCTION,
      ReturnTypes.BIGINT_NULLABLE,
      null,
      OperandTypes.sequence(
          "<PERIOD LITERAL>, <DATE or TIMESTAMP or INTERVAL>",
          new EnumeratedListChecker(VALID_PERIODS.keySet()),
          OperandTypes.or(
              OperandTypes.family(SqlTypeFamily.DATE),
              OperandTypes.family(SqlTypeFamily.TIMESTAMP),
              OperandTypes.family(SqlTypeFamily.DATETIME),
              OperandTypes.family(SqlTypeFamily.DATETIME_INTERVAL),
              OperandTypes.family(SqlTypeFamily.INTERVAL_DAY_TIME),
              OperandTypes.family(SqlTypeFamily.INTERVAL_YEAR_MONTH))
          ),
          SqlFunctionCategory.SYSTEM);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:20,代码来源:SqlDatePartOperator.java


示例2: isTemporal

import org.apache.calcite.sql.type.SqlTypeFamily; //导入依赖的package包/类
public static boolean isTemporal(final LayoutField field) {
  final Optional<SqlTypeFamily> familyOpt = getSqlTypeFamily(field);
  if (!familyOpt.isPresent()) {
    return false;
  }

  final SqlTypeFamily family = familyOpt.get();
  switch (family) {
    case DATETIME:
    case TIMESTAMP:
    case DATE:
    case TIME:
      return true;
    default:
      return false;
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:18,代码来源:TypeUtils.java


示例3: createMeasuresFor

import org.apache.calcite.sql.type.SqlTypeFamily; //导入依赖的package包/类
private Iterable<AggregateCall> createMeasuresFor(final RelNode view, final LayoutField field) {
  final Optional<SqlTypeFamily> family = TypeUtils.getSqlTypeFamily(field);
  if (!family.isPresent()) {
    return ImmutableList.of();
  }

  return FluentIterable
      .from(AccelerationUtils.selfOrEmptyCollection(calls.get(family.get())))
      .transform(new Function<SqlAggFunction, AggregateCall>() {
        private int index = 0;

        @Nullable
        @Override
        public AggregateCall apply(@Nullable final SqlAggFunction func) {
          // no distinct measures for now
          final int inputRef = getField(field.getName()).getIndex();
          return AggregateCall.create(func, false, ImmutableList.of(inputRef), -1, 1, view, null,
              String.format("agg-%s-%s", inputRef, index++));
        }
      });
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:22,代码来源:LayoutExpander.java


示例4: addAggLayout

import org.apache.calcite.sql.type.SqlTypeFamily; //导入依赖的package包/类
private Layout addAggLayout(Acceleration acceleration, int layoutNum) {
  List<LayoutDimensionField> dimFields = new ArrayList<>();
  dimFields.add(new LayoutDimensionField().setName("dim" + layoutNum).setTypeFamily(SqlTypeFamily.CHARACTER.toString()));
  List<LayoutField> measureFields = new ArrayList<>();
  measureFields.add(new LayoutField().setName("measure" + layoutNum).setTypeFamily(SqlTypeFamily.NUMERIC.toString()));

  Layout aggLayout = new Layout()
    .setLayoutType(LayoutType.AGGREGATION)
    .setDetails(new LayoutDetails().setDimensionFieldList(dimFields).setMeasureFieldList(measureFields))
    .setId(new LayoutId("aggLayout" + layoutNum))
    .setName("aggLayout")
    .setVersion(0);

  acceleration.getAggregationLayouts().getLayoutList().add(aggLayout);

  when(store.get(aggLayout.getId())).thenReturn(Optional.<MaterializedLayout>absent());

  return aggLayout;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:20,代码来源:TestActivationStage.java


示例5: addRawLayout

import org.apache.calcite.sql.type.SqlTypeFamily; //导入依赖的package包/类
private Layout addRawLayout(Acceleration acceleration, int layoutNum) {
  List<LayoutField> measureFields = new ArrayList<>();
  measureFields.add(new LayoutField().setName("dim" + layoutNum).setTypeFamily(SqlTypeFamily.CHARACTER.toString()));
  measureFields.add(new LayoutField().setName("measure" + layoutNum).setTypeFamily(SqlTypeFamily.NUMERIC.toString()));

  Layout rawLayout = new Layout()
    .setLayoutType(LayoutType.RAW)
    .setDetails(new LayoutDetails().setDisplayFieldList(measureFields))
    .setId(new LayoutId("rawLayout" + layoutNum))
    .setName("rawLayout")
    .setVersion(0);

  acceleration.getRawLayouts().getLayoutList().add(rawLayout);

  when(store.get(rawLayout.getId())).thenReturn(Optional.<MaterializedLayout>absent());

  return rawLayout;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:19,代码来源:TestActivationStage.java


示例6: mockContext

import org.apache.calcite.sql.type.SqlTypeFamily; //导入依赖的package包/类
private void mockContext(StageContext context) {
  Mockito.reset(context);

  RowType schema = new RowType();
  schema.setFieldList(ImmutableList.of(
    new ViewFieldType("dim0", SqlTypeName.CHAR.getName()).setTypeFamily(SqlTypeFamily.CHARACTER.toString()),
    new ViewFieldType("measure0", SqlTypeName.DOUBLE.getName()).setTypeFamily(SqlTypeFamily.NUMERIC.toString())
  ));

  // Set up an empty acceleration for the original.
  final Acceleration currentAcceleration = new Acceleration()
    .setContext(new AccelerationContext().setDataset(new DatasetConfig().setFullPathList(ImmutableList.of("a", "b"))).setDatasetSchema(schema))
    .setRawLayouts(new LayoutContainer().setLayoutList(new ArrayList<Layout>()))
    .setAggregationLayouts(new LayoutContainer().setLayoutList(new ArrayList<Layout>()));

  when(context.getCurrentAcceleration()).thenReturn(currentAcceleration);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:18,代码来源:TestLayoutUpdateStage.java


示例7: addAggLayout

import org.apache.calcite.sql.type.SqlTypeFamily; //导入依赖的package包/类
private Layout addAggLayout(Acceleration acceleration, int layoutNum) {
  List<LayoutDimensionField> dimFields = new ArrayList<>();
  dimFields.add(new LayoutDimensionField().setName("dim" + layoutNum).setTypeFamily(SqlTypeFamily.CHARACTER.toString()));
  List<LayoutField> measureFields = new ArrayList<>();
  measureFields.add(new LayoutField().setName("measure" + layoutNum).setTypeFamily(SqlTypeFamily.NUMERIC.toString()));

  Layout aggLayout = new Layout()
    .setLayoutType(LayoutType.AGGREGATION)
    .setDetails(new LayoutDetails().setDimensionFieldList(dimFields).setMeasureFieldList(measureFields))
    .setId(new LayoutId("aggLayout" + layoutNum))
    .setName("aggLayout")
    .setVersion(0);

  acceleration.getAggregationLayouts().getLayoutList().add(aggLayout);

  return aggLayout;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:18,代码来源:TestLayoutUpdateStage.java


示例8: addRawLayout

import org.apache.calcite.sql.type.SqlTypeFamily; //导入依赖的package包/类
private Layout addRawLayout(Acceleration acceleration, int layoutNum) {
  List<LayoutField> measureFields = new ArrayList<>();
  measureFields.add(new LayoutField().setName("dim" + layoutNum).setTypeFamily(SqlTypeFamily.CHARACTER.toString()));
  measureFields.add(new LayoutField().setName("measure" + layoutNum).setTypeFamily(SqlTypeFamily.NUMERIC.toString()));

  Layout rawLayout = new Layout()
    .setLayoutType(LayoutType.RAW)
    .setDetails(new LayoutDetails().setDisplayFieldList(measureFields))
    .setId(new LayoutId("rawLayout" + layoutNum))
    .setName("rawLayout")
    .setVersion(0);

  acceleration.getRawLayouts().getLayoutList().add(rawLayout);

  return rawLayout;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:17,代码来源:TestLayoutUpdateStage.java


示例9: checkForIncompatibleDateTimeOperands

import org.apache.calcite.sql.type.SqlTypeFamily; //导入依赖的package包/类
/**
 * If one operand in a binary operator is a DateTime type, but the other isn't, we should not push down the predicate
 * @param call
 */
public static void checkForIncompatibleDateTimeOperands(RexCall call) {
  RelDataType op1 = call.getOperands().get(0).getType();
  RelDataType op2 = call.getOperands().get(1).getType();
  if (
      (SqlTypeFamily.DATETIME.contains(op1) && !SqlTypeFamily.DATETIME.contains(op2)) ||
      (SqlTypeFamily.DATETIME.contains(op2) && !SqlTypeFamily.DATETIME.contains(op1)) ||
      (SqlTypeFamily.DATE.contains(op1) && !SqlTypeFamily.DATE.contains(op2)) ||
      (SqlTypeFamily.DATE.contains(op2) && !SqlTypeFamily.DATE.contains(op1)) ||
      (SqlTypeFamily.TIMESTAMP.contains(op1) && !SqlTypeFamily.TIMESTAMP.contains(op2)) ||
      (SqlTypeFamily.TIMESTAMP.contains(op2) && !SqlTypeFamily.TIMESTAMP.contains(op1)) ||
      (SqlTypeFamily.TIME.contains(op1) && !SqlTypeFamily.TIME.contains(op2)) ||
      (SqlTypeFamily.TIME.contains(op2) && !SqlTypeFamily.TIME.contains(op1)))
  {
    throw new PredicateAnalyzerException("Cannot handle " + call.getKind() + " expression for _id field, " + call);
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:21,代码来源:PredicateAnalyzer.java


示例10: getChecker

import org.apache.calcite.sql.type.SqlTypeFamily; //导入依赖的package包/类
private SqlSingleOperandTypeChecker getChecker(RelDataType operandType) {
  switch (operandType.getSqlTypeName()) {
  case ARRAY:
    return OperandTypes.family(SqlTypeFamily.INTEGER);
  case MAP:
    return OperandTypes.family(
        operandType.getKeyType().getSqlTypeName().getFamily());
  case ANY:
  case DYNAMIC_STAR:
    return OperandTypes.or(
        OperandTypes.family(SqlTypeFamily.INTEGER),
        OperandTypes.family(SqlTypeFamily.CHARACTER));
  default:
    throw new AssertionError(operandType.getSqlTypeName());
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:17,代码来源:SqlItemOperator.java


示例11: getRowType

import org.apache.calcite.sql.type.SqlTypeFamily; //导入依赖的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);
  }
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:33,代码来源:View.java


示例12: getRowType

import org.apache.calcite.sql.type.SqlTypeFamily; //导入依赖的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);
  }
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:30,代码来源:View.java


示例13: checkSingleOperandType

import org.apache.calcite.sql.type.SqlTypeFamily; //导入依赖的package包/类
@Override
public boolean checkSingleOperandType(SqlCallBinding callBinding, SqlNode node,
    int iFormalOperand, boolean throwOnFailure) {

  // check that the input is a literal.
  if(!super.checkSingleOperandType(callBinding, node, iFormalOperand, throwOnFailure)) {
    return false;
  }

  final RelDataType type = callBinding.getValidator().deriveType(callBinding.getScope(), node);
  final SqlTypeName typeName = type.getSqlTypeName();

  // Pass type checking for operators if it's of type 'ANY'.
  if (typeName.getFamily() == SqlTypeFamily.ANY) {
    return true;
  }

  if(!(typeName == SqlTypeName.CHAR || typeName == SqlTypeName.VARCHAR)) {
    if(throwOnFailure) {
      throw callBinding.newValidationSignatureError();
    }
    return false;
  }

  final SqlLiteral literal = (SqlLiteral) node;
  final String value = ((NlsString)literal.getValue()).getValue();
  if(validStrings.contains(value.toLowerCase())) {
    return true;
  }

  if(throwOnFailure) {
    throw callBinding.newValidationSignatureError();
    //throw new SqlValidatorException(String.format("DATE_PART function only accepts the following values for a date type: %s.", Joiner.on(", ").join(validStrings)), null);
  }

  return false;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:38,代码来源:SqlDatePartOperator.java


示例14: isText

import org.apache.calcite.sql.type.SqlTypeFamily; //导入依赖的package包/类
public static boolean isText(final LayoutField field) {
  final Optional<SqlTypeFamily> familyOpt = getSqlTypeFamily(field);
  if (!familyOpt.isPresent()) {
    return false;
  }

  final SqlTypeFamily family = familyOpt.get();
  return family == SqlTypeFamily.CHARACTER;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:10,代码来源:TypeUtils.java


示例15: isNumeric

import org.apache.calcite.sql.type.SqlTypeFamily; //导入依赖的package包/类
public static boolean isNumeric(final LayoutField field) {
  final Optional<SqlTypeFamily> familyOpt = getSqlTypeFamily(field);
  if (!familyOpt.isPresent()) {
    return false;
  }

  final SqlTypeFamily family = familyOpt.get();
  return family == SqlTypeFamily.NUMERIC;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:10,代码来源:TypeUtils.java


示例16: isBoolean

import org.apache.calcite.sql.type.SqlTypeFamily; //导入依赖的package包/类
public static boolean isBoolean(final LayoutField field) {
  final Optional<SqlTypeFamily> familyOpt = getSqlTypeFamily(field);
  if (!familyOpt.isPresent()) {
    return false;
  }
  final SqlTypeFamily family = familyOpt.get();
  return family == SqlTypeFamily.BOOLEAN;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:9,代码来源:TypeUtils.java


示例17: isComplex

import org.apache.calcite.sql.type.SqlTypeFamily; //导入依赖的package包/类
public static boolean isComplex(final LayoutField field) {
  final Optional<SqlTypeFamily> familyOpt = getSqlTypeFamily(field);
  if (!familyOpt.isPresent()) {
    return false;
  }
  final SqlTypeFamily family = familyOpt.get();
  return family == SqlTypeFamily.ANY;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:9,代码来源:TypeUtils.java


示例18: getSqlTypeFamily

import org.apache.calcite.sql.type.SqlTypeFamily; //导入依赖的package包/类
public static Optional<SqlTypeFamily> getSqlTypeFamily(final LayoutField field) {
  try {
    return Optional.of(SqlTypeFamily.valueOf(field.getTypeFamily()));
  } catch (final IllegalArgumentException ex) {
    return Optional.absent();
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:8,代码来源:TypeUtils.java


示例19: SqlTimestampAddFunction

import org.apache.calcite.sql.type.SqlTypeFamily; //导入依赖的package包/类
/** Creates a SqlTimestampAddFunction. */
SqlTimestampAddFunction() {
    super("TIMESTAMPADD", SqlKind.TIMESTAMP_ADD, RETURN_TYPE_INFERENCE, null,
          OperandTypes.family(SqlTypeFamily.ANY, SqlTypeFamily.INTEGER,
                              SqlTypeFamily.TIMESTAMP),
          SqlFunctionCategory.TIMEDATE);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:8,代码来源:SqlTimestampAddFunction.java


示例20: createCustomAggFunction

import org.apache.calcite.sql.type.SqlTypeFamily; //导入依赖的package包/类
SqlAggFunction createCustomAggFunction(String funcName, RelDataType returnType, Class<?> customAggFuncClz) {
    RelDataTypeFactory typeFactory = getCluster().getTypeFactory();
    SqlIdentifier sqlIdentifier = new SqlIdentifier(funcName, new SqlParserPos(1, 1));
    AggregateFunction aggFunction = AggregateFunctionImpl.create(customAggFuncClz);
    List<RelDataType> argTypes = new ArrayList<RelDataType>();
    List<SqlTypeFamily> typeFamilies = new ArrayList<SqlTypeFamily>();
    for (FunctionParameter o : aggFunction.getParameters()) {
        final RelDataType type = o.getType(typeFactory);
        argTypes.add(type);
        typeFamilies.add(Util.first(type.getSqlTypeName().getFamily(), SqlTypeFamily.ANY));
    }
    return new SqlUserDefinedAggFunction(sqlIdentifier, ReturnTypes.explicit(returnType),
            InferTypes.explicit(argTypes), OperandTypes.family(typeFamilies), aggFunction, false, false);
}
 
开发者ID:apache,项目名称:kylin,代码行数:15,代码来源:OLAPAggregateRel.java



注:本文中的org.apache.calcite.sql.type.SqlTypeFamily类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CreateImageRequest类代码示例发布时间:2022-05-22
下一篇:
Java DisableOnDebug类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap