Search in sources :

Example 6 with ChildErrorContext

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;
}
Also used : ScanFrameworkBuilder(org.apache.drill.exec.physical.impl.scan.framework.ManagedScanFramework.ScanFrameworkBuilder) ChildErrorContext(org.apache.drill.common.exceptions.ChildErrorContext) ReaderFactory(org.apache.drill.exec.physical.impl.scan.framework.ManagedScanFramework.ReaderFactory) UserException(org.apache.drill.common.exceptions.UserException)

Example 7 with ChildErrorContext

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;
}
Also used : SimpleHttp(org.apache.drill.exec.store.http.util.SimpleHttp) ChildErrorContext(org.apache.drill.common.exceptions.ChildErrorContext) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) CsvParser(com.univocity.parsers.csv.CsvParser) File(java.io.File) HttpUrl(okhttp3.HttpUrl) ImplicitColumns(org.apache.drill.exec.store.ImplicitColumnUtils.ImplicitColumns) CustomErrorContext(org.apache.drill.common.exceptions.CustomErrorContext)

Aggregations

ChildErrorContext (org.apache.drill.common.exceptions.ChildErrorContext)7 CustomErrorContext (org.apache.drill.common.exceptions.CustomErrorContext)4 File (java.io.File)3 HttpUrl (okhttp3.HttpUrl)3 UserException (org.apache.drill.common.exceptions.UserException)3 ImplicitColumns (org.apache.drill.exec.store.ImplicitColumnUtils.ImplicitColumns)3 SimpleHttp (org.apache.drill.exec.store.http.util.SimpleHttp)3 ReaderFactory (org.apache.drill.exec.physical.impl.scan.framework.ManagedScanFramework.ReaderFactory)2 ScanFrameworkBuilder (org.apache.drill.exec.physical.impl.scan.framework.ManagedScanFramework.ScanFrameworkBuilder)2 CsvParser (com.univocity.parsers.csv.CsvParser)1 InputStream (java.io.InputStream)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 Builder (okhttp3.HttpUrl.Builder)1 PlanStringBuilder (org.apache.drill.common.PlanStringBuilder)1 ColumnsScanBuilder (org.apache.drill.exec.physical.impl.scan.columns.ColumnsScanFramework.ColumnsScanBuilder)1 RowSetLoader (org.apache.drill.exec.physical.resultSet.RowSetLoader)1 SchemaBuilder (org.apache.drill.exec.record.metadata.SchemaBuilder)1 TupleMetadata (org.apache.drill.exec.record.metadata.TupleMetadata)1 JsonLoaderBuilder (org.apache.drill.exec.store.easy.json.loader.JsonLoaderImpl.JsonLoaderBuilder)1 JsonLoaderOptions (org.apache.drill.exec.store.easy.json.loader.JsonLoaderOptions)1