Package org.eigenbase.reltype

Examples of org.eigenbase.reltype.RelDataType


    final MethodCallExpression call = Expressions.call(schema.getExpression(), //
        BuiltinMethod.DATA_CONTEXT_GET_TABLE.method, //
        Expressions.constant(name), //
        Expressions.constant(Object.class));
   
    final RelDataType rowType =
        typeFactory.createStructType(
            Collections.singletonList(
                typeFactory.createMapType(
                    typeFactory.createSqlType(SqlTypeName.VARCHAR),
                    typeFactory.createSqlType(SqlTypeName.ANY))),
View Full Code Here


                        if (isIncluded(types[i].getName(), query)) {
                            com.sforce.soap.partner.Field [] fields =
                                describeSObjectResult.getFields();
                            int ordinal = 0;
                            for (int j = 0; j < fields.length; j++) {
                                RelDataType reltype =
                                    toRelType(
                                        fields[j],
                                        sink.getTypeFactory());
                                sink.writeColumnDescriptor(
                                    types[i].getName(),
                                    fields[j].getName(),
                                    ordinal,
                                    reltype,
                                    null,
                                    null,
                                    EMPTY_PROPERTIES);
                                ordinal++;
                            }
                        }
                        if (isLovIncluded(types[i].getName(), query)) {
                            // import picklist LOV as well
                            RelDataType reltype =
                                sink.getTypeFactory().createTypeWithNullability(
                                    sink.getTypeFactory().createSqlType(
                                        SqlTypeName.VARCHAR,
                                        25 + this.varcharPrecision),
                                    true);
View Full Code Here

                    intermediateTypeList.add(over.getType());
                    flattenedAggCallList.add(over);
                }
            }
        }
        RelDataType intermediateRowType =
            cluster.getTypeFactory().createStructType(
                intermediateTypeList,
                intermediateNameList);

        // The output program is the windowed agg's program, combined with
View Full Code Here

      this.TABLE_CATALOG = catalog;
      this.TABLE_SCHEMA = schemaName;
      this.TABLE_NAME = tableName;

      this.COLUMN_NAME = field.getName();
      RelDataType type = field.getType();
      SqlTypeName sqlType = type.getSqlTypeName();

      this.ORDINAL_POSITION = field.getIndex();
      this.IS_NULLABLE = type.isNullable() ? "YES" : "NO";

      if (sqlType == SqlTypeName.ARRAY || sqlType == SqlTypeName.MAP || sqlType == SqlTypeName.ROW) {
        // For complex types use the toString method to display the inside elements
        String typeString = type.toString();

        // RelDataType.toString prints "RecordType" for "STRUCT".
        this.DATA_TYPE = type.toString().replace("RecordType", "STRUCT");
      } else {
        this.DATA_TYPE = sqlType.toString();
      }

      this.NUMERIC_PRECISION_RADIX = (sqlType == SqlTypeName.DECIMAL) ? 10 : -1; // TODO: where do we get radix?

      if (sqlType == SqlTypeName.VARCHAR) {
        // Max length is stored as precision in Optiq.
        this.CHARACTER_MAXIMUM_LENGTH = (sqlType.allowsPrec()) ? type.getPrecision() : -1;
        this.NUMERIC_PRECISION = -1;
      } else {
        this.CHARACTER_MAXIMUM_LENGTH = -1;
        this.NUMERIC_PRECISION = (sqlType.allowsPrec()) ? type.getPrecision() : -1;
      }

      this.NUMERIC_SCALE = (sqlType.allowsScale())?type.getScale(): -1;
    }
View Full Code Here

        Table table = schema.getTable(tableName);
        // Visit the table, and if requested ...
        if (visitTable(schemaPath,  tableName, table)) {

          // ... do for each of the table's fields.
          RelDataType tableRow = table.getRowType(new JavaTypeFactoryImpl());
          for (RelDataTypeField field: tableRow.getFieldList()) {
            visitField(schemaPath,  tableName, field);
          }
        }
      }
    }
View Full Code Here

    return Statistics.UNKNOWN;
  }

  @Override
  public RelNode toRel(ToRelContext context, RelOptTable relOptTable) {
    RelDataType rowType = relOptTable.getRowType();
    RelNode rel = context.expandView(rowType, view.getSql(), view.getWorkspaceSchemaPath());

    if (view.isDynamic()){
      return rel;
    }else{
View Full Code Here

      return false;
    }
    final List<RelDataTypeField> f1 = rowType1.getFieldList();
    final List<RelDataTypeField> f2 = rowType2.getFieldList();
    for (Pair<RelDataTypeField, RelDataTypeField> pair : Pair.zip(f1, f2)) {
      final RelDataType type1 = pair.left.getType();
      final RelDataType type2 = pair.right.getType();
      // If one of the types is ANY comparison should succeed
      if (type1.getSqlTypeName() == SqlTypeName.ANY
        || type2.getSqlTypeName() == SqlTypeName.ANY) {
        continue;
      }
      if (!type1.equals(type2)) {
        if (allowSubstring
            && (type1.getSqlTypeName() == SqlTypeName.CHAR && type2.getSqlTypeName() == SqlTypeName.CHAR)
            && (type1.getPrecision() <= type2.getPrecision())) {
          return true;
        }          
        return false;
      }
    }
View Full Code Here

    for (RelDataTypeField field : inputFields) {
      RexNode expr = input.getCluster().getRexBuilder().makeInputRef(field.getType(), field.getIndex());
      exprs.add(expr);
    }

    RelDataType rowType = RexUtil.createStructType(input.getCluster().getTypeFactory(), exprs, outputFieldNames);

    ProjectPrel proj = new ProjectPrel(input.getCluster(), input.getTraitSet(), input, exprs, rowType);

    return proj;
  }
View Full Code Here

        SqlNode validatedQuery = planner.validate(createView.getQuery());
        RelNode validatedRelNode = planner.convert(validatedQuery);

        // If view's field list is specified then its size should match view's query field list size.
        RelDataType queryRowType = validatedRelNode.getRowType();

        List<String> viewFieldNames = createView.getFieldNames();
        if (viewFieldNames.size() > 0) {
          // number of fields match.
          if (viewFieldNames.size() != queryRowType.getFieldCount())
            return DirectPlan.createDirectPlan(context, false,
                "View's field list and View's query field list have different counts.");

          // make sure View's query field list has no "*"
          for(String field : queryRowType.getFieldNames()) {
            if (field.equals("*"))
              return DirectPlan.createDirectPlan(context, false,
                  "View's query field list has a '*', which is invalid when View's field list is specified.");
          }

View Full Code Here

      // Convert the query in CTAS statement into a RelNode
      SqlNode validatedQuery = validateNode(sqlCreateTable.getQuery());
      RelNode relQuery = convertToRel(validatedQuery);

      List<String> tblFiledNames = sqlCreateTable.getFieldNames();
      RelDataType queryRowType = relQuery.getRowType();

      if (tblFiledNames.size() > 0) {
        // Field count should match.
        if (tblFiledNames.size() != queryRowType.getFieldCount())
          return DirectPlan.createDirectPlan(context, false,
              "Table's field list and the table's query field list have different counts.");

        // CTAS's query field list shouldn't have "*" when table's field list is specified.
        for(String field : queryRowType.getFieldNames()) {
          if (field.equals("*"))
            return DirectPlan.createDirectPlan(context, false,
                "Table's query field list has a '*', which is invalid when table's field list is specified.");
        }
      }

      // if the CTAS statement has table fields lists (ex. below), add a project rel to rename the query fields.
      // Ex. CREATE TABLE tblname(col1, medianOfCol2, avgOfCol3) AS
      //        SELECT col1, median(col2), avg(col3) FROM sourcetbl GROUP BY col1 ;
      if (tblFiledNames.size() > 0) {
        // create rowtype to which the select rel needs to be casted.
        RelDataType rowType = new DrillFixedRelDataTypeImpl(planner.getTypeFactory(), tblFiledNames);

        relQuery = RelOptUtil.createCastRel(relQuery, rowType, true);
      }

      SchemaPlus schema = findSchema(context.getRootSchema(), context.getNewDefaultSchema(),
View Full Code Here

TOP

Related Classes of org.eigenbase.reltype.RelDataType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.