Class TablePlanRead
- All Implemented Interfaces:
TablePlan
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionexecute(DataResource streamSource) Reads the supplied stream source as CSV usingReadOptionsCsv.standard()defaults.Executes this plan against an already-open row supplier.Executes this plan against a configured row source.execute(TableColumnar table) execute(TableName tableName, TableDescription tableDescription, Column... columns) getColumnType(ColumnName columnName) booleanprotected TablePlanReadself()withColumnRename(ColumnName original, ColumnName newName) withColumnRenames(Map<ColumnName, ColumnName> renames) withColumnType(ColumnName columnName, Column.Type columnType) Specifies the desired output type for a column in the resulting table.withColumnTypes(Column.Type columnType, ColumnName... columnNames) withHeaderStrategy(HeaderStrategy headerStrategy) withIncludeResourceName(ColumnName resourceName) withLocalDateFormat(DateFormat localDateFormat) withRowFilter(RowFilter rowFilter) withSelectedColumn(ColumnName columnName) withSelectedColumns(ColumnName... columnNames) withSelectedColumns(Iterable<ColumnName> columnNames) withSelectedColumns(Collection<ColumnName> columnNames) withStripping(boolean stripping) withTransform(Transform transform) withTransforms(Transform... transforms) Methods inherited from class app.babylon.table.plans.TablePlanCommon
getTableDescription, getTableName, withTableDescription, withTableName
-
Constructor Details
-
TablePlanRead
public TablePlanRead()
-
-
Method Details
-
withIncludeResourceName
-
getResourceName
-
withLocalDateFormat
-
getLocalDateFormat
-
withTransform
-
withTransforms
-
getTransforms
-
withHeaderStrategy
-
getHeaderStrategy
-
withSelectedColumn
-
withSelectedColumns
-
withSelectedColumns
-
withSelectedColumns
-
getSelectedColumns
-
withColumnRename
-
withColumnRenames
-
getColumnRenames
-
withRowFilter
-
getRowFilter
-
withStripping
-
isStripping
public boolean isStripping() -
withColumnType
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 namecolumnType- the desired output type- Returns:
- this plan
-
withColumnTypes
-
getColumnType
-
getColumnTypes
-
execute
-
execute
public TableColumnar execute(TableName tableName, TableDescription tableDescription, Column... columns) -
execute
-
execute
Description copied from interface:TablePlanExecutes 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 liveResultSetin 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
Reads the supplied stream source as CSV usingReadOptionsCsv.standard()defaults.- Parameters:
streamSource- the CSV stream source- Returns:
- the parsed table
-
execute
Description copied from interface:TablePlanExecutes 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
RowSourceand 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
- Specified by:
selfin classTablePlanCommon<TablePlanRead>
-