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; }
@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); }
@Override public void visit(Column column) { columnName = StringUtils.strip(column.getColumnName(), "`").toUpperCase(); }