Package org.apache.drill.exec.store

Examples of org.apache.drill.exec.store.AbstractSchema


    return true;
  }

  protected boolean shouldVisitSchema(SchemaPlus schema) {
    try {
      AbstractSchema drillSchema = schema.unwrap(AbstractSchema.class);
      return drillSchema.showInInformationSchema();
    } catch(ClassCastException e) {
      // ignore and return true as this is not a drill schema
    }
    return true;
  }
View Full Code Here


    }

    @Override
    public boolean visitSchema(String schemaName, SchemaPlus schema) {
      if (shouldVisitSchema(schema) && schemaName != null && !schemaName.isEmpty()) {
        AbstractSchema as = schema.unwrap(AbstractSchema.class);
        records.add(new Records.Schema("DRILL", schemaName, "<owner>", as.getTypeName(), as.isMutable()));
      }
      return false;
    }
View Full Code Here

        throw new RelConversionException(String.format("Table %s is not valid", Util.sepList(table.names, ".")));
      }

      SqlNode schemaCondition = null;
      if (!isRootSchema(schema)) {
        AbstractSchema drillSchema = getDrillSchema(schema);

        schemaCondition = DrillParserUtil.createCondition(
            new SqlIdentifier("TABLE_SCHEMA", SqlParserPos.ZERO),
            SqlStdOperatorTable.EQUALS,
            SqlLiteral.createCharString(drillSchema.getFullSchemaName(), CHARSET, SqlParserPos.ZERO)
        );
      }

      SqlNode where = DrillParserUtil.createCondition(
          new SqlIdentifier("TABLE_NAME", SqlParserPos.ZERO),
View Full Code Here

            drillSchema = findSchema(context.getRootSchema(), defaultSchema, from.names.subList(0, from.names.size() - 1));
            fromDir = fromDir + from.names.get((from.names.size() - 1));
        }
      }

      AbstractSchema tempSchema = getDrillSchema(drillSchema);
      WorkspaceSchema schema = null;
      if (tempSchema instanceof WorkspaceSchema) {
        schema = ((WorkspaceSchema)tempSchema);
      } else {
        throw new ValidationException("Unsupported schema");
View Full Code Here

      if (isRootSchema(schema)) {
        // If the default schema is a root schema, throw an error to select a default schema
        throw new RelConversionException("No schema selected. Select a schema using 'USE schema' command");
      }

      AbstractSchema drillSchema;

      try {
        drillSchema = getDrillSchema(schema);
      } catch(Exception ex) {
        throw new RelConversionException("Error while rewriting SHOW TABLES query: " + ex.getMessage(), ex);
      }

      tableSchema = drillSchema.getFullSchemaName();
    }

    where = DrillParserUtil.createCondition(
        new SqlIdentifier("TABLE_SCHEMA", SqlParserPos.ZERO),
        SqlStdOperatorTable.EQUALS,
View Full Code Here

      SqlCreateView createView = unwrap(sqlNode, SqlCreateView.class);

      try {
        SchemaPlus defaultSchema = context.getNewDefaultSchema();
        SchemaPlus schema = findSchema(context.getRootSchema(), defaultSchema, createView.getSchemaPath());
        AbstractSchema drillSchema = getDrillSchema(schema);

        String schemaPath = drillSchema.getFullSchemaName();
        if (!drillSchema.isMutable())
          return DirectPlan.createDirectPlan(context, false, String.format("Unable to create view. " +
            "Schema [%s] is immutable. ", schemaPath));

        // find current workspace schema path
        List<String> workspaceSchemaPath = ImmutableList.of();
View Full Code Here

    public PhysicalPlan getPlan(SqlNode sqlNode) throws ValidationException, RelConversionException, IOException {
      SqlDropView dropView = unwrap(sqlNode, SqlDropView.class);

      try {
        SchemaPlus schema = findSchema(context.getRootSchema(), context.getNewDefaultSchema(), dropView.getSchemaPath());
        AbstractSchema drillSchema = getDrillSchema(schema);

        String schemaPath = drillSchema.getFullSchemaName();
        if (!drillSchema.isMutable())
          return DirectPlan.createDirectPlan(context, false, String.format("Schema '%s' is not a mutable schema. " +
              "Views don't exist in this schema", schemaPath));

        if (drillSchema instanceof WorkspaceSchema) {
          ((WorkspaceSchema) drillSchema).dropView(dropView.getName());;
View Full Code Here

      }

      SchemaPlus schema = findSchema(context.getRootSchema(), context.getNewDefaultSchema(),
          sqlCreateTable.getSchemaPath());

      AbstractSchema drillSchema = getDrillSchema(schema);

      if (!drillSchema.isMutable())
        return DirectPlan.createDirectPlan(context, false, String.format("Current schema '%s' is not a mutable schema. " +
            "Can't create tables in this schema.", drillSchema.getFullSchemaName()));

      String newTblName = sqlCreateTable.getName();
      if (schema.getTable(newTblName) != null) {
        return DirectPlan.createDirectPlan(context, false, String.format("Table '%s' already exists.", newTblName));
      }
View Full Code Here

  /**
   * From a given SchemaPlus return a Drill schema object of type AbstractSchema if exists.
   * Otherwise throw errors.
   */
  public static AbstractSchema getDrillSchema(SchemaPlus schemaPlus) throws Exception{
    AbstractSchema drillSchema;
    try {
      drillSchema = schemaPlus.unwrap(AbstractSchema.class);
      drillSchema = drillSchema.getDefaultSchema();
    } catch(ClassCastException e) {
      throw new Exception("Current schema is not a Drill schema. " +
              "Can't create new relations (tables or views) in non-Drill schemas.", e);
    }

View Full Code Here

  /**
   * From a given SchemaPlus return a Drill schema object of type AbstractSchema if exists.
   * Otherwise throw errors.
   */
  public static AbstractSchema getDrillSchema(SchemaPlus schemaPlus) throws Exception {
    AbstractSchema drillSchema;
    try {
      drillSchema = schemaPlus.unwrap(AbstractSchema.class);
      drillSchema = drillSchema.getDefaultSchema();
    } catch (ClassCastException e) {
      throw new Exception("Current schema is not a Drill schema. " +
              "Can't create new relations (tables or views) in non-Drill schemas.", e);
    }

View Full Code Here

TOP

Related Classes of org.apache.drill.exec.store.AbstractSchema

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.