use of org.apache.drill.exec.physical.impl.scan.columns.ColumnsScanFramework.ColumnsScanBuilder in project drill by apache.
the class TextFormatPlugin method frameworkBuilder.
@Override
protected FileScanBuilder frameworkBuilder(OptionManager options, EasySubScan scan) throws ExecutionSetupException {
ColumnsScanBuilder builder = new ColumnsScanBuilder();
initScanBuilder(builder, scan);
TextParsingSettings settings = new TextParsingSettings(getConfig(), scan.getSchema());
builder.setReaderFactory(new ColumnsReaderFactory(settings, scan.getMaxRecords()));
// If this format has no headers, or wants to skip them,
// then we must use the columns column to hold the data.
builder.requireColumnsArray(!settings.isHeaderExtractionEnabled() && builder.providedSchema() == null);
// Text files handle nulls in an unusual way. Missing columns
// are set to required Varchar and filled with blanks. Yes, this
// means that the SQL statement or code cannot differentiate missing
// columns from empty columns, but that is how CSV and other text
// files have been defined within Drill.
builder.nullType(Types.required(MinorType.VARCHAR));
// The text readers use required Varchar columns to represent null columns.
builder.allowRequiredNullColumns(true);
// Provide custom error context
builder.errorContext(new ChildErrorContext(builder.errorContext()) {
@Override
public void addContext(UserException.Builder builder) {
super.addContext(builder);
builder.addContext("Extract headers:", Boolean.toString(getConfig().isHeaderExtractionEnabled()));
builder.addContext("Skip first line:", Boolean.toString(getConfig().isSkipFirstLine()));
}
});
return builder;
}
use of org.apache.drill.exec.physical.impl.scan.columns.ColumnsScanFramework.ColumnsScanBuilder in project drill by apache.
the class TestColumnsArray method buildScan.
private ScanSchemaOrchestrator buildScan(boolean requireColumns, List<SchemaPath> cols) {
// Set up the columns array manager
ColumnsArrayManager colsManager = new ColumnsArrayManager(requireColumns);
// Configure the schema orchestrator
ScanOrchestratorBuilder builder = new ColumnsScanBuilder();
builder.addParser(colsManager.projectionParser());
builder.addResolver(colsManager.resolver());
builder.projection(cols);
return new ScanSchemaOrchestrator(fixture.allocator(), builder);
}
Aggregations