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


Java SqlTypeName类代码示例

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


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

示例1: parseColumns

import org.apache.calcite.sql.type.SqlTypeName; //导入依赖的package包/类
private static Map<String, SqlTypeName> parseColumns(final Map<String, Object> args, final String columnName)
		throws SolrSqlException {
	return parseSafeArgument(args, columnName,
			"comma seperated column definitions, each column is describled in format 'column_name column_type_name', e.g. 'id integer, name char, age integer'",
			"", new Parser() {
				final Map<String, SqlTypeName> _tMap = new LinkedHashMap<>();

				@SuppressWarnings("unchecked")
				public Map<String, SqlTypeName> parse(String value) throws SolrSqlException {
					String column = (String) args.get(columnName);
					String[] fileds = column.split("\\s*,\\s*");
					for (String f : fileds) {
						String[] filedAndValue = f.split("\\s");
						_tMap.put(filedAndValue[0], toSqlTypeName(filedAndValue[1]));
					}
					return _tMap;
				}
			});
}
 
开发者ID:jenkin2016,项目名称:solr-sql,代码行数:20,代码来源:SolrTableFactory.java

示例2: getField

import org.apache.calcite.sql.type.SqlTypeName; //导入依赖的package包/类
public RelDataTypeField getField(RelDataTypeFactory typeFactory, String fieldName) {

    /* First check if this field name exists in our field list */
    for (RelDataTypeField f : fields) {
      if (fieldName.equalsIgnoreCase(f.getName())) {
        return f;
      }
    }

    /* This field does not exist in our field list add it */
    RelDataTypeField newField = new RelDataTypeFieldImpl(fieldName, fields.size(), typeFactory.createTypeWithNullability(typeFactory.createSqlType(SqlTypeName.ANY), true));

    /* Add the name to our list of field names */
    fields.add(newField);

    return newField;
  }
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:18,代码来源:RelDataTypeHolder.java

示例3: equalityWithCast

import org.apache.calcite.sql.type.SqlTypeName; //导入依赖的package包/类
@Test
public void equalityWithCast(){

  final RexNode node = builder.makeCall(SqlStdOperatorTable.EQUALS,
      builder.makeCast(
          factory.createSqlType(SqlTypeName.ANY),
          builder.makeBigintLiteral(BigDecimal.ONE)
      ),
      builder.makeInputRef(factory.createSqlType(SqlTypeName.BIGINT), 0)
  );

  FindSimpleFilters finder = new FindSimpleFilters(builder);
  StateHolder holder = node.accept(finder);
  ImmutableList<RexCall> conditions = holder.getConditions();

  assertEquals(1, conditions.size());
  assertEquals(SqlKind.EQUALS, conditions.get(0).getKind());
  // Make sure CAST was removed
  assertEquals(SqlKind.LITERAL, conditions.get(0).getOperands().get(0).getKind());
  assertFalse(holder.hasRemainingExpression());

}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:23,代码来源:TestFilterFinder.java

示例4: createCalciteTypeWithNullability

import org.apache.calcite.sql.type.SqlTypeName; //导入依赖的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

示例5: convertCall

import org.apache.calcite.sql.type.SqlTypeName; //导入依赖的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<>();

  RelDataTypeFactory typeFactory = cx.getTypeFactory();

  //RelDataType nullableReturnType =

  for (SqlNode node: operands) {
     exprs.add(cx.convertExpression(node));
  }

  // Determine NULL-able using 2nd argument's Null-able.
  RelDataType returnType = typeFactory.createTypeWithNullability(typeFactory.createSqlType(SqlTypeName.BIGINT), exprs.get(1).getType().isNullable());

  return rexBuilder.makeCall(returnType, call.getOperator(), exprs);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:20,代码来源:DrillExtractConvertlet.java

示例6: visitCall

import org.apache.calcite.sql.type.SqlTypeName; //导入依赖的package包/类
@Override
public Boolean visitCall(RexCall call) {
  if (call.getOperator() == SqlStdOperatorTable.ITEM) {
    final RexNode op0 = call.getOperands().get(0);
    final RexNode op1 = call.getOperands().get(1);

    if (op0 instanceof RexInputRef &&
        op1 instanceof RexLiteral && ((RexLiteral) op1).getTypeName() == SqlTypeName.CHAR) {
      return true;
    } else if (op0 instanceof RexCall &&
        op1 instanceof RexLiteral && ((RexLiteral) op1).getTypeName() == SqlTypeName.CHAR) {
      return op0.accept(this);
    }
  }

  return false;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:18,代码来源:DrillProjectRelBase.java

示例7: createColumnFormatConversion

import org.apache.calcite.sql.type.SqlTypeName; //导入依赖的package包/类
/**
 * Apply any data format conversion expressions.
 */
private RexNode createColumnFormatConversion(final DrillScanRel hiveScanRel, final DrillScanRel nativeScanRel,
    final String colName, final RexBuilder rb) {

  final RelDataType outputType = hiveScanRel.getRowType().getField(colName, false, false).getType();
  final RelDataTypeField inputField = nativeScanRel.getRowType().getField(colName, false, false);
  final RexInputRef inputRef = rb.makeInputRef(inputField.getType(), inputField.getIndex());

  if (outputType.getSqlTypeName() == SqlTypeName.TIMESTAMP) {
    // TIMESTAMP is stored as INT96 by Hive in ParquetFormat. Use convert_fromTIMESTAMP_IMPALA UDF to convert
    // INT96 format data to TIMESTAMP
    return rb.makeCall(INT96_TO_TIMESTAMP, inputRef);
  }

  return inputRef;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:19,代码来源:ConvertHiveParquetScanToDrillParquetScan.java

示例8: isScalar

import org.apache.calcite.sql.type.SqlTypeName; //导入依赖的package包/类
private static boolean isScalar(final String type) {
  final SqlTypeName sqlType = SqlTypeName.valueOf(type);
  switch (sqlType) {
    case BIGINT:
    case BINARY:
    case BOOLEAN:
    case CHAR:
    case DATE:
    case DECIMAL:
    case DOUBLE:
    case FLOAT:
    case INTEGER:
    case REAL:
    case TIME:
    case TIMESTAMP:
    case TINYINT:
    case VARBINARY:
    case VARCHAR:
      return true;
    default:
      return false;
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:24,代码来源:AccelerationServiceImpl.java

示例9: FieldType

import org.apache.calcite.sql.type.SqlTypeName; //导入依赖的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:dremio,项目名称:dremio-oss,代码行数:26,代码来源:View.java

示例10: deriveSumType

import org.apache.calcite.sql.type.SqlTypeName; //导入依赖的package包/类
@Override
public RelDataType deriveSumType(
    RelDataTypeFactory typeFactory, RelDataType argumentType) {
  SqlTypeName sqlTypeName = argumentType.getSqlTypeName();
  switch (sqlTypeName) {
    case TINYINT:
    case SMALLINT:
    case INTEGER:
    case BIGINT:
      return typeFactory.createTypeWithNullability(typeFactory.createSqlType(SqlTypeName.BIGINT), argumentType.isNullable());
    case FLOAT:
    case DOUBLE:
      return typeFactory.createTypeWithNullability(typeFactory.createSqlType(SqlTypeName.DOUBLE), argumentType.isNullable());
  }
  return argumentType;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:17,代码来源:RelDataTypeSystemImpl.java

示例11: visitCall

import org.apache.calcite.sql.type.SqlTypeName; //导入依赖的package包/类
@Override
public RexNode visitCall(RexCall call) {

  String functionName = call.getOperator().getName();

  List<RexNode> newOps = new ArrayList<>();
  for (RexNode operand : call.operands) {
    newOps.add(operand.accept(this));
  }
  if (funcReg.isFunctionComplexOutput(functionName)) {
    RexNode ret = builder.makeInputRef( factory.createTypeWithNullability(factory.createSqlType(SqlTypeName.ANY), true), lastUsedIndex);
    lastUsedIndex++;
    complexExprs.add(call.clone(factory.createTypeWithNullability(factory.createSqlType(SqlTypeName.ANY), true), newOps));
    return ret;
  }
  return call.clone(call.getType(), newOps);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:18,代码来源:RexVisitorComplexExprSplitter.java

示例12: convertCall

import org.apache.calcite.sql.type.SqlTypeName; //导入依赖的package包/类
@Override
public RexNode convertCall(SqlRexContext cx, SqlCall call) {
  SqlFlattenOperator operator = (SqlFlattenOperator) call.getOperator();
  final List<RexNode> exprs = new LinkedList<>();

  for (SqlNode node : call.getOperandList()) {
    exprs.add(cx.convertExpression(node));
  }

  SqlFlattenOperator indexedOperator = operator.withIndex(((SqlValidatorImpl)cx.getValidator()).nextFlattenIndex());
  final RexBuilder rexBuilder = cx.getRexBuilder();
  // Since we don't have any way of knowing if the output of the flatten is nullable, we should always assume it is.
  // This is especially important when accelerating a count(column) query, because the normalizer will convert it to
  // a count(1) if it thinks this column is non-nullable, and then remove the flatten altogether. This is actually a
  // problem with the fact that flatten is not really a project operator (because it can output more than one row per input).
  RelDataType type = rexBuilder
    .getTypeFactory()
    .createTypeWithNullability(
      rexBuilder
        .getTypeFactory()
        .createSqlType(SqlTypeName.ANY),
      true
    );
  return rexBuilder.makeCall(type, indexedOperator, exprs);

}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:27,代码来源:FlattenConvertlet.java

示例13: convertCall

import org.apache.calcite.sql.type.SqlTypeName; //导入依赖的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

示例14: testMultiTimestampDimensionCastedToDate

import org.apache.calcite.sql.type.SqlTypeName; //导入依赖的package包/类
@Test
public void testMultiTimestampDimensionCastedToDate() {
  // Set up the dimensions/measures in the test.
  final List<String> names = Arrays.asList("f_dimension_one", "f_dimension_two", "f_measure_two");
  final List<SqlTypeName> types = Arrays.asList(SqlTypeName.TIMESTAMP, SqlTypeName.TIMESTAMP, SqlTypeName.DOUBLE);
  final RelDataType[] rowTypes = getRowTypes(names, types);

  // Create the layout to be used.
  final int split = 2;
  final Layout layout = createLayout(names, types, split);
  layout.getDetails().getDimensionFieldList().get(0).setGranularity(DimensionGranularity.DATE);
  layout.getDetails().getDimensionFieldList().get(1).setGranularity(DimensionGranularity.NORMAL);

  // Test all the possible permutations crossed with nullable combinations.
  testExpandedLayouts(rowTypes, split, layout, new Command() {
    public void validate(RelDataType rowType, RelNode aggregation) {
      compareWithType(rowType, aggregation, names.get(0), SqlTypeName.DATE);
      compare(rowType, aggregation, names.get(1));
    }
  });
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:22,代码来源:TestLayoutExpander.java

示例15: testTimestampDimensionWithDateGranularity

import org.apache.calcite.sql.type.SqlTypeName; //导入依赖的package包/类
@Test
public void testTimestampDimensionWithDateGranularity() {
  // Set up the dimensions/measures in the test.
  final List<String> names = Arrays.asList("f_dimension", "f_measure_one", "f_measure_two");
  final List<SqlTypeName> types = Arrays.asList(SqlTypeName.TIMESTAMP, SqlTypeName.DOUBLE, SqlTypeName.DOUBLE);
  final RelDataType[] rowTypes = getRowTypes(names, types);

  // Create the layout to be used.
  final int split = 1;
  final Layout layout = createLayout(names, types, split);
  layout.getDetails().getDimensionFieldList().get(0).setGranularity(DimensionGranularity.DATE);

  // Test all the possible permutations crossed with nullable combinations.
  testExpandedLayouts(rowTypes, split, layout, new Command() {
    public void validate(RelDataType rowType, RelNode aggregation) {
      compareWithType(rowType, aggregation, names.get(0), SqlTypeName.DATE);
    }
  });
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:20,代码来源:TestLayoutExpander.java


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