Example #1
0
  public void deParse(Update update) {
    buffer
        .append("UPDATE ")
        .append(PlainSelect.getStringList(update.getTables(), true, false))
        .append(" SET ");
    for (int i = 0; i < update.getColumns().size(); i++) {
      Column column = update.getColumns().get(i);
      buffer.append(column.getFullyQualifiedName()).append(" = ");

      Expression expression = update.getExpressions().get(i);
      expression.accept(expressionVisitor);
      if (i < update.getColumns().size() - 1) {
        buffer.append(", ");
      }
    }

    if (update.getFromItem() != null) {
      buffer.append(" FROM ").append(update.getFromItem());
      if (update.getJoins() != null) {
        for (Join join : update.getJoins()) {
          if (join.isSimple()) {
            buffer.append(", ").append(join);
          } else {
            buffer.append(" ").append(join);
          }
        }
      }
    }

    if (update.getWhere() != null) {
      buffer.append(" WHERE ");
      update.getWhere().accept(expressionVisitor);
    }
  }
 public Datum[] convertType(String[] singleTableElement) {
   // Map tupleKeyValueMap = new HashMap();
   String key = null, value = null, type = null;
   Column col = null;
   Datum[] t = new Datum[singleTableElement.length];
   int i = 0;
   int j = 0;
   while (tableMap.size() != j
       && !tableMap
           .get(j)
           .getTable()
           .toString()
           .equalsIgnoreCase(tableName.getName().toString())) {
     j++;
   }
   while (i < singleTableElement.length) {
     col = tableMap.get(j);
     value = singleTableElement[i];
     type = tableColTypeMap.get(tableName.getName().toString().toLowerCase()).get(i).toLowerCase();
     if (type.equalsIgnoreCase("int")) {
       // tupleKeyValueMap.put(key, Integer.parseInt(value));
       t[i] = new Datum.dLong(singleTableElement[i], new Column(tableName, col.getColumnName()));
       // System.out.print(t[i].toComString());
     } else if (type.equalsIgnoreCase("decimal")) {
       // tupleKeyValueMap.put(key, Integer.parseInt(value));
       t[i] =
           new Datum.dDecimal(singleTableElement[i], new Column(tableName, col.getColumnName()));
       // System.out.print(t[i].toComString());
     } else if (type.equalsIgnoreCase("String")
         || type.startsWith("char")
         || type.startsWith("varchar")) {
       // tupleKeyValueMap.put(key, value);
       t[i] = new Datum.dString(singleTableElement[i], new Column(tableName, col.getColumnName()));
       // System.out.print(t[i].toComString());
     } else if (type.equalsIgnoreCase("date")) {
       // tupleKeyValueMap.put(key, (new SimpleDateFormat(
       // "YYYY-MM-DD", Locale.ENGLISH).parse(value)));
       t[i] = new Datum.dDate(singleTableElement[i], new Column(tableName, col.getColumnName()));
       // System.out.print(t[i].toComString());
     } else {
       try {
         throw new Exception("Not aware of this data type :: " + type);
       } catch (Exception e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
       }
     }
     i++;
     j++;
   }
   return t;
 }
Example #3
0
  @Override
  public void visit(Column column) {
    // extract type for the column
    String tableSchemaName = _tan.getSchemaName(ParserUtil.getComponentName(column.getTable()));
    String columnName = column.getColumnName();
    TypeConversion tc = _schema.getType(tableSchemaName, columnName);

    // extract the position (index) of the required column
    int position =
        HierarchyExtractor.extractComponentIndex(
            column, _affectedComponent, _queryPlan, _schema, _tan);

    ValueExpression ve = new ColumnReference(tc, position);
    _exprStack.push(ve);
  }
Example #4
0
 @Override
 public void visit(Column column) {
   Table affectedTable = column.getTable();
   if (_sideTable == null) {
     _sideTable = affectedTable;
   } else {
     if (!ParserUtil.equals(_sideTable, affectedTable)) {
       throw new RuntimeException(
           "Multiple tables on one side of a join condition is not supported yet!");
     }
   }
 }
Example #5
0
 public void visit(Column tableColumn) throws Exception {
   if (tableColumn.getTable() != null) {
     tableColumn.getTable().accept(this);
   }
 }
 @Override
 public void visit(Column column) {
   columnName = StringUtils.strip(column.getColumnName(), "`").toUpperCase();
 }