当前位置: 首页>>代码示例>>Java>>正文


Java SqlTypeFamily类代码示例

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


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


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