Class TablePlanRead

All Implemented Interfaces:
TablePlan

public class TablePlanRead extends TablePlanCommon<TablePlanRead>
Reads rows into a TableColumnar.

Example:


 DataResource streamSource = DataResources.fromString("Code,Amount\nabc,10.5\n", "values.csv");
 ReadOptionsCsv options = ReadOptionsCsv.builder().withSeparator(',').build();
 RowSource rowSource = RowSources.create(options, streamSource);

 TableColumnar table = new TablePlanRead().withTableName(TableName.of("Trades")).execute(rowSource);
 

There are two useful layers for column typing when reading:

- source-side types from RowCursor.columns() choose the low-level builder before rows are consumed and are therefore the best place to avoid intermediate string materialisation when that direct parser is genuinely worthwhile

- plan-side types configured on this class describe the desired output type and can override the source-side type when appropriate

  • Constructor Details

    • TablePlanRead

      public TablePlanRead()
  • Method Details

    • withIncludeResourceName

      public TablePlanRead withIncludeResourceName(ColumnName resourceName)
    • getResourceName

      public ColumnName getResourceName()
    • withLocalDateFormat

      public TablePlanRead withLocalDateFormat(DateFormat localDateFormat)
    • getLocalDateFormat

      public DateFormat getLocalDateFormat()
    • withTransform

      public TablePlanRead withTransform(Transform transform)
    • withTransforms

      public TablePlanRead withTransforms(Transform... transforms)
    • getTransforms

      public List<Transform> getTransforms()
    • withHeaderStrategy

      public TablePlanRead withHeaderStrategy(HeaderStrategy headerStrategy)
    • getHeaderStrategy

      public HeaderStrategy getHeaderStrategy()
    • withSelectedColumn

      public TablePlanRead withSelectedColumn(ColumnName columnName)
    • withSelectedColumns

      public TablePlanRead withSelectedColumns(ColumnName... columnNames)
    • withSelectedColumns

      public TablePlanRead withSelectedColumns(Collection<ColumnName> columnNames)
    • withSelectedColumns

      public TablePlanRead withSelectedColumns(Iterable<ColumnName> columnNames)
    • getSelectedColumns

      public Set<ColumnName> getSelectedColumns()
    • withColumnRename

      public TablePlanRead withColumnRename(ColumnName original, ColumnName newName)
    • withColumnRenames

      public TablePlanRead withColumnRenames(Map<ColumnName,ColumnName> renames)
    • getColumnRenames

      public Map<ColumnName,ColumnName> getColumnRenames()
    • withRowFilter

      public TablePlanRead withRowFilter(RowFilter rowFilter)
    • getRowFilter

      public RowFilter getRowFilter()
    • withStripping

      public TablePlanRead withStripping(boolean stripping)
    • isStripping

      public boolean isStripping()
    • withColumnType

      public TablePlanRead withColumnType(ColumnName columnName, Column.Type columnType)
      Specifies the desired output type for a column in the resulting table.

      This is best thought of as plan-side type intent. If the source cursor also exposes a type for the same column, that source-side type can still matter earlier because it may choose the low-level builder before rows are read.

      In other words:

      - source-side types are the right place to request direct builder parsing and bypass intermediate strings when the parser has a real advantage

      - plan-side types are the right place to describe the desired result schema or override the source metadata

      Parameters:
      columnName - the output column name
      columnType - the desired output type
      Returns:
      this plan
    • withColumnTypes

      public TablePlanRead withColumnTypes(Column.Type columnType, ColumnName... columnNames)
    • getColumnType

      public Column.Type getColumnType(ColumnName columnName)
    • getColumnTypes

      public Map<ColumnName,Column.Type> getColumnTypes()
    • execute

      public TableColumnar execute(TableName tableName, Column... columns)
    • execute

      public TableColumnar execute(TableName tableName, TableDescription tableDescription, Column... columns)
    • execute

      public TableColumnar execute(TableColumnar table)
    • execute

      public TableColumnar execute(RowCursor rowCursor)
      Description copied from interface: TablePlan
      Executes this plan against an already-open row supplier.

      Use this lower-level entry point when the caller already owns the live source resource and wants to control its lifetime explicitly.

      For CSV, open the input stream, create a RowCursor, then pass that cursor to this method inside the caller's resource scope. For JDBC, execute the prepared statement, wrap the live ResultSet in a row cursor, and pass it to this method before closing the JDBC resources.

      Parameters:
      rowCursor - open row supplier to consume
      Returns:
      the resulting table
    • execute

      public TableColumnar execute(DataResource streamSource)
      Reads the supplied stream source as CSV using ReadOptionsCsv.standard() defaults.
      Parameters:
      streamSource - the CSV stream source
      Returns:
      the parsed table
    • execute

      public TableColumnar execute(RowSource rowSource)
      Description copied from interface: TablePlan
      Executes this plan against a configured row source.

      This is the simplest high-level entry point when the source should handle opening and closing its own row supplier internally.

      For CSV or JDBC, build an appropriate RowSource and pass it to this method. The row source owns the open/close lifecycle for each execution.

      Parameters:
      rowSource - configured source that opens rows for this execution
      Returns:
      the resulting table
    • self

      protected TablePlanRead self()
      Specified by:
      self in class TablePlanCommon<TablePlanRead>