コード例 #1
0
 private List<ColumnGetter> newColumnGetters(
     PluginTask task, JdbcSchema querySchema, PageBuilder pageBuilder) throws SQLException {
   ColumnGetterFactory factory = newColumnGetterFactory(pageBuilder, task.getDefaultTimeZone());
   ImmutableList.Builder<ColumnGetter> getters = ImmutableList.builder();
   for (JdbcColumn c : querySchema.getColumns()) {
     JdbcColumnOption columnOption = columnOptionOf(task.getColumnOptions(), c);
     getters.add(factory.newColumnGetter(c, columnOption));
   }
   return getters.build();
 }
コード例 #2
0
  private Schema setupTask(JdbcInputConnection con, PluginTask task) throws SQLException {
    // build SELECT query and gets schema of its result
    String query = getQuery(task, con);
    logger.info("SQL: " + query);
    JdbcSchema querySchema = con.getSchemaOfQuery(query);
    task.setQuerySchema(querySchema);

    // validate column_options
    newColumnGetters(task, querySchema, null);

    ColumnGetterFactory factory = newColumnGetterFactory(null, task.getDefaultTimeZone());
    ImmutableList.Builder<Column> columns = ImmutableList.builder();
    for (int i = 0; i < querySchema.getCount(); i++) {
      JdbcColumn column = querySchema.getColumn(i);
      JdbcColumnOption columnOption = columnOptionOf(task.getColumnOptions(), column);
      columns.add(
          new Column(
              i, column.getName(), factory.newColumnGetter(column, columnOption).getToType()));
    }
    return new Schema(columns.build());
  }