public class MissingColumnHandlerBuilder extends Object
The set of missing columns may differ per reader or even per batch within a reader. If reader 1 reads all columns, but reader 2 reads a subset, then this class will use the column types from reader 1 when creating the columns missing from reader 2.
Unfortunately, Drill cannot predict the future, so the opposite scenario will end badly: Reader 2 comes first, omits column "c", this class chooses a default value, then Reader 1 wants the column to be some other type. The query will fail with a type mismatch error.
Specifically, the mechanism uses the following rules to infer column type:
Note that Drill is not magic: relying on the default type is likely to cause a type conflict across readers or across scans. A default has no way of knowing if it matches the same column read in some other fragment on some other node.
Work is separated in a schema-time part (to resolve column types) and a read-time part (to create and fill the needed vectors.)
Modifier and Type | Field and Description |
---|---|
protected boolean |
allowRequiredNullColumns |
static TypeProtos.MajorType |
DEFAULT_NULL_TYPE |
protected TupleMetadata |
inputSchema |
protected TypeProtos.MajorType |
nullType |
protected TupleMetadata |
outputSchema |
protected ResultVectorCache |
vectorCache |
Constructor and Description |
---|
MissingColumnHandlerBuilder() |
Modifier and Type | Method and Description |
---|---|
MissingColumnHandlerBuilder |
allowRequiredNullColumns(boolean flag) |
StaticBatchBuilder |
build() |
TupleMetadata |
buildSchema() |
MissingColumnHandlerBuilder |
inputSchema(TupleMetadata inputSchema) |
MissingColumnHandlerBuilder |
nullType(TypeProtos.MajorType nullType) |
MissingColumnHandlerBuilder |
vectorCache(ResultVectorCache vectorCache) |
public static final TypeProtos.MajorType DEFAULT_NULL_TYPE
protected TupleMetadata inputSchema
protected TypeProtos.MajorType nullType
protected boolean allowRequiredNullColumns
protected ResultVectorCache vectorCache
protected TupleMetadata outputSchema
public MissingColumnHandlerBuilder inputSchema(TupleMetadata inputSchema)
public MissingColumnHandlerBuilder nullType(TypeProtos.MajorType nullType)
public MissingColumnHandlerBuilder allowRequiredNullColumns(boolean flag)
public MissingColumnHandlerBuilder vectorCache(ResultVectorCache vectorCache)
public TupleMetadata buildSchema()
public StaticBatchBuilder build()
Copyright © 1970 The Apache Software Foundation. All rights reserved.