private TapDataType getDatatypeFromExpression(Expression expression) { // TODO: could check constant types instead iof lazy string return new TapDataType("char", "*", null); }
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)); }
/** * 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; }
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; }
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");