Class ColumnsArrayManager

java.lang.Object
org.apache.drill.exec.physical.impl.scan.columns.ColumnsArrayManager
All Implemented Interfaces:
ReaderLevelProjection.ReaderProjectionResolver

public class ColumnsArrayManager extends Object implements ReaderLevelProjection.ReaderProjectionResolver
Handles the special case in which the entire row is returned as a "columns" array. The SELECT list can include:
  • `columns`: Use the columns array.
  • Wildcard: Equivalent to columns.
  • One or more references to specific array members: columns[2], columns[4], ....
In the first two forms, all columns are loaded into the columns array. In the third form, only the columns listed are loaded, the other slots will exist, but will be empty.

The columns mechanism works in conjunction with a reader that is aware of this model. For example, the text reader can be configured to use the columns mechanism, or to pick out columns by name. The reader and this mechanism must be coordinated: configure this mechanism only when the reader itself is configured to use model. That configuration is done outside of this mechanism; it is typically done when setting up the scan operator.

The output of this mechanism is a specialized projected column that identifies itself as the columns column, and optionally holds the list of selected elements.

Configuration

The mechanism handles two use cases:
  • The reader uses normal named columns. In this case the scan operator should not configure this mechanism; that will allow a column called columns to work like any other column: no special handling.
  • The reader uses a single columns array as described below.
The scan operator configures this mechanism and adds it to the ScanSchemaOrchestrator. The associated parser handles the scan-level projection resolution.

The reader produces a schema with a single column, columns, of the agreed-upon type (as configured here.)

Although the ResultSetLoader automatically handles column-level projection; it does not handle array-level projection. (Perhaps we might want to add that later.) Instead, the reader is given a pointer to this mechanism from which it can retrieve the desired set of array items, and writes only those items to the array column via the usual vector writer mechanism.