Class SchemaNegotiatorImpl
- All Implemented Interfaces:
SchemaNegotiator
- Direct Known Subclasses:
FileScanFramework.FileSchemaNegotiatorImpl
Handles both early- and late-schema readers. Early-schema readers provide a table schema, late-schema readers do not.
If the reader (or, later, the scanner) has a SELECT list, then that select list is pushed down into the result set loader created for the reader.
Also handles parsing out various column types, filling in null columns and (via the vector cache), minimizing changes across readers. In the worst case, a reader might have a column "c" in one file, might skip "c" in the second file, and "c" may appear again in a third file. This negotiator, along with the scan projection and vector cache, "smoothes out" schema changes by preserving the vector for "c" across all three files. In the first and third files "c" is a vector written by the reader, in the second, it is a null column filled in by the scan projector (assuming, of course, that "c" is nullable or an array.)
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected CustomErrorContextprotected final ManagedScanFrameworkprotected booleanprotected longprotected TupleMetadataprotected TupleMetadata -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbatchSize(int maxRecordsPerBatch) Set the preferred batch size (which may be overridden by the result set loader in order to limit vector or batch size.)voidbind(SchemaNegotiatorImpl.NegotiatorListener listener) build()Callback from the schema negotiator to build the schema from information from both the table and scan operator.context()com.typesafe.config.ConfigbooleanReport if the execution plan defines a provided schema.booleanReport whether the projection list is empty, as occurs in two cases: SELECT COUNT(*) ... -- empty project. SELECT a, b FROM table(c d) -- disjoint project.booleanvoidlimit(long limit) Push down a LIMIT into the scan.The context to use as a parent when creating a custom context.Returns the provided schema, if defined.voidsetErrorContext(CustomErrorContext context) Specify an advanced error context which allows the reader to fill in custom context values.voidtableSchema(TupleMetadata schema, boolean isComplete) Specify the table schema if this is an early-schema reader.userName()Name of the user running the query.
-
Field Details
-
framework
-
context
-
providedSchema
-
tableSchema
-
isSchemaComplete
protected boolean isSchemaComplete -
batchSize
protected int batchSize -
limit
protected long limit
-
-
Constructor Details
-
SchemaNegotiatorImpl
-
-
Method Details
-
bind
-
isProjectionEmpty
public boolean isProjectionEmpty()Description copied from interface:SchemaNegotiatorReport whether the projection list is empty, as occurs in two cases:- SELECT COUNT(*) ... -- empty project.
- SELECT a, b FROM table(c d) -- disjoint project.
- Specified by:
isProjectionEmptyin interfaceSchemaNegotiator- Returns:
- true if no columns are projected, and the client can
make use of
ResultSetLoader.skipRows(int)to indicate the row count, false if at least one column is projected and so data must be written using the loader
-
hasProvidedSchema
public boolean hasProvidedSchema()Description copied from interface:SchemaNegotiatorReport if the execution plan defines a provided schema. If so, the reader should use that schema, converting or ignoring columns as needed. A scan without a provided schema has a "dynamic" schema to be defined by the scan operator itself along with the column projection list.- Specified by:
hasProvidedSchemain interfaceSchemaNegotiator- Returns:
trueif the execution plan defines the output schema,falseif the schema should be computed dynamically from the source schema and column projections
-
providedSchema
Description copied from interface:SchemaNegotiatorReturns the provided schema, if defined. The provided schema is a description of the source schema viewed as a Drill schema.- Specified by:
providedSchemain interfaceSchemaNegotiator- Returns:
- the output schema, if
SchemaNegotiator.hasProvidedSchema()returnstrue,nullotherwise
-
context
- Specified by:
contextin interfaceSchemaNegotiator
-
drillConfig
public com.typesafe.config.Config drillConfig()- Specified by:
drillConfigin interfaceSchemaNegotiator
-
queryOptions
- Specified by:
queryOptionsin interfaceSchemaNegotiator
-
parentErrorContext
Description copied from interface:SchemaNegotiatorThe context to use as a parent when creating a custom context.(Obtain the error context for this reader from the
ResultSetLoader.- Specified by:
parentErrorContextin interfaceSchemaNegotiator
-
errorContext
-
setErrorContext
Description copied from interface:SchemaNegotiatorSpecify an advanced error context which allows the reader to fill in custom context values.- Specified by:
setErrorContextin interfaceSchemaNegotiator
-
tableSchema
Description copied from interface:SchemaNegotiatorSpecify the table schema if this is an early-schema reader. Need not be called for a late-schema readers. The schema provided here, if any, is a base schema: the reader is free to discover additional columns during the read.Should only be called if the schema is dynamic, that is, if
SchemaNegotiator.hasProvidedSchema()returns false.- Specified by:
tableSchemain interfaceSchemaNegotiator- Parameters:
schema- the table schema if known at open timeisComplete- true if the schema is complete: if it can be used to define an empty schema-only batch for the first reader. Set to false if the schema is partial: if the reader must read rows to determine the full schema
-
isSchemaComplete
public boolean isSchemaComplete() -
batchSize
public void batchSize(int maxRecordsPerBatch) Description copied from interface:SchemaNegotiatorSet the preferred batch size (which may be overridden by the result set loader in order to limit vector or batch size.)- Specified by:
batchSizein interfaceSchemaNegotiator- Parameters:
maxRecordsPerBatch- preferred number of record per batch
-
userName
Description copied from interface:SchemaNegotiatorName of the user running the query.- Specified by:
userNamein interfaceSchemaNegotiator
-
limit
public void limit(long limit) Description copied from interface:SchemaNegotiatorPush down a LIMIT into the scan. This is a per-reader limit, not an overall scan limit.- Specified by:
limitin interfaceSchemaNegotiator
-
build
Callback from the schema negotiator to build the schema from information from both the table and scan operator. Returns the result set loader to be used by the reader to write to the table's value vectors. schema information- Specified by:
buildin interfaceSchemaNegotiator- Returns:
- the result set loader to be used by the reader
-