private TapDataType getDatatypeFromExpression(Expression expression) { // TODO: could check constant types instead iof lazy string return new TapDataType("char", "*", null); }
/** * Find or create a TypePair for the specified data type. The current implementation * looks for exact matches in the dataTypes map and, if not found, it rechecks with * just the base datatype when the specified TapDataType has length is greater than * 1; the latter takes care of arrays of strings (char(n) or char(*)) and should work * for other arrays. * * @param tt * @return */ protected TypePair findTypePair(TapDataType tt) { TypePair dbt = dataTypes.get(tt); if (dbt == null && tt.arraysize != null) { // input may have a non-matching arraysize TapDataType tmp = new TapDataType(tt.getDatatype(), "*", tt.xtype); dbt = dataTypes.get(tmp); } if (dbt == null) { throw new UnsupportedOperationException("unexpected datatype: " + tt); } log.debug("findTypePair: " + tt + " -> " + dbt); return dbt; }
@Override public int hashCode() { return toString().hashCode(); }
protected VOTableField createVOTableField(TapSelectItem resultCol) { if (resultCol != null) { TapDataType tt = resultCol.getDatatype(); VOTableField newField = new VOTableField(resultCol.getName(),tt.getDatatype(), tt.arraysize); newField.xtype = tt.xtype; newField.description = resultCol.description; newField.id = resultCol.id; newField.utype = resultCol.utype; newField.ucd = resultCol.ucd; newField.unit = resultCol.unit; return newField; } return null; } }
String[] parts = tt.getDatatype().split(":"); Element eleDt = addChild(eleColumn, "dataType", tt.getDatatype()); if (eleDt != null) if (tt.arraysize != null && !tt.isVarSize()) // assume single digit eleDt.setAttribute("size", tt.arraysize);
if (!cd.getDatatype().equals(ncd.getDatatype())) { throw new UnsupportedOperationException("cannot change column type: " + cd.getColumnName() + " " + cd.getDatatype() + " -> " + ncd.getDatatype());
safeSetString(sb, ps, col++, column.ucd); safeSetString(sb, ps, col++, column.unit); safeSetString(sb, ps, col++, column.getDatatype().getDatatype()); safeSetString(sb, ps, col++, column.getDatatype().arraysize); safeSetString(sb, ps, col++, column.getDatatype().xtype);
throw new UnsupportedOperationException("invalid function: " + function.getName()); if ( TapDataType.FUNCTION_ARG.equals(functionDesc.getDatatype()) ) log.debug("vist(nested Function " + nestedFunction); FunctionDesc nestedFunctionDesc = TapSchemaUtil.findFunctionDesc(tapSchema, (Function) parameter); if ( TapDataType.FUNCTION_ARG.equals(nestedFunctionDesc.getDatatype()) )
public PostgresDataTypeMapper() { dataTypes.put(TapDataType.POINT, new TypePair("spoint", null)); dataTypes.put(TapDataType.CIRCLE, new TypePair("scircle", null)); dataTypes.put(TapDataType.POLYGON, new TypePair("spoly", null)); dataTypes.put(TapDataType.INTERVAL, new TypePair("polygon", null)); dataTypes.put(new TapDataType("char", "*", "uri"), new TypePair("CHAR", Types.CHAR)); dataTypes.put(new TapDataType("char", "36", "uuid"), new TypePair("uuid", null)); dataTypes.put(new TapDataType("char", "*", "adql:POINT"), new TypePair("spoint", null)); dataTypes.put(new TapDataType("char", "*", "adql:REGION"), new TypePair("spoly", null)); }
/** * Create a VOTableField from a ColumnDesc. * * @param column * @return The associated VOTableField */ public static VOTableField convert(ColumnDesc column) { VOTableField vtf = new VOTableField( column.getColumnName(), column.getDatatype().getDatatype(), column.getDatatype().arraysize); vtf.xtype = column.getDatatype().xtype; return vtf; }
public Object mapRow(ResultSet rs, int rowNum) throws SQLException { String tn = rs.getString("table_name"); String cn = rs.getString("column_name"); String dt = rs.getString("datatype"); String as = rs.getString("arraysize"); String xt = rs.getString("xtype"); log.debug("ColumnMapper: " + tn + "," + cn + "," + dt + "," + as + "," + xt); TapDataType datatype = new TapDataType(dt, as, xt); ColumnDesc col = new ColumnDesc(tn, cn, datatype); col.description = rs.getString("description"); col.utype = rs.getString("utype"); col.ucd = rs.getString("ucd"); col.unit = rs.getString("unit"); col.principal = intToBoolean(rs.getInt("principal")); col.indexed = intToBoolean(rs.getInt("indexed")); col.std = intToBoolean(rs.getInt("std")); col.id = rs.getString("id"); return col; }
String datatype = tt.getDatatype();
functionDescs.add(new FunctionDesc("COORD1", TapDataType.DOUBLE, "deg")); functionDescs.add(new FunctionDesc("COORD2", TapDataType.DOUBLE, "deg")); functionDescs.add(new FunctionDesc("COORDSYS", new TapDataType("char", "16*", null))); functionDescs.add(new FunctionDesc("DISTANCE", TapDataType.DOUBLE, "deg")); functionDescs.add(new FunctionDesc("INTERSECTS", TapDataType.INTEGER)); functionDescs.add(new FunctionDesc("COUNT", new TapDataType("long", null, null))); functionDescs.add(new FunctionDesc("MAX", TapDataType.FUNCTION_ARG)); functionDescs.add(new FunctionDesc("MIN", TapDataType.FUNCTION_ARG)); functionDescs.add(new FunctionDesc("LOWER", new TapDataType("char", "*", null))); functionDescs.add(new FunctionDesc("SUBSTRING", new TapDataType("char", "*", null))); functionDescs.add(new FunctionDesc("UPPER", new TapDataType("char", "*", null)));
/** * Convert a VOTable field into tap_schema column descriptor. * * @param tableName * @param field * @return */ public static ColumnDesc convert(String tableName, VOTableField field) { TapDataType dt = new TapDataType(field.getDatatype(), field.getArraysize(), field.xtype); ColumnDesc ret = new ColumnDesc(tableName, field.getName(), dt); ret.description = field.description; ret.id = field.id; ret.ucd = field.ucd; ret.unit = field.unit; ret.utype = field.utype; ret.indexed = false; ret.principal = false; ret.std = false; return ret; }
TapDataType tt = new TapDataType(dtv, arraysize, xtype); ColumnDesc cd = new ColumnDesc(tn, cn, tt); cd.description = ce.getChildTextTrim("description");