Search in sources :

Example 66 with DrillRuntimeException

use of org.apache.drill.common.exceptions.DrillRuntimeException in project drill by apache.

the class HiveScan method getScanStats.

@Override
public ScanStats getScanStats() {
    try {
        final HiveStats stats = metadataProvider.getStats(hiveReadEntry);
        logger.debug("HiveStats: {}", stats.toString());
        // Hive's native reader is neither memory efficient nor fast. Increase the CPU cost
        // by a factor to let the planner choose HiveDrillNativeScan over HiveScan with SerDes.
        float cpuCost = 1 * getSerDeOverheadFactor();
        return new ScanStats(GroupScanProperty.NO_EXACT_ROW_COUNT, stats.getNumRows(), cpuCost, stats.getSizeInBytes());
    } catch (final IOException e) {
        throw new DrillRuntimeException(e);
    }
}
Also used : HiveStats(org.apache.drill.exec.store.hive.HiveMetadataProvider.HiveStats) IOException(java.io.IOException) DrillRuntimeException(org.apache.drill.common.exceptions.DrillRuntimeException) ScanStats(org.apache.drill.exec.physical.base.ScanStats)

Example 67 with DrillRuntimeException

use of org.apache.drill.common.exceptions.DrillRuntimeException in project drill by apache.

the class DescribeSchemaHandler method getPlan.

@Override
public PhysicalPlan getPlan(SqlNode sqlNode) {
    SqlIdentifier schema = ((SqlDescribeSchema) sqlNode).getSchema();
    SchemaPlus drillSchema = SchemaUtilites.findSchema(config.getConverter().getDefaultSchema(), schema.names);
    if (drillSchema != null) {
        StoragePlugin storagePlugin;
        try {
            storagePlugin = context.getStorage().getPlugin(schema.names.get(0));
        } catch (ExecutionSetupException e) {
            throw new DrillRuntimeException("Failure while retrieving storage plugin", e);
        }
        String properties;
        try {
            final Map configMap = mapper.convertValue(storagePlugin.getConfig(), Map.class);
            if (storagePlugin instanceof FileSystemPlugin) {
                transformWorkspaces(schema.names, configMap);
            }
            properties = mapper.writeValueAsString(configMap);
        } catch (JsonProcessingException e) {
            throw new DrillRuntimeException("Error while trying to convert storage config to json string", e);
        }
        return DirectPlan.createDirectPlan(context, new DescribeSchemaResult(Joiner.on(".").join(schema.names), properties));
    }
    throw UserException.validationError().message(String.format("Invalid schema name [%s]", Joiner.on(".").join(schema.names))).build(logger);
}
Also used : ExecutionSetupException(org.apache.drill.common.exceptions.ExecutionSetupException) FileSystemPlugin(org.apache.drill.exec.store.dfs.FileSystemPlugin) SchemaPlus(org.apache.calcite.schema.SchemaPlus) SerializableString(com.fasterxml.jackson.core.SerializableString) SqlIdentifier(org.apache.calcite.sql.SqlIdentifier) DrillRuntimeException(org.apache.drill.common.exceptions.DrillRuntimeException) Map(java.util.Map) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) SqlDescribeSchema(org.apache.drill.exec.planner.sql.parser.SqlDescribeSchema) StoragePlugin(org.apache.drill.exec.store.StoragePlugin)

Example 68 with DrillRuntimeException

use of org.apache.drill.common.exceptions.DrillRuntimeException in project drill by apache.

the class DrillMetaImpl method s.

private MetaResultSet s(String s) {
    try {
        logger.debug("Running {}", s);
        AvaticaStatement statement = connection.createStatement();
        return MetaResultSet.create(connection.id, statement.getId(), true, newSignature(s), null);
    } catch (Exception e) {
        // didn't allow for SQLException!
        throw new DrillRuntimeException("Failure while attempting to get DatabaseMetadata.", e);
    }
}
Also used : DrillRuntimeException(org.apache.drill.common.exceptions.DrillRuntimeException) RpcException(org.apache.drill.exec.rpc.RpcException) DrillRuntimeException(org.apache.drill.common.exceptions.DrillRuntimeException) SQLException(java.sql.SQLException) AvaticaStatement(org.apache.calcite.avatica.AvaticaStatement)

Example 69 with DrillRuntimeException

use of org.apache.drill.common.exceptions.DrillRuntimeException in project drill by apache.

the class ExpressionInterpreterTest method createMockScanBatch.

@SuppressWarnings("resource")
private ScanBatch createMockScanBatch(Drillbit bit, MockSubScanPOP scanPOP, BitControl.PlanFragment planFragment) {
    final List<RecordBatch> children = Lists.newArrayList();
    final MockScanBatchCreator creator = new MockScanBatchCreator();
    try {
        final FragmentContext context = new FragmentContext(bit.getContext(), planFragment, null, bit.getContext().getFunctionImplementationRegistry());
        return creator.getBatch(context, scanPOP, children);
    } catch (Exception ex) {
        throw new DrillRuntimeException("Error when setup fragment context" + ex);
    }
}
Also used : FragmentContext(org.apache.drill.exec.ops.FragmentContext) RecordBatch(org.apache.drill.exec.record.RecordBatch) DrillRuntimeException(org.apache.drill.common.exceptions.DrillRuntimeException) MockScanBatchCreator(org.apache.drill.exec.store.mock.MockScanBatchCreator) DrillRuntimeException(org.apache.drill.common.exceptions.DrillRuntimeException)

Aggregations

DrillRuntimeException (org.apache.drill.common.exceptions.DrillRuntimeException)69 IOException (java.io.IOException)32 VersionMismatchException (org.apache.drill.exec.exception.VersionMismatchException)9 Stopwatch (com.google.common.base.Stopwatch)7 ExecutionSetupException (org.apache.drill.common.exceptions.ExecutionSetupException)7 UserException (org.apache.drill.common.exceptions.UserException)6 KeeperException (org.apache.zookeeper.KeeperException)6 NodeExistsException (org.apache.zookeeper.KeeperException.NodeExistsException)6 NoSuchElementException (java.util.NoSuchElementException)5 Path (org.apache.hadoop.fs.Path)5 Bson (org.bson.conversions.Bson)4 Registry (org.apache.drill.exec.proto.UserBitShared.Registry)3 ValueVector (org.apache.drill.exec.vector.ValueVector)3 Admin (org.apache.hadoop.hbase.client.Admin)3 Document (org.bson.Document)3 File (java.io.File)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 URI (java.net.URI)2 RexNode (org.apache.calcite.rex.RexNode)2 LogicalExpression (org.apache.drill.common.expression.LogicalExpression)2