Esempio n. 1
0
 public int getFieldJdbcType(int fieldOrdinal) {
   RelDataType type = getFieldNamedType(fieldOrdinal);
   SqlTypeName typeName = type.getSqlTypeName();
   if (typeName == null) {
     return Types.OTHER;
   }
   return typeName.getJdbcOrdinal();
 }
Esempio n. 2
0
 public RelDataType getFieldType(int fieldOrdinal) {
   RelDataType namedType = getFieldNamedType(fieldOrdinal);
   if (namedType.getSqlTypeName() == SqlTypeName.DISTINCT) {
     // for most metadata calls, report information about the
     // predefined type on which the distinct type is based
     return namedType.getFields()[0].getType();
   } else {
     return namedType;
   }
 }
Esempio n. 3
0
 public int getFieldScale(int fieldOrdinal) {
   RelDataType type = getFieldType(fieldOrdinal);
   SqlTypeName typeName = type.getSqlTypeName();
   if (typeName == null) {
     return 0;
   }
   if (typeName.allowsPrecScale(true, true)) {
     return type.getScale();
   } else {
     return 0;
   }
 }
Esempio n. 4
0
 public String getFieldTypeName(int fieldOrdinal) {
   RelDataType type = getFieldNamedType(fieldOrdinal);
   SqlTypeName typeName = type.getSqlTypeName();
   if (typeName == null) {
     return type.toString();
   }
   switch (typeName) {
     case STRUCTURED:
     case DISTINCT:
       return type.getSqlIdentifier().toString();
     case INTERVAL_DAY_TIME:
     case INTERVAL_YEAR_MONTH:
       return type.toString();
   }
   return typeName.name();
 }
Esempio n. 5
0
 /**
  * Creates a FarragoJdbcMetaDataImpl.
  *
  * @param rowType Type info to return
  * @param fieldOrigins Origin of each field in column of catalog object
  */
 protected FarragoJdbcMetaDataImpl(RelDataType rowType, List<List<String>> fieldOrigins) {
   this.rowType = rowType;
   this.fieldOrigins = fieldOrigins;
   assert rowType != null;
   assert fieldOrigins != null;
   assert fieldOrigins.size() == rowType.getFieldCount()
       : "field origins " + fieldOrigins + " have different count than row type " + rowType;
 }
Esempio n. 6
0
 public int getFieldCount() {
   return rowType.getFieldCount();
 }
Esempio n. 7
0
 public String getFieldName(int fieldOrdinal) {
   return rowType.getFields()[fieldOrdinal - 1].getName();
 }
Esempio n. 8
0
 public RelDataType getFieldNamedType(int fieldOrdinal) {
   return rowType.getFields()[fieldOrdinal - 1].getType();
 }
Esempio n. 9
0
 public boolean isFieldSearchable(int fieldOrdinal) {
   RelDataType type = getFieldType(fieldOrdinal);
   return RelDataTypeComparability.None != type.getComparability();
 }
Esempio n. 10
0
 public int isFieldNullable(int fieldOrdinal) {
   RelDataType type = getFieldType(fieldOrdinal);
   return type.isNullable() ? ResultSetMetaData.columnNullable : ResultSetMetaData.columnNoNulls;
 }
Esempio n. 11
0
 public int getFieldPrecision(int fieldOrdinal) {
   RelDataType type = getFieldType(fieldOrdinal);
   return type.getPrecision();
 }
  // implement FarragoMedDataServer
  public FarragoMedColumnSet newColumnSet(
      String[] localName,
      Properties tableProps,
      FarragoTypeFactory typeFactory,
      RelDataType rowType,
      Map<String, Properties> columnPropMap)
      throws SQLException {
    if (rowType == null) {
      rowType = createMockRowType(typeFactory);
    }

    assert (rowType.getFieldList().size() == 1);
    RelDataType type = rowType.getFields()[0].getType();
    assert (!type.isNullable());
    assert (typeFactory.getClassForPrimitive(type) != null);

    // TODO jvs 5-Aug-2005:  clean up usage of server properties
    // as defaults

    long nRows = -1;
    String rowCountSql = tableProps.getProperty(PROP_ROW_COUNT_SQL);
    if (rowCountSql != null) {
      // Attempt to issue a loopback query into Farrago to
      // get the number of rows to produce.
      DataSource loopbackDataSource = getLoopbackDataSource();
      Connection connection = null;
      if (loopbackDataSource != null) {
        try {
          connection = loopbackDataSource.getConnection();
          Statement stmt = connection.createStatement();
          ResultSet resultSet = stmt.executeQuery(rowCountSql);
          if (resultSet.next()) {
            nRows = resultSet.getLong(1);
          }
        } finally {
          // It's OK not to clean up stmt and resultSet;
          // connection.close() will do that for us.
          if (connection != null) {
            connection.close();
          }
        }
      }
    }

    if (nRows == -1) {
      nRows =
          getLongProperty(
              tableProps, PROP_ROW_COUNT, getLongProperty(getProperties(), PROP_ROW_COUNT, 10));
    }

    String executorImpl =
        tableProps.getProperty(
            PROP_EXECUTOR_IMPL, getProperties().getProperty(PROP_EXECUTOR_IMPL, PROPVAL_JAVA));
    assert (executorImpl.equals(PROPVAL_JAVA) || executorImpl.equals(PROPVAL_FENNEL));

    String udxSpecificName = tableProps.getProperty(PROP_UDX_SPECIFIC_NAME);

    if (udxSpecificName != null) {
      assert (executorImpl.equals(PROPVAL_JAVA));
    }

    checkNameMatch(getForeignSchemaName(), tableProps.getProperty(PROP_SCHEMA_NAME));

    checkNameMatch(getForeignTableName(), tableProps.getProperty(PROP_TABLE_NAME));

    return new MedMockColumnSet(this, localName, rowType, nRows, executorImpl, udxSpecificName);
  }