Examples of CreateTable


Examples of org.apache.accumulo.test.randomwalk.unit.CreateTable

    return new File(this.getClass().getResource(resource).toURI());
  }

  @org.junit.Test
  public void testRWTest() {
    Test t1 = new CreateTable();
    assertEquals("org.apache.accumulo.test.randomwalk.unit.CreateTable", t1.toString());

    Test t2 = new CreateTable();
    assertEquals("CreateTable test nodes were not equal.", t1, t2);
  }
View Full Code Here

Examples of org.apache.accumulo.test.randomwalk.unit.CreateTable

    }
  }
 
  public void testRWTest() {
   
    Test t1 = new CreateTable();
    assertTrue(t1.toString().equals("org.apache.accumulo.test.randomwalk.unit.CreateTable"));
   
    Test t2 = new CreateTable();
    assertTrue(t1.equals(t2));
  }
View Full Code Here

Examples of org.apache.metamodel.create.CreateTable

    public void testUsingSingleUpdates() throws Exception {
        final JdbcDataContext dc = new JdbcDataContext(conn);
       
        final Schema schema = dc.getDefaultSchema();
        dc.executeUpdate(new CreateTable(schema, "test_table").withColumn("id").ofType(ColumnType.VARCHAR));

        final Table table = schema.getTableByName("test_table");
        dc.executeUpdate(new InsertInto(table).value(0, "foo"));
        dc.executeUpdate(new InsertInto(table).value(0, "bar"));
View Full Code Here

Examples of org.apache.tajo.algebra.CreateTable

  @Test
  public void testCreateTablePartitionByHash1() throws IOException {
    String sql = FileUtil.readTextFile(new File("src/test/resources/queries/default/create_table_partition_by_hash_1.sql"));
    Expr expr = parseQuery(sql);
    assertEquals(OpType.CreateTable, expr.getType());
    CreateTable createTable = (CreateTable) expr;
    assertTrue(createTable.hasPartition());
    assertEquals(CreateTable.PartitionType.HASH, createTable.getPartitionMethod().getPartitionType());
    CreateTable.HashPartition hashPartition = createTable.getPartitionMethod();
    assertEquals("col1", hashPartition.getColumns()[0].getCanonicalName());
    assertTrue(hashPartition.hasQuantifier());
  }
View Full Code Here

Examples of org.apache.tajo.algebra.CreateTable

  @Test
  public void testCreateTablePartitionByHash2() throws IOException {
    String sql = FileUtil.readTextFile(new File("src/test/resources/queries/default/create_table_partition_by_hash_2.sql"));
    Expr expr = parseQuery(sql);
    assertEquals(OpType.CreateTable, expr.getType());
    CreateTable createTable = (CreateTable) expr;
    assertTrue(createTable.hasPartition());
    assertEquals(CreateTable.PartitionType.HASH, createTable.getPartitionMethod().getPartitionType());
    CreateTable.HashPartition hashPartition = createTable.getPartitionMethod();
    assertEquals("col1", hashPartition.getColumns()[0].getCanonicalName());
    assertTrue(hashPartition.hasSpecifiers());
    assertEquals(3, hashPartition.getSpecifiers().size());
  }
View Full Code Here

Examples of org.apache.tajo.algebra.CreateTable

  @Test
  public void testCreateTablePartitionByRange() throws IOException {
    String sql = FileUtil.readTextFile(new File("src/test/resources/queries/default/create_table_partition_by_range.sql"));
    Expr expr = parseQuery(sql);
    assertEquals(OpType.CreateTable, expr.getType());
    CreateTable createTable = (CreateTable) expr;
    assertTrue(createTable.hasPartition());
    assertEquals(CreateTable.PartitionType.RANGE, createTable.getPartitionMethod().getPartitionType());
    CreateTable.RangePartition rangePartition = createTable.getPartitionMethod();
    assertEquals("col1", rangePartition.getColumns()[0].getCanonicalName());
    assertEquals(3, rangePartition.getSpecifiers().size());
  }
View Full Code Here

Examples of org.apache.tajo.algebra.CreateTable

  @Test
  public void testCreateTablePartitionByList() throws IOException {
    String sql = FileUtil.readTextFile(new File("src/test/resources/queries/default/create_table_partition_by_list.sql"));
    Expr expr = parseQuery(sql);
    assertEquals(OpType.CreateTable, expr.getType());
    CreateTable createTable = (CreateTable) expr;
    assertTrue(createTable.hasPartition());
    assertEquals(CreateTable.PartitionType.LIST, createTable.getPartitionMethod().getPartitionType());
    CreateTable.ListPartition listPartition = createTable.getPartitionMethod();
    assertEquals("col1", listPartition.getColumns()[0].getCanonicalName());
    assertEquals(2, listPartition.getSpecifiers().size());
    Iterator<CreateTable.ListPartitionSpecifier> iterator = listPartition.getSpecifiers().iterator();
    CreateTable.ListPartitionSpecifier specifier = iterator.next();
    LiteralValue value1 = (LiteralValue) specifier.getValueList().getValues()[0];
View Full Code Here

Examples of org.apache.tajo.algebra.CreateTable

  @Test
  public void testCreateTablePartitionByColumn() throws IOException {
    String sql = FileUtil.readTextFile(new File("src/test/resources/queries/default/create_table_partition_by_column.sql"));
    Expr expr = parseQuery(sql);
    assertEquals(OpType.CreateTable, expr.getType());
    CreateTable createTable = (CreateTable) expr;
    assertTrue(createTable.hasPartition());
    assertEquals(CreateTable.PartitionType.COLUMN, createTable.getPartitionMethod().getPartitionType());
    CreateTable.ColumnPartition columnPartition = createTable.getPartitionMethod();
    assertEquals(3, columnPartition.getColumns().length);
    assertEquals("col3", columnPartition.getColumns()[0].getColumnName());
    assertEquals("col4", columnPartition.getColumns()[1].getColumnName());
    assertEquals("col5", columnPartition.getColumns()[2].getColumnName());
  }
View Full Code Here

Examples of org.apache.tajo.algebra.CreateTable

  }

  @Override
  public Expr visitCreate_table_statement(SQLParser.Create_table_statementContext ctx) {
    String tableName = ctx.table_name().getText();
    CreateTable createTable = new CreateTable(tableName, checkIfExist(ctx.if_not_exists()));

    if (checkIfExist(ctx.EXTERNAL())) {
      createTable.setExternal();

      ColumnDefinition[] elements = getDefinitions(ctx.table_elements());
      String fileType = ctx.file_type.getText();
      String path = stripQuote(ctx.path.getText());

      createTable.setTableElements(elements);
      createTable.setStorageType(fileType);
      createTable.setLocation(path);
    } else {
      if (checkIfExist(ctx.table_elements())) {
        ColumnDefinition[] elements = getDefinitions(ctx.table_elements());
        createTable.setTableElements(elements);
      }

      if (checkIfExist(ctx.USING())) {
        String fileType = ctx.file_type.getText();
        createTable.setStorageType(fileType);
      }

      if (checkIfExist(ctx.query_expression())) {
        Expr subquery = visitQuery_expression(ctx.query_expression());
        createTable.setSubQuery(subquery);
      }
    }

    if (checkIfExist(ctx.param_clause())) {
      Map<String, String> params = escapeTableMeta(getParams(ctx.param_clause()));
      createTable.setParams(params);
    }

    if (checkIfExist(ctx.table_partitioning_clauses())) {
      PartitionMethodDescExpr partitionMethodDesc =
          parseTablePartitioningClause(ctx.table_partitioning_clauses());
      createTable.setPartitionMethod(partitionMethodDesc);
    }
    return createTable;
  }
View Full Code Here

Examples of org.h2.command.ddl.CreateTable

            // (...) not logged
            schemaName = session.getCurrentSchemaName();
            globalTemp = false;
        }
        Schema schema = getSchema();
        CreateTable command = new CreateTable(session, schema);
        command.setPersistIndexes(persistIndexes);
        command.setTemporary(temp);
        command.setGlobalTemporary(globalTemp);
        command.setIfNotExists(ifNotExists);
        command.setTableName(tableName);
        command.setComment(readCommentIf());
        if (readIf("(")) {
            if (!readIf(")")) {
                do {
                    DefineCommand c = parseAlterTableAddConstraintIf(tableName, schema);
                    if (c != null) {
                        command.addConstraintCommand(c);
                    } else {
                        String columnName = readColumnIdentifier();
                        Column column = parseColumnForTable(columnName, true);
                        if (column.isAutoIncrement() && column.isPrimaryKey()) {
                            column.setPrimaryKey(false);
                            IndexColumn[] cols = { new IndexColumn() };
                            cols[0].columnName = column.getName();
                            AlterTableAddConstraint pk = new AlterTableAddConstraint(session, schema, false);
                            pk.setType(CommandInterface.ALTER_TABLE_ADD_CONSTRAINT_PRIMARY_KEY);
                            pk.setTableName(tableName);
                            pk.setIndexColumns(cols);
                            command.addConstraintCommand(pk);
                        }
                        command.addColumn(column);
                        String constraintName = null;
                        if (readIf("CONSTRAINT")) {
                            constraintName = readColumnIdentifier();
                        }
                        if (readIf("PRIMARY")) {
                            read("KEY");
                            boolean hash = readIf("HASH");
                            IndexColumn[] cols = { new IndexColumn() };
                            cols[0].columnName = column.getName();
                            AlterTableAddConstraint pk = new AlterTableAddConstraint(session, schema, false);
                            pk.setPrimaryKeyHash(hash);
                            pk.setType(CommandInterface.ALTER_TABLE_ADD_CONSTRAINT_PRIMARY_KEY);
                            pk.setTableName(tableName);
                            pk.setIndexColumns(cols);
                            command.addConstraintCommand(pk);
                            if (readIf("AUTO_INCREMENT")) {
                                parseAutoIncrement(column);
                            }
                        } else if (readIf("UNIQUE")) {
                            AlterTableAddConstraint unique = new AlterTableAddConstraint(session, schema, false);
                            unique.setConstraintName(constraintName);
                            unique.setType(CommandInterface.ALTER_TABLE_ADD_CONSTRAINT_UNIQUE);
                            IndexColumn[] cols = { new IndexColumn() };
                            cols[0].columnName = columnName;
                            unique.setIndexColumns(cols);
                            unique.setTableName(tableName);
                            command.addConstraintCommand(unique);
                        }
                        if (readIf("NOT")) {
                            read("NULL");
                            column.setNullable(false);
                        } else {
                            readIf("NULL");
                        }
                        if (readIf("CHECK")) {
                            Expression expr = readExpression();
                            column.addCheckConstraint(session, expr);
                        }
                        if (readIf("REFERENCES")) {
                            AlterTableAddConstraint ref = new AlterTableAddConstraint(session, schema, false);
                            ref.setConstraintName(constraintName);
                            ref.setType(CommandInterface.ALTER_TABLE_ADD_CONSTRAINT_REFERENTIAL);
                            IndexColumn[] cols = { new IndexColumn() };
                            cols[0].columnName = columnName;
                            ref.setIndexColumns(cols);
                            ref.setTableName(tableName);
                            parseReferences(ref, schema, tableName);
                            command.addConstraintCommand(ref);
                        }
                    }
                } while (readIfMore());
            }
        }
        if (readIf("ENGINE")) {
            command.setTableEngine(readUniqueIdentifier());
        }
        if (temp) {
            if (readIf("ON")) {
                read("COMMIT");
                if (readIf("DROP")) {
                    command.setOnCommitDrop();
                } else if (readIf("DELETE")) {
                    read("ROWS");
                    command.setOnCommitTruncate();
                }
            } else if (readIf("NOT")) {
                if (readIf("PERSISTENT")) {
                    command.setPersistData(false);
                } else {
                    read("LOGGED");
                }
            }
            if (readIf("TRANSACTIONAL")) {
                command.setTransactional(true);
            }
        } else if (!persistIndexes && readIf("NOT")) {
            read("PERSISTENT");
            command.setPersistData(false);
        }
        if (readIf("HIDDEN")) {
            command.setHidden(true);
        }
        if (readIf("AS")) {
            if (readIf("SORTED")) {
                command.setSortedInsertMode(true);
            }
            command.setQuery(parseSelect());
        }
        return command;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.