Package net.hydromatic.optiq

Examples of net.hydromatic.optiq.SchemaPlus


    DrillFileSystem fs = null;
    String defaultLocation = null;
    String fromDir = "./";

    try {
      SchemaPlus defaultSchema = context.getNewDefaultSchema();
      SchemaPlus drillSchema = defaultSchema;

      // Show files can be used without from clause, in which case we display the files in the default schema
      if (from != null) {
        // We are not sure if the full from clause is just the schema or includes table name, first try to see if the full path specified is a schema
        try {
View Full Code Here


    @Override
    public PhysicalPlan getPlan(SqlNode sqlNode) throws ValidationException, RelConversionException, IOException {
      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. " +
View Full Code Here

    @Override
    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. " +
View Full Code Here

        RelDataType rowType = new DrillFixedRelDataTypeImpl(planner.getTypeFactory(), tblFiledNames);

        relQuery = RelOptUtil.createCastRel(relQuery, rowType, true);
      }

      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));
      }

      log("Optiq Logical", relQuery);
View Full Code Here

  public static SchemaPlus findSchema(SchemaPlus rootSchema, SchemaPlus defaultSchema, List<String> schemaPath)
      throws Exception {
    if (schemaPath.size() == 0)
      return defaultSchema;

    SchemaPlus schema;

    if ((schema = searchSchemaTree(defaultSchema, schemaPath)) != null)
      return schema;

    if ((schema = searchSchemaTree(rootSchema, schemaPath)) != null)
View Full Code Here

    String tableSchema;
    if (db != null) {
      tableSchema = db.toString();
    } else {
      // If no schema is given in SHOW TABLES command, list tables from current schema
      SchemaPlus schema = context.getNewDefaultSchema();

      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");
      }
View Full Code Here

    final StoragePluginRegistry registry = new StoragePluginRegistry(dbContext);
    registry.init();
    final FunctionImplementationRegistry functionRegistry = new FunctionImplementationRegistry(config);
    final DrillOperatorTable table = new DrillOperatorTable(functionRegistry);
    final SchemaPlus root = SimpleOptiqSchema.createRootSchema(false);
    registry.getSchemaFactory().registerSchemas(UserSession.Builder.newBuilder().setSupportComplexTypes(true).build(), root);


    new NonStrictExpectations() {
      {
View Full Code Here

  }

  @Override
  public void registerSchemas(UserSession session, SchemaPlus parent) {
    HiveSchema schema = new HiveSchema(schemaName);
    SchemaPlus hPlus = parent.add(schemaName, schema);
    schema.setHolder(hPlus);
  }
View Full Code Here

  }

  @Override
  public void registerSchemas(UserSession session, SchemaPlus parent) {
    HBaseSchema schema = new HBaseSchema(schemaName);
    SchemaPlus hPlus = parent.add(schemaName, schema);
    schema.setHolder(hPlus);
  }
View Full Code Here

    if (connection == null) {
      fail(new UnsupportedOperationException("Schema tree can only be created in root fragment. " +
          "This is a non-root fragment."));
      return null;
    } else {
      SchemaPlus root = SimpleOptiqSchema.createRootSchema(false);
      context.getStorage().getSchemaFactory().registerSchemas(connection.getSession(), root);
      return root;
    }
  }
View Full Code Here

TOP

Related Classes of net.hydromatic.optiq.SchemaPlus

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.