Package com.alibaba.wasp.plan.parser

Examples of com.alibaba.wasp.plan.parser.UnsupportedException


            .next().getValue());
    SQLExpr entityGroupKeySQLExpr = waspSqlCreateTableStatement
        .getEntityGroupKey();
    Field entityGroupKey = primaryKeys.get(parseName(entityGroupKeySQLExpr));
    if (entityGroupKey == null) {
      throw new UnsupportedException(entityGroupKeySQLExpr
          + " is ForeignKey, but don't in primaryKeys.");
    }
    table.setEntityGroupKey(entityGroupKey);

    if (tableType == FTable.TableType.CHILD) {
      String parentName = parseFromClause(waspSqlCreateTableStatement
          .getInTableName());
      table.setParentName(parentName);
      if (!parentName.equals(parseFromClause(waspSqlCreateTableStatement
          .getReferenceTable()))) {
        throw new UnsupportedException(" in table "
            + waspSqlCreateTableStatement.getInTableName()
            + " != references table "
            + waspSqlCreateTableStatement.getReferenceTable());
      }

      // Check parent's EGK equals child's EGK.
      TableSchemaCacheReader reader = TableSchemaCacheReader
          .getInstance(configuration);
      FTable parentTable = reader.getSchema(parentName);
      if (parentTable == null) {
        parentTable = TableSchemaCacheReader.getService(reader.getConf())
            .getTable(tableName);
      }
      if (parentTable == null) {
        throw new TableNotFoundException("Not found parent table:" + parentName);
      }

      if (!parentTable.getEntityGroupKey().getName()
          .equals(table.getEntityGroupKey().getName())) {
        throw new UnsupportedException("Parent" + parentName
            + "'s egk doesn't equals Child" + tableName + "'s egk.");
      }

      // Check child's PKS contains parent's PKS.
      for (Field parentPrimaryKey : parentTable.getPrimaryKeys().values()) {
        boolean found = table.getPrimaryKeys().containsKey(
            parentPrimaryKey.getName());
        if (!found) {
          throw new UnsupportedException(
              "Child's pks must contains parent's pks.");
        }
      }
    }

    SQLPartitioningClause partitioning = waspSqlCreateTableStatement
        .getPartitioning();
    byte[][] splitKeys = null;
    if (partitioning != null) {
      if (table.isRootTable()) {
        if (partitioning instanceof WaspSqlPartitionByKey) {
          WaspSqlPartitionByKey partitionKey = (WaspSqlPartitionByKey) partitioning;
          byte[] start = convert(null, partitionKey.getStart());
          byte[] end = convert(null, partitionKey.getEnd());
          int partitionCount = convertToInt(partitionKey.getPartitionCount());
          splitKeys = Bytes.split(start, end, partitionCount - 3);
        } else {
          throw new UnsupportedException("Unsupported SQLPartitioningClause "
              + partitioning);
        }
      } else {
        throw new UnsupportedException(
            "Partition by only supported for Root Table");
      }
    }
    CreateTablePlan createTable = new CreateTablePlan(table, splitKeys);
    context.setPlan(createTable);
View Full Code Here


        particularColumns.size());
    for (SQLExpr expr : particularColumns) {
      String name = parseName(expr);
      Field field = columns.get(name);
      if (field == null) {
        throw new UnsupportedException(
            "Unsupported table don't have this primaryKey " + expr);
      }
      particularFields.put(name, field);
    }
    return particularFields;
View Full Code Here

      } else if (column.getColumnConstraint() == FieldKeyWord.OPTIONAL) {
        keyWord = FieldKeyWord.OPTIONAL;
      } else if (column.getColumnConstraint() == FieldKeyWord.REPEATED) {
        keyWord = FieldKeyWord.REPEATED;
      } else {
        throw new UnsupportedException("Unsupported ColumnConstraint "
            + column.getColumnConstraint());
      }
      SQLName name = column.getName();
      SQLDataType dataType = column.getDataType();
      SQLName columnFamilyName = column.getColumnFamily();
      String columnFamily = FConstants.COLUMNFAMILYNAME_STR;
      if (columnFamilyName != null) {
        columnFamily = parseName(columnFamilyName);
      }
      field = new Field(keyWord, columnFamily, parseName(name),
          parse(dataType), column.getComment());
      return field;
    } else {
      throw new UnsupportedException("Unsupported SQLColumnDefinition "
          + tableElement);
    }
  }
View Full Code Here

    LinkedHashSet<String> columns = new LinkedHashSet<String>(items.size());
    List<String> desc = new ArrayList<String>();
    for (SQLSelectOrderByItem item : items) {
      String columnName = parseName(item.getExpr());
      if (columns.contains(columnName)) {
        throw new UnsupportedException("Index have two same field '" + columnName + "'");
      } else {
        columns.add(columnName);
      }
      if (item.getType() == SQLOrderingSpecification.DESC) {
        desc.add(columnName);
      }
    }

    if (!metaEventOperation.isLegalDescFields(fTable, desc)) {
      throw new UnsupportedException(
          "Currently we only support the ascending and descending time field.");
    }

    List<String> colList = new ArrayList<String>();
    colList.addAll(columns);
    if (metaEventOperation.arePrimaryKeys(fTable, colList)) {
      throw new UnsupportedException("Index keys is Primary Keys.");
    }
    if (metaEventOperation.containPrimaryKeys(fTable, colList)) {
      throw new UnsupportedException("Index keys contain all Primary Keys.");
    }

    LinkedHashMap<String, Field> indexKeys = metaEventOperation
        .checkAndGetFields(fTable, columns);
    // Check the indexKeys whether have Duplicate column name
View Full Code Here

      if (field.getName().equals(name)) {
        return i;
      }
      i++;
    }
    throw new UnsupportedException(name + " is not in set");
  }
View Full Code Here

    } else if (typeName.equalsIgnoreCase("PROTOBUF")) {
      return DataType.PROTOBUF;
    } else if (typeName.equalsIgnoreCase("DATETIME")) {
      return DataType.DATETIME;
    } else {
      throw new UnsupportedException("Unsupported SQLDataType " + dataType);
    }
  }
View Full Code Here

    LinkedHashMap<String, Field> foundColumns = new LinkedHashMap<String, Field>(
        fields.size());
    for (String field : fields) {
      Field foundColumn = table.getColumn(field);
      if (foundColumn == null) {
        throw new UnsupportedException(table.getTableName() + " does not have column '"
            + field + "'!");
      }
      foundColumns.put(foundColumn.getName(), foundColumn);
    }
    return foundColumns;
View Full Code Here

    LinkedHashMap<String, Field> primaryKeys = table.getPrimaryKeys();
    if (primaryKeys.size() == 1
        && primaryKeys.entrySet().iterator().next().getValue().getName()
            .equals(field)) {
    } else {
      throw new UnsupportedException(field + " is not Primary Key !");
    }
  }
View Full Code Here

  @Override
  public void checkIsPrimaryKey(FTable table, Set<String> fields)
      throws IOException {
    LinkedHashMap<String, Field> primaryKeys = table.getPrimaryKeys();
    if (primaryKeys.size() != fields.size()) {
      throw new UnsupportedException(fields + " is not Primary Key !");
    }

    for (String fieldName : fields) {
      boolean exists = false;
      if (primaryKeys.containsKey(fieldName)) {
        exists = true;
      }

      if (!exists) {
        throw new UnsupportedException("Does not have primary key '" + fieldName + "'!");
      }
    }
  }
View Full Code Here

   */
  @Override
  public void checkFieldExists(FTable table, String field) throws IOException {
    LinkedHashMap<String, Field> columns = table.getColumns();
    if (!inSet(columns, field)) {
      throw new UnsupportedException("Field '" + field + "' not exists!");
    }
  }
View Full Code Here

TOP

Related Classes of com.alibaba.wasp.plan.parser.UnsupportedException

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.