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

Java RelRecordType类代码示例

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

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



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

示例1: toSql

import org.apache.calcite.rel.type.RelRecordType; //导入依赖的package包/类
public RelDataType toSql(RelDataType type) {
    if (type instanceof RelRecordType) {
        return createStructType(
                Lists.transform(type.getFieldList(),
                        new Function<RelDataTypeField, RelDataType>() {
                            public RelDataType apply(RelDataTypeField a0) {
                                return toSql(a0.getType());
                            }
                        }),
                type.getFieldNames());
    }
    if (type instanceof JavaType) {
        return createTypeWithNullability(
                createSqlType(type.getSqlTypeName()),
                type.isNullable());
    }
    return type;
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:19,代码来源:JavaTypeFactoryImpl.java


示例2: createSyntheticType

import org.apache.calcite.rel.type.RelRecordType; //导入依赖的package包/类
/**
 * Creates a synthetic Java class whose fields have the same names and
 * relational types.
 */
private Type createSyntheticType(RelRecordType type) {
    final String name =
            "Record" + type.getFieldCount() + "_" + syntheticTypes.size();
    final SyntheticRecordType syntheticType =
            new SyntheticRecordType(type, name);
    for (final RelDataTypeField recordField : type.getFieldList()) {
        final Type javaClass = getJavaClass(recordField.getType());
        syntheticType.fields.add(
                new RecordFieldImpl(
                        syntheticType,
                        recordField.getName(),
                        javaClass,
                        recordField.getType().isNullable()
                                && !Primitive.is(javaClass),
                        Modifier.PUBLIC));
    }
    return register(syntheticType);
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:23,代码来源:JavaTypeFactoryImpl.java


示例3: testSimpleSchemaConversion

import org.apache.calcite.rel.type.RelRecordType; //导入依赖的package包/类
@Test
public void testSimpleSchemaConversion() {
  String streamName = "stream";

  RelDataType dataType = simpleRecordSchemaProvider.getRelationalSchema();
  junit.framework.Assert.assertTrue(dataType instanceof RelRecordType);
  RelRecordType recordType = (RelRecordType) dataType;

  junit.framework.Assert.assertEquals(recordType.getFieldCount(), SimpleRecord.SCHEMA$.getFields().size());
  junit.framework.Assert.assertTrue(
      recordType.getField("id", true, false).getType().getSqlTypeName() == SqlTypeName.INTEGER);
  junit.framework.Assert.assertTrue(
      recordType.getField("name", true, false).getType().getSqlTypeName() == SqlTypeName.VARCHAR);

  LOG.info("Relational schema " + dataType);
}
 
开发者ID:apache,项目名称:samza,代码行数:17,代码来源:TestAvroRelConversion.java


示例4: getDataSourceRowType

import org.apache.calcite.rel.type.RelRecordType; //导入依赖的package包/类
private RelDataType getDataSourceRowType() throws SQLException {

    List<RelDataTypeField> relDataTypeFields =
        ImmutableList.<RelDataTypeField>of(
            new RelDataTypeFieldImpl("id", 1, getIntegerJavaType()),
            new RelDataTypeFieldImpl("type", 2, getStringJavaType()),
            new RelDataTypeFieldImpl("url", 3, getStringJavaType()),
            new RelDataTypeFieldImpl("name", 4, getStringJavaType()),
            new RelDataTypeFieldImpl("ds_set_id", 5, getIntegerJavaType()),
            new RelDataTypeFieldImpl("datasource_type", 6, getStringJavaType()),
            new RelDataTypeFieldImpl("auth_token", 7, getStringJavaType()),
            new RelDataTypeFieldImpl("dbtap_id", 8, getIntegerJavaType()),
            new RelDataTypeFieldImpl("username", 9, getStringJavaType()),
            new RelDataTypeFieldImpl("password", 10, getStringJavaType()));

    return new RelRecordType(relDataTypeFields);
  }
 
开发者ID:qubole,项目名称:quark,代码行数:18,代码来源:PlanExecutor.java


示例5: getViewRowType

import org.apache.calcite.rel.type.RelRecordType; //导入依赖的package包/类
private RelDataType getViewRowType() {

    List<RelDataTypeField> relDataTypeFields =
        ImmutableList.<RelDataTypeField>of(
            new RelDataTypeFieldImpl("id", 1, getIntegerJavaType()),
            new RelDataTypeFieldImpl("name", 2, getStringJavaType()),
            new RelDataTypeFieldImpl("description", 3, getStringJavaType()),
            new RelDataTypeFieldImpl("cost", 4, getIntegerJavaType()),
            new RelDataTypeFieldImpl("query", 5, getStringJavaType()),
            new RelDataTypeFieldImpl("destination_id", 6, getIntegerJavaType()),
            new RelDataTypeFieldImpl("schema_name", 7, getStringJavaType()),
            new RelDataTypeFieldImpl("table_name", 8, getStringJavaType()),
            new RelDataTypeFieldImpl("ds_set_id", 9, getIntegerJavaType()));

    return new RelRecordType(relDataTypeFields);
  }
 
开发者ID:qubole,项目名称:quark,代码行数:17,代码来源:PlanExecutor.java


示例6: toSql

import org.apache.calcite.rel.type.RelRecordType; //导入依赖的package包/类
/** Converts a type in Java format to a SQL-oriented type. */
public static RelDataType toSql(final RelDataTypeFactory typeFactory,
    RelDataType type) {
  if (type instanceof RelRecordType) {
    return typeFactory.createStructType(
        Lists.transform(type.getFieldList(),
            new Function<RelDataTypeField, RelDataType>() {
              public RelDataType apply(RelDataTypeField a0) {
                return toSql(typeFactory, a0.getType());
              }
            }),
        type.getFieldNames());
  }
  if (type instanceof JavaType) {
    return typeFactory.createTypeWithNullability(
        typeFactory.createSqlType(type.getSqlTypeName()),
        type.isNullable());
  }
  return type;
}
 
开发者ID:apache,项目名称:calcite,代码行数:21,代码来源:JavaTypeFactoryImpl.java


示例7: createSyntheticType

import org.apache.calcite.rel.type.RelRecordType; //导入依赖的package包/类
/** Creates a synthetic Java class whose fields have the same names and
 * relational types. */
private Type createSyntheticType(RelRecordType type) {
  final String name =
      "Record" + type.getFieldCount() + "_" + syntheticTypes.size();
  final SyntheticRecordType syntheticType =
      new SyntheticRecordType(type, name);
  for (final RelDataTypeField recordField : type.getFieldList()) {
    final Type javaClass = getJavaClass(recordField.getType());
    syntheticType.fields.add(
        new RecordFieldImpl(
            syntheticType,
            recordField.getName(),
            javaClass,
            recordField.getType().isNullable()
                && !Primitive.is(javaClass),
            Modifier.PUBLIC));
  }
  return register(syntheticType);
}
 
开发者ID:apache,项目名称:calcite,代码行数:21,代码来源:JavaTypeFactoryImpl.java


示例8: convert

import org.apache.calcite.rel.type.RelRecordType; //导入依赖的package包/类
public static DrillProjectRel convert(Project project, ConversionContext context) throws InvalidRelException{
  RelNode input = context.toRel(project.getInput());
  List<RelDataTypeField> fields = Lists.newArrayList();
  List<RexNode> exps = Lists.newArrayList();
  for(NamedExpression expr : project.getSelections()){
    fields.add(new RelDataTypeFieldImpl(expr.getRef().getRootSegment().getPath(), fields.size(), context.getTypeFactory().createSqlType(SqlTypeName.ANY) ));
    exps.add(context.toRex(expr.getExpr()));
  }
  return new DrillProjectRel(context.getCluster(), context.getLogicalTraits(), input, exps, new RelRecordType(fields));
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:11,代码来源:DrillProjectRel.java


示例9: convert

import org.apache.calcite.rel.type.RelRecordType; //导入依赖的package包/类
public static ProjectRel convert(Project project, ConversionContext context) throws InvalidRelException{
  RelNode input = context.toRel(project.getInput());
  List<RelDataTypeField> fields = Lists.newArrayList();
  List<RexNode> exps = Lists.newArrayList();
  for(NamedExpression expr : project.getSelections()){
    fields.add(new RelDataTypeFieldImpl(expr.getRef().getRootSegment().getPath(), fields.size(), context.getTypeFactory().createSqlType(SqlTypeName.ANY) ));
    exps.add(context.toRex(expr.getExpr()));
  }
  return new ProjectRel(context.getCluster(), context.getLogicalTraits(), input, exps, new RelRecordType(fields));
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:11,代码来源:ProjectRel.java


示例10: testUpdateSql

import org.apache.calcite.rel.type.RelRecordType; //导入依赖的package包/类
@Test
public void testUpdateSql() throws Exception {
  final String sql = "select foo, bar as b from tbl";
  SqlParser parser = SqlParser.create(sql, new ParserConfig(Quoting.DOUBLE_QUOTE, 128));
  final SqlNode sqlNode = parser.parseStmt();


  final JavaTypeFactory typeFactory = new JavaTypeFactoryImpl();
  final RelDataType rowType = new RelRecordType(Arrays.<RelDataTypeField>asList(
      new RelDataTypeFieldImpl("foo", 0, typeFactory.createSqlType(SqlTypeName.INTEGER)),
      new RelDataTypeFieldImpl("b", 0, typeFactory.createSqlType(SqlTypeName.INTEGER))
  ));

  TransformActor actor = new TransformActor(state, false, "test_user", null) {
    @Override
    protected QueryMetadata getMetadata(SqlQuery query) {
      return new QueryMetadata(null, null, null, null, sqlNode, rowType, null, null, null, null, BatchSchema.fromCalciteRowType(rowType));
    }

    @Override
    protected boolean hasMetadata() {
      return true;
    }
  };

  TransformResult result = new TransformUpdateSQL(sql).accept(actor);
  VirtualDatasetState newState = result.getNewState();

  assertEquals(2, newState.getColumnsList().size());
  assertEquals("foo", newState.getColumnsList().get(0).getName());
  assertEquals(new ExpColumnReference("foo").wrap(), newState.getColumnsList().get(0).getValue());
  assertEquals("b", newState.getColumnsList().get(1).getName());
  assertEquals(new ExpColumnReference("bar").wrap(), newState.getColumnsList().get(1).getValue());
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:35,代码来源:TestTransformer.java


示例11: visitProject

import org.apache.calcite.rel.type.RelRecordType; //导入依赖的package包/类
@Override
public Prel visitProject(ProjectPrel node, Object unused) throws RelConversionException {
  ProjectPrel project = node;
  List<RexNode> exprList = new ArrayList<>();
  boolean rewrite = false;

  List<RelDataTypeField> relDataTypes = new ArrayList<>();
  int i = 0;
  RexNode flatttenExpr = null;
  for (RexNode rex : project.getChildExps()) {
    RexNode newExpr = rex;
    if (rex instanceof RexCall) {
      RexCall function = (RexCall) rex;
      String functionName = function.getOperator().getName();

      if (functionName.equalsIgnoreCase("flatten") ) {
        rewrite = true;
        if (function.getOperands().size() != 1) {
          throw new RelConversionException("Flatten expression expects a single input.");
        }
        newExpr = function.getOperands().get(0);
        RexBuilder builder = new RexBuilder(factory);
        flatttenExpr = builder.makeInputRef( new RelDataTypeDrillImpl(new RelDataTypeHolder(), factory), i);
      }
    }
    relDataTypes.add(project.getRowType().getFieldList().get(i));
    i++;
    exprList.add(newExpr);
  }
  if (rewrite == true) {
    // TODO - figure out what is the right setting for the traits
    Prel newChild = ((Prel)project.getInput(0)).accept(this, null);
    ProjectPrel newProject = new ProjectPrel(node.getCluster(), project.getTraitSet(), newChild, exprList, new RelRecordType(relDataTypes));
    FlattenPrel flatten = new FlattenPrel(project.getCluster(), project.getTraitSet(), newProject, flatttenExpr);
    return flatten;
  }

  Prel child = ((Prel)project.getInput()).accept(this, null);
  return (Prel) project.copy(project.getTraitSet(), child, exprList, new RelRecordType(relDataTypes));
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:41,代码来源:RewriteProjectToFlatten.java


示例12: constructDataType

import org.apache.calcite.rel.type.RelRecordType; //导入依赖的package包/类
/**
 * For each aggregate call creates field based on its name with bigint type.
 * Constructs record type for created fields.
 *
 * @param aggregateRel aggregate relation expression
 * @param fieldNames field names
 * @return record type
 */
private RelDataType constructDataType(DrillAggregateRel aggregateRel, Collection<String> fieldNames) {
  List<RelDataTypeField> fields = new ArrayList<>();
  Iterator<String> filedNamesIterator = fieldNames.iterator();
  int fieldIndex = 0;
  while (filedNamesIterator.hasNext()) {
    RelDataTypeField field = new RelDataTypeFieldImpl(
        filedNamesIterator.next(),
        fieldIndex++,
        aggregateRel.getCluster().getTypeFactory().createSqlType(SqlTypeName.BIGINT));
    fields.add(field);
  }
  return new RelRecordType(fields);
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:22,代码来源:ConvertCountToDirectScan.java


示例13: createType

import org.apache.calcite.rel.type.RelRecordType; //导入依赖的package包/类
public RelDataType createType(Schema schema) {
  Schema.Type type = schema.getType();
  if (type != Schema.Type.RECORD) {
    String msg =
        String.format("System supports only RECORD as top level avro type, But the Schema's type is %s", type);
    LOG.error(msg);
    throw new SamzaException(msg);
  }

  List<RelDataTypeField> relFields = getRelFields(schema.getFields());
  return new RelRecordType(relFields);
}
 
开发者ID:apache,项目名称:samza,代码行数:13,代码来源:AvroTypeFactoryImpl.java


示例14: createTableFromRelSchema

import org.apache.calcite.rel.type.RelRecordType; //导入依赖的package包/类
private Table createTableFromRelSchema(RelDataType relationalSchema) {
  return new AbstractTable() {
    public RelDataType getRowType(RelDataTypeFactory typeFactory) {
      List<RelDataTypeField> fieldsList = new ArrayList<>();
      fieldsList.add(new RelDataTypeFieldImpl(SamzaSqlRelMessage.KEY_NAME, 0,
          typeFactory.createTypeWithNullability(typeFactory.createSqlType(SqlTypeName.VARCHAR), true)));
      fieldsList.addAll(relationalSchema.getFieldList());
      return new RelRecordType(fieldsList);
    }
  };
}
 
开发者ID:apache,项目名称:samza,代码行数:12,代码来源:QueryPlanner.java


示例15: visitProject

import org.apache.calcite.rel.type.RelRecordType; //导入依赖的package包/类
@Override
public Prel visitProject(ProjectPrel node, Object unused) throws RelConversionException {
  ProjectPrel project = node;
  List<RexNode> exprList = new ArrayList<>();
  boolean rewrite = false;

  List<RelDataTypeField> relDataTypes = new ArrayList();
  int i = 0;
  RexNode flatttenExpr = null;
  for (RexNode rex : project.getChildExps()) {
    RexNode newExpr = rex;
    if (rex instanceof RexCall) {
      RexCall function = (RexCall) rex;
      String functionName = function.getOperator().getName();
      int nArgs = function.getOperands().size();

      if (functionName.equalsIgnoreCase("flatten") ) {
        rewrite = true;
        if (function.getOperands().size() != 1) {
          throw new RelConversionException("Flatten expression expects a single input.");
        }
        newExpr = function.getOperands().get(0);
        RexBuilder builder = new RexBuilder(factory);
        flatttenExpr = builder.makeInputRef( new RelDataTypeDrillImpl(new RelDataTypeHolder(), factory), i);
      }
    }
    relDataTypes.add(project.getRowType().getFieldList().get(i));
    i++;
    exprList.add(newExpr);
  }
  if (rewrite == true) {
    // TODO - figure out what is the right setting for the traits
    Prel newChild = ((Prel)project.getInput(0)).accept(this, null);
    ProjectPrel newProject = new ProjectPrel(node.getCluster(), project.getTraitSet(), newChild, exprList, new RelRecordType(relDataTypes));
    FlattenPrel flatten = new FlattenPrel(project.getCluster(), project.getTraitSet(), newProject, flatttenExpr);
    return flatten;
  }

  Prel child = ((Prel)project.getInput()).accept(this, null);
  return (Prel) project.copy(project.getTraitSet(), child, exprList, new RelRecordType(relDataTypes));
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:42,代码来源:RewriteProjectToFlatten.java


示例16: getCountDirectScanRowType

import org.apache.calcite.rel.type.RelRecordType; //导入依赖的package包/类
private RelDataType getCountDirectScanRowType(RelDataTypeFactory typeFactory) {
  List<RelDataTypeField> fields = Lists.newArrayList();
  fields.add(new RelDataTypeFieldImpl("count", 0, typeFactory.createSqlType(SqlTypeName.BIGINT)));

  return new RelRecordType(fields);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:7,代码来源:ConvertCountToDirectScan.java


示例17: visitCall

import org.apache.calcite.rel.type.RelRecordType; //导入依赖的package包/类
@Override
public Boolean visitCall(RexCall call) {
  if (call.getOperator().getName().equalsIgnoreCase("contains")) {
    if (!checkOrigin) {
      return true;
    }
    // Check origin
    final Set<RelColumnOrigin> origins;
    if (index >= 0) {
      origins = mq.getColumnOrigins(node, index);
    } else {
      List<RelDataTypeField> fields = ImmutableList.<RelDataTypeField>of(new RelDataTypeFieldImpl("ContainsTemp", 0, call.getType()));
      Project temporary =
          new LogicalProject(node.getCluster(), node.getTraitSet().plus(Convention.NONE), node.getInput(0), ImmutableList.of(call), new RelRecordType(fields));
      origins = mq.getColumnOrigins(temporary, 0);
    }

    boolean supportContains = true;
    if (origins == null) {
      supportContains = false;
    } else {
      for (RelColumnOrigin column : origins) {
        if (column.getOriginTable() == null) {
          supportContains = false;
        } else {
          OldNamespaceTable namespaceTable = column.getOriginTable().unwrap(OldNamespaceTable.class);
          NamespaceTable namespaceTable2 = column.getOriginTable().unwrap(NamespaceTable.class);
          if (namespaceTable != null) {
            if (!namespaceTable.getPlugin().supportsContains()) {
              supportContains = false;
            }
          } else if (namespaceTable2 != null) {
            if(!namespaceTable2.getStoragePluginId().getCapabilities().getCapability(SourceCapabilities.SUPPORTS_CONTAINS)){
              supportContains = false;
            }
          } else {
            supportContains = false;
          }
        }
      }
    }
    if (!supportContains) {
      throw UserException.unsupportedError().message("Contains operator is not supported for the table, %s", call).build(logger);
    }
    return true;
  }

  for (RexNode op : call.getOperands()) {
    Boolean opResult = op.accept(this);
    if (opResult != null && opResult.booleanValue()) {
      return true;
    }
  }
  return false;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:56,代码来源:MoreRelOptUtil.java


示例18: getCountRowType

import org.apache.calcite.rel.type.RelRecordType; //导入依赖的package包/类
private RelDataType getCountRowType(RelDataTypeFactory typeFactory) {
  List<RelDataTypeField> fields = Lists.newArrayList();
  fields.add(new RelDataTypeFieldImpl("count", 0, typeFactory.createSqlType(SqlTypeName.BIGINT)));
  return new RelRecordType(fields);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:6,代码来源:ConvertCountToDirectScan.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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