Package com.alibaba.wasp.plan.parser

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


      // This is a Delete SQL
      getDeletePlan(context, (SQLDeleteStatement) stmt, metaEventOperation);
    }

    else {
      throw new UnsupportedException("Unsupported SQLStatement " + stmt);
    }
  }
View Full Code Here


      // For MySQL, INSERT statements that use VALUES syntax can insert multiple
      // rows. see http://dev.mysql.com/doc/refman/5.5/en/insert.html
      List<ValuesClause> valuesList = ((WaspSqlInsertStatement) sqlInsertStatement)
          .getValuesList();
      if (valuesList.size() > 1) {
        throw new UnsupportedException("Insert multi value unsupported now");
      }
      LOG.debug("INSERT SQL Insert Values List " + valuesList);
      for (ValuesClause values : valuesList) {
        actions.add(genInsertAction(metaEventOperation, table, insertColumns,
            values));
View Full Code Here

    LOG.debug("UPDATE SQL where " + where);
    LinkedHashMap<String, Condition> eqConditions = new LinkedHashMap<String, Condition>();
    LinkedHashMap<String, Condition> ranges = new LinkedHashMap<String, Condition>();
    ParserUtils.parse(where, eqConditions, ranges);
    if (ranges.size() > 0) {
      throw new UnsupportedException("RANGE is not supported!");
    }

    // check if table has this columns
    metaEventOperation.checkAndGetFields(table, eqConditions.keySet());
View Full Code Here

    LinkedHashMap<String, Condition> conditions = new LinkedHashMap<String, Condition>();
    LinkedHashMap<String, Condition> ranges = new LinkedHashMap<String, Condition>();
    ParserUtils.parse(where, conditions, ranges);
    if (ranges.size() > 0) {
      throw new UnsupportedException(
          "RANGE is not supported by update operation!");
    }

    Set<String> conditionColumns = ParserUtils.getColumns(conditions);
    // check if table has this columns
View Full Code Here

        context.getTsr());
    if (stmt instanceof SQLSelectStatement) {
      // This is a select SQL
      getSelectPlan(context, (SQLSelectStatement) stmt, metaEventOperation);
    } else {
      throw new UnsupportedException("Unsupported SQLStatement " + stmt);
    }
  }
View Full Code Here

        actionInfo.setType(QueryInfo.QueryType.AGGREGATE);
        actionInfo.setAggregateInfo(aggregateInfo);
        convertToQueryPlan(table, context, actionInfo, metaEventOperation);
      }
    } else if (sqlSelectQuery instanceof SQLUnionQuery) {
      throw new UnsupportedException("Union clause Unsupported");
    }
  }
View Full Code Here

    List<Pair<String, byte[]>> primaryKeyPairs = metaEventOperation
        .getPrimaryKeyPairList(table, queryInfo.getEqConditions(),
            queryInfo.getRangeConditions());

    if ((queryInfo.getEqConditions().size() + queryInfo.getRangeConditions().size()) == 0) {
      throw new UnsupportedException("Unsupported null condition.");
    }

    if (primaryKeyPairs == null || primaryKeyPairs.isEmpty()) {
      // conditions do not contain PK.
      queryInfo.setType(QueryInfo.QueryType.SCAN);
    } else {
      queryInfo.setType(QueryInfo.QueryType.GET);
      if (primaryKeyPairs.size() != conditionColumns.size()) {
        throw new UnsupportedException(
            "When you have specified the pk, you'd better not to specify additional filter conditions.");
      }
    }

    Action action = null;
    DQLPlan qp = null;

    Condition entityGroupKeyCondition = queryInfo.getField(table
        .getEntityGroupKey().getName());
    if (queryInfo.getType() == QueryInfo.QueryType.GET) {
      byte[] primaryKey = RowBuilder.build().genRowkey(primaryKeyPairs);
      // check if the column is table's primary key.
      action = new GetAction(context.getReadModel(), table.getTableName(),
          primaryKey, this.buildEntityColumnsForGet(table, metaEventOperation,
              selectItem));
      ((GetAction)action).setForUpdate(queryInfo.isForUpdate());
      if (context.isGenWholePlan()) {
        // get entityGroupLocation according to entity group key.
        EntityGroupLocation entityGroupLocation = this.connection
            .locateEntityGroup(Bytes.toBytes(table.getTableName()), DruidParser
                .convert(
                    table.getColumn(entityGroupKeyCondition.getFieldName()),
                    entityGroupKeyCondition.getValue()));
        action.setEntityGroupLocation(entityGroupLocation);
      }
      qp = new LocalQueryPlan((GetAction) action);
      LOG.debug(QueryInfo.QueryType.GET + "  "
          + Bytes.toStringBinary(primaryKey) + " from " + table.getTableName());
    } else if (queryInfo.getType() == QueryInfo.QueryType.SCAN) {
      Index index = metaEventOperation.checkAndGetIndex(table,
          queryInfo.getAllConditionFieldName());

      if (index == null) {
        throw new UnsupportedException("Don't get a Index!");
      }

      boolean isJustUseIndex = index.getIndexKeys().size() >= queryInfo.getAllConditionFieldName().size();
      Pair<byte[], byte[]> startKeyAndEndKey = metaEventOperation.getStartkeyAndEndkey(index, queryInfo);
View Full Code Here

          metaEventOperation);
    } else if (stmt instanceof SQLTruncateStatement) {
      // This is a TRUNCATE TABLE SQL
      getTruncatePlan(context, (SQLTruncateStatement) stmt, metaEventOperation);
    } else {
      throw new UnsupportedException("Unsupported SQLStatement " + SQLUtils.toSQLString(stmt));
    }
  }
View Full Code Here

    } else if (like != null) {
      showTables = new ShowTablesPlan(ShowTablesPlan.ShowTablesType.LIKE);
      String likePattern = parseString(like);
      showTables.setLikePattern(likePattern);
    } else if (where != null) {
      throw new UnsupportedException("Show tables where not Unsupported!");
    }
    context.setPlan(showTables);
    LOG.debug("ShowTablesPlan " + showTables.toString());
  }
View Full Code Here

        // ColumnFamily specify do not supported.
        if (newColumnDefinition instanceof WaspSqlColumnDefinition) {
          WaspSqlColumnDefinition waspSqlColumnDefinition =
              (WaspSqlColumnDefinition) newColumnDefinition;
          if (waspSqlColumnDefinition.getColumnFamily() != null) {
            throw new UnsupportedException("Alter Table, columnFamily specify do not supported.");
          }
        }
        if (newColumnDefinition.getDataType() != null) {
          field.setType(parse(newColumnDefinition.getDataType()));
        }
        String newColumnName = parseName(newColumnDefinition.getName());
        if (!oldColumnName.equals(newColumnName)) { // Change column name
          for (Field f : ftableColumns.values()) {
            if (f.getName().equalsIgnoreCase(newColumnName)) {
              throw new UnsupportedException(
                  "Unsupported. Rename one column to a column that already column "
                      + newColumnName);
            }
          }
          field.setName(newColumnName);
        }
      } else if (item instanceof MySqlAlterTableAddColumn) {
        // Alter Table Add Column
        MySqlAlterTableAddColumn addColumn = (MySqlAlterTableAddColumn) item;
        List<SQLColumnDefinition> columns = addColumn.getColumns();
        boolean first = addColumn.isFirst();
        SQLName afterColumn = addColumn.getAfterColumn();
        LinkedHashMap<String, Field> ftableColumns = newTable.getColumns();

        List<Field> addFields = convertColumnDefForAlterTable(columns);
        // check Duplicate column name
        metaEventOperation.areLegalTableColumns(ftableColumns.values(),
            addFields);
        // Do not support add ColumnFamily dynamic right now.
        metaEventOperation.checkColumnFamilyName(ftableColumns.values(), addFields);
        if (first) {
          this.addFieldByPosition(-1, addFields, ftableColumns, newTable);
        } else if (afterColumn != null) {
          int index = getIndex(parseName(afterColumn), ftableColumns);
          this.addFieldByPosition(index, addFields, ftableColumns, newTable);
        } else {
          int index = ftableColumns.size() - 1;
          this.addFieldByPosition(index, addFields, ftableColumns, newTable);
        }
      } else if (item instanceof SQLAlterTableDropColumnItem) {
        // Alter Table Drop Column
        SQLAlterTableDropColumnItem dropColumn = (SQLAlterTableDropColumnItem) item;
        SQLName columnName = dropColumn.getColumnName();
        String cname = parseName(columnName);
        // This column is not primary key
        metaEventOperation.checkFieldNotInPrimaryKeys(oldTable, cname);
        // Check column not in a index, if you want to drop the column you
        // should drop the index first
        metaEventOperation.checkColumnNotInIndex(oldTable, cname);

        LinkedHashMap<String, Field> ftableColumns = newTable.getColumns();
        Field field = ftableColumns.remove(cname);
        if (field == null) {
          throw new UnsupportedException("Unsupported Do not find this column "
              +  SQLUtils.toSQLString(((SQLAlterTableDropColumnItem) item).getColumnName()));
        }
        newTable.setColumns(ftableColumns);
      } else {
        throw new UnsupportedException(SQLUtils.toSQLString(item) + " SQLAlterTableItem Unsupported");
      }
    }

    AlterTablePlan alterTable = new AlterTablePlan(oldTable, newTable);
    context.setPlan(alterTable);
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.