Exemplo n.º 1
0
 private RelDataType sqlType(
     RelDataTypeFactory typeFactory, int dataType, int precision, int scale, String typeString) {
   SqlTypeName sqlTypeName = SqlTypeName.getNameForJdbcType(dataType);
   switch (sqlTypeName) {
     case ARRAY:
       RelDataType component = null;
       if (typeString != null && typeString.endsWith(" ARRAY")) {
         // E.g. hsqldb gives "INTEGER ARRAY", so we deduce the component type
         // "INTEGER".
         final String remaining = typeString.substring(0, typeString.length() - " ARRAY".length());
         component = parseTypeString(typeFactory, remaining);
       }
       if (component == null) {
         component = typeFactory.createSqlType(SqlTypeName.ANY);
       }
       return typeFactory.createArrayType(component, -1);
   }
   if (precision >= 0 && scale >= 0 && sqlTypeName.allowsPrecScale(true, true)) {
     return typeFactory.createSqlType(sqlTypeName, precision, scale);
   } else if (precision >= 0 && sqlTypeName.allowsPrecNoScale()) {
     return typeFactory.createSqlType(sqlTypeName, precision);
   } else {
     assert sqlTypeName.allowsNoPrecNoScale();
     return typeFactory.createSqlType(sqlTypeName);
   }
 }