Package org.apache.tajo.catalog

Examples of org.apache.tajo.catalog.Schema


  public static Schema targetToSchema(Collection<Target> targets) {
    return targetToSchema(targets.toArray(new Target[targets.size()]));
  }

  public static Schema targetToSchema(Target[] targets) {
    Schema schema = new Schema();
    for (Target t : targets) {
      DataType type = t.getEvalTree().getValueType();
      String name;
      if (t.hasAlias()) {
        name = t.getAlias();
      } else {
        name = t.getEvalTree().getName();
      }
      if (!schema.containsByQualifiedName(name)) {
        schema.addColumn(name, type);
      }
    }

    return schema;
  }
View Full Code Here


    String databaseName = CatalogUtil.extractQualifier(this.tableDesc.getName());
    String qualifiedAlias = CatalogUtil.buildFQName(databaseName, alias);
    this.setInSchema(tableDesc.getSchema());
    this.getInSchema().setQualifier(qualifiedAlias);
    this.setOutSchema(new Schema(getInSchema()));
    logicalSchema = SchemaUtil.getQualifiedLogicalSchema(tableDesc, qualifiedAlias);
  }
View Full Code Here

    this.srcId = new ExecutionBlockId(proto.getSrcId());
    this.targetId = new ExecutionBlockId(proto.getTargetId());
    this.transmitType = proto.getTransmitType();
    this.shuffleType = proto.getShuffleType();
    if (proto.hasSchema()) {
      this.setSchema(new Schema(proto.getSchema()));
    }
    if (proto.getShuffleKeysCount() > 0) {
      shuffleKeys = new Column[proto.getShuffleKeysCount()];
      for (int i = 0; i < proto.getShuffleKeysCount(); i++) {
        shuffleKeys[i] = new Column(proto.getShuffleKeys(i));
View Full Code Here

          relationOp.getCanonicalName(),
          CatalogUtil.extractSimpleName(canonicalName));
      canonicalName = changedName;
    }

    Schema schema = relationOp.getTableSchema();
    Column column = schema.getColumn(canonicalName);
    if (column == null) {
      throw new NoSuchColumnException(canonicalName);
    }

    // If code reach here, a column is found.
    // But, it may be aliased from bottom logical node.
    // If the column is aliased, the found name may not be used in upper node.

    // Here, we try to check if column reference is already aliased.
    // If so, it replaces the name with aliased name.
    LogicalNode currentNode = block.getCurrentNode();

    // The condition (currentNode.getInSchema().contains(column)) means
    // the column can be used at the current node. So, we don't need to find aliase name.
    Schema currentNodeSchema = null;
    if (currentNode != null) {
      if (currentNode instanceof RelationNode) {
        currentNodeSchema = ((RelationNode) currentNode).getTableSchema();
      } else {
        currentNodeSchema = currentNode.getInSchema();
      }
    }

    if (currentNode != null && !currentNodeSchema.contains(column)
        && currentNode.getType() != NodeType.TABLE_SUBQUERY) {
      List<Column> candidates = TUtil.newList();
      if (block.namedExprsMgr.isAliased(qualifiedName)) {
        String alias = block.namedExprsMgr.getAlias(canonicalName);
        Column found = resolveColumn(block, new ColumnReferenceExpr(alias));
View Full Code Here

    stack.push(node);
    LogicalNode left = visit(newContext, plan, block, node.getLeftChild(), stack);
    LogicalNode right = visit(newContext, plan, block, node.getRightChild(), stack);
    stack.pop();

    Schema merged = SchemaUtil.merge(left.getOutSchema(), right.getOutSchema());

    node.setInSchema(merged);

    if (node.hasJoinQual()) {
      Target target = context.targetListMgr.getTarget(joinQualReference);
View Full Code Here

  private Path [] findFilteredPartitionPaths(ScanNode scanNode) throws IOException {
    TableDesc table = scanNode.getTableDesc();
    PartitionMethodDesc partitionDesc = scanNode.getTableDesc().getPartitionMethod();

    Schema paritionValuesSchema = new Schema();
    for (Column column : partitionDesc.getExpressionSchema().getColumns()) {
      paritionValuesSchema.addColumn(column);
    }

    Set<EvalNode> indexablePredicateSet = Sets.newHashSet();

    // if a query statement has a search condition, try to find indexable predicates
    if (scanNode.hasQual()) {
      EvalNode [] conjunctiveForms = AlgebraicUtil.toConjunctiveNormalFormArray(scanNode.getQual());
      Set<EvalNode> remainExprs = Sets.newHashSet(conjunctiveForms);

      // add qualifier to schema for qual
      paritionValuesSchema.setQualifier(scanNode.getCanonicalName());
      for (Column column : paritionValuesSchema.getColumns()) {
        for (EvalNode simpleExpr : conjunctiveForms) {
          if (checkIfIndexablePredicateOnTargetColumn(simpleExpr, column)) {
            indexablePredicateSet.add(simpleExpr);
          }
        }
View Full Code Here

import org.apache.tajo.catalog.Schema;
import org.apache.tajo.catalog.TableDesc;

public class SchemaUtil {
  public static Schema merge(Schema left, Schema right) {
    Schema merged = new Schema();
    for(Column col : left.getColumns()) {
      if (!merged.containsByQualifiedName(col.getQualifiedName())) {
        merged.addColumn(col);
      }
    }
    for(Column col : right.getColumns()) {
      if (!merged.containsByQualifiedName(col.getQualifiedName())) {
        merged.addColumn(col);
      }
    }
   
    return merged;
  }
View Full Code Here

  /**
   * Get common columns to be used as join keys of natural joins.
   */
  public static Schema getNaturalJoinColumns(Schema left, Schema right) {
    Schema common = new Schema();
    for (Column outer : left.getColumns()) {
      if (!common.containsByName(outer.getSimpleName()) && right.containsByName(outer.getSimpleName())) {
        common.addColumn(new Column(outer.getSimpleName(), outer.getDataType()));
      }
    }
   
    return common;
  }
View Full Code Here

   
    return common;
  }

  public static Schema getQualifiedLogicalSchema(TableDesc tableDesc, String tableName) {
    Schema logicalSchema = new Schema(tableDesc.getLogicalSchema());
    if (tableName != null) {
      logicalSchema.setQualifier(tableName);
    }
    return logicalSchema;
  }
View Full Code Here

  public static void setup() throws Exception {
    util = TpchTestBase.getInstance().getTestingCluster();
    conf = util.getConfiguration();
    sm = StorageManagerFactory.getStorageManager(conf);

    scoreSchema = new Schema();
    scoreSchema.addColumn("deptname", Type.TEXT);
    scoreSchema.addColumn("score", Type.INT4);
    scoreMeta = CatalogUtil.newTableMeta(StoreType.CSV);
    TableStats stats = new TableStats();
View Full Code Here

TOP

Related Classes of org.apache.tajo.catalog.Schema

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.