use of org.apache.drill.common.exceptions.ChildErrorContext in project drill by apache.
the class PhoenixScanBatchCreator method createBuilder.
private ScanFrameworkBuilder createBuilder(OptionManager options, PhoenixSubScan subScan) {
ScanFrameworkBuilder builder = new ScanFrameworkBuilder();
builder.projection(subScan.getColumns());
builder.setUserName(subScan.getUserName());
// Phoenix reader
ReaderFactory readerFactory = new PhoenixReaderFactory(subScan);
builder.setReaderFactory(readerFactory);
builder.nullType(Types.optional(MinorType.VARCHAR));
// Add custom error context
builder.errorContext(new ChildErrorContext(builder.errorContext()) {
@Override
public void addContext(UserException.Builder builder) {
builder.addContext("sql : ", subScan.getScanSpec().getSql());
builder.addContext("columns : ", subScan.getScanSpec().getColumns().toString());
builder.addContext("estimate row count : ", subScan.getScanSpec().getEstimateRows());
}
});
return builder;
}
use of org.apache.drill.common.exceptions.ChildErrorContext in project drill by apache.
the class HttpCSVBatchReader method open.
@Override
public boolean open(SchemaNegotiator negotiator) {
// Result set loader setup
String tempDirPath = negotiator.drillConfig().getString(ExecConstants.DRILL_TMP_DIR);
HttpUrl url = buildUrl();
CustomErrorContext errorContext = new ChildErrorContext(negotiator.parentErrorContext()) {
@Override
public void addContext(UserException.Builder builder) {
super.addContext(builder);
builder.addContext("URL", url.toString());
}
};
negotiator.setErrorContext(errorContext);
// Http client setup
SimpleHttp http = SimpleHttp.builder().scanDefn(subScan).url(url).tempDir(new File(tempDirPath)).proxyConfig(proxySettings(negotiator.drillConfig(), url)).errorContext(errorContext).build();
// CSV loader setup
inStream = http.getInputStream();
this.csvReader = new CsvParser(csvSettings);
csvReader.beginParsing(inStream);
// Build the Schema
builder = new SchemaBuilder();
TupleMetadata drillSchema = buildSchema();
negotiator.tableSchema(drillSchema, true);
resultLoader = negotiator.build();
// Add implicit columns
if (implicitColumnsAreProjected()) {
implicitColumns = new ImplicitColumns(resultLoader.writer());
buildImplicitColumns();
populateImplicitFieldMap(http);
}
// Create ScalarWriters
rowWriter = resultLoader.writer();
populateWriterArray();
return true;
}
Aggregations