Codota Logo
AlterTable
Code IndexAdd Codota to your IDE (free)

How to use
AlterTable
in
com.englishtown.vertx.cassandra.tablebuilder

Best Java code snippets using com.englishtown.vertx.cassandra.tablebuilder.AlterTable (Showing top 11 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Point p =
  • Codota Iconnew Point(x, y)
  • Codota Iconnew Point()
  • Codota IconMouseEvent e;e.getPoint()
  • Smart code suggestions by Codota
}
origin: com.englishtown.vertx/vertx-cassandra

/**
 * Returns a {@link com.englishtown.vertx.cassandra.tablebuilder.AlterTable} builder
 *
 * @param keyspace the keyspace for the table to create
 * @param table    the table name
 * @return the create table builder
 */
public static AlterTable alter(String keyspace, String table) {
  return new AlterTable(keyspace, table);
}
origin: com.englishtown/vertx-mod-cassandra

/**
 * Returns a {@link com.datastax.driver.core.BatchStatement} with all the alter statements necessary to modify an existing table.
 * <p>
 * Note: Columns will only be added or modified, not dropped.
 *
 * @param existing the existing table to be modified
 * @param desired  the desired end result
 * @return a set of statements to modify an existing table
 */
public static List<AlterTable> alter(TableMetadata existing, CreateTable desired) {
  List<AlterTable> results = new ArrayList<>();
  for (BuiltTableStatement.Column column : desired.getColumns()) {
    ColumnMetadata columnMetadata = existing.getColumn(column.getName());
    if (columnMetadata == null) {
      results.add(alter(desired.getKeyspace(), desired.getTable()).addColumn(column.getName(), column.getType()));
    } else if (!columnMetadata.getType().toString().equalsIgnoreCase(column.getType())) {
      if (columnMetadata.isStatic()) {
        throw new IllegalArgumentException("A static column cannot have its type modified");
      }
      results.add(alter(desired.getKeyspace(), desired.getTable()).alterColumn(column.getName(), column.getType()));
    }
  }
  return results;
}
origin: ef-labs/vertx-cassandra

@Test
public void testAdd() throws Exception {
  AlterTable alter = TableBuilder.alter("test_keyspace", "test_table")
      .addColumn("col1", "text");
  String cql = alter.getQueryString();
  assertEquals("ALTER TABLE test_keyspace.test_table ADD col1 text", cql);
}
origin: ef-labs/vertx-cassandra

@Test
public void testAlter() throws Exception {
  AlterTable alter = TableBuilder.alter("test_keyspace", "test_table")
      .alterColumn("col1", "text");
  String cql = alter.getQueryString();
  assertEquals("ALTER TABLE test_keyspace.test_table ALTER col1 TYPE text", cql);
}
origin: ef-labs/vertx-cassandra

  @Test
  public void testRename() throws Exception {
    AlterTable alter = TableBuilder.alter("test_keyspace", "test_table")
        .renameColumn("col1", "col2");

    String cql = alter.getQueryString();
    assertEquals("ALTER TABLE test_keyspace.test_table RENAME col1 TO col2", cql);
  }
}
origin: ef-labs/vertx-cassandra

@Test
public void testDrop() throws Exception {
  AlterTable alter = TableBuilder.alter("test_keyspace", "test_table")
      .dropColumn("col1");
  String cql = alter.getQueryString();
  assertEquals("ALTER TABLE test_keyspace.test_table DROP col1", cql);
}
origin: ef-labs/vertx-cassandra

@Test
public void testAlter() throws Exception {
  CreateTable desired = TableBuilder.create("test_keyspace", "test_table")
      .column("col1", "text")
      .column("col2", "bigint")
      .column("col3", "int")
      .column("col4", "text")
      .primaryKey("col1");
  List<AlterTable> statements = TableBuilder.alter(existing, desired);
  assertEquals(3, statements.size());
  assertEquals("ALTER TABLE test_keyspace.test_table ALTER col2 TYPE bigint", statements.get(0).toString());
  assertEquals("ALTER TABLE test_keyspace.test_table ADD col3 int", statements.get(1).toString());
  assertEquals("ALTER TABLE test_keyspace.test_table ADD col4 text", statements.get(2).toString());
}
origin: com.englishtown.vertx/vertx-cassandra

/**
 * Returns a {@link com.datastax.driver.core.BatchStatement} with all the alter statements necessary to modify an existing table.
 * <p>
 * Note: Columns will only be added or modified, not dropped.
 *
 * @param existing the existing table to be modified
 * @param desired  the desired end result
 * @return a set of statements to modify an existing table
 */
public static List<AlterTable> alter(AbstractTableMetadata existing, CreateTable desired) {
  List<AlterTable> results = new ArrayList<>();
  for (BuiltTableStatement.Column column : desired.getColumns()) {
    ColumnMetadata columnMetadata = existing.getColumn(column.getName());
    if (columnMetadata == null) {
      results.add(alter(desired.getKeyspace(), desired.getTable()).addColumn(column.getName(), column.getType()));
    } else if (!columnMetadata.getType().toString().equalsIgnoreCase(column.getType())) {
      if (columnMetadata.isStatic()) {
        throw new IllegalArgumentException("A static column cannot have its type modified");
      }
      results.add(alter(desired.getKeyspace(), desired.getTable()).alterColumn(column.getName(), column.getType()));
    }
  }
  return results;
}
origin: ef-labs/vertx-cassandra

/**
 * Returns a {@link com.datastax.driver.core.BatchStatement} with all the alter statements necessary to modify an existing table.
 * <p>
 * Note: Columns will only be added or modified, not dropped.
 *
 * @param existing the existing table to be modified
 * @param desired  the desired end result
 * @return a set of statements to modify an existing table
 */
public static List<AlterTable> alter(AbstractTableMetadata existing, CreateTable desired) {
  List<AlterTable> results = new ArrayList<>();
  for (BuiltTableStatement.Column column : desired.getColumns()) {
    ColumnMetadata columnMetadata = existing.getColumn(column.getName());
    if (columnMetadata == null) {
      results.add(alter(desired.getKeyspace(), desired.getTable()).addColumn(column.getName(), column.getType()));
    } else if (!columnMetadata.getType().toString().equalsIgnoreCase(column.getType())) {
      if (columnMetadata.isStatic()) {
        throw new IllegalArgumentException("A static column cannot have its type modified");
      }
      results.add(alter(desired.getKeyspace(), desired.getTable()).alterColumn(column.getName(), column.getType()));
    }
  }
  return results;
}
origin: com.englishtown/vertx-mod-cassandra

/**
 * Returns a {@link com.englishtown.vertx.cassandra.tablebuilder.AlterTable} builder
 *
 * @param keyspace the keyspace for the table to create
 * @param table    the table name
 * @return the create table builder
 */
public static AlterTable alter(String keyspace, String table) {
  return new AlterTable(keyspace, table);
}
origin: ef-labs/vertx-cassandra

/**
 * Returns a {@link com.englishtown.vertx.cassandra.tablebuilder.AlterTable} builder
 *
 * @param keyspace the keyspace for the table to create
 * @param table    the table name
 * @return the create table builder
 */
public static AlterTable alter(String keyspace, String table) {
  return new AlterTable(keyspace, table);
}
com.englishtown.vertx.cassandra.tablebuilderAlterTable

Javadoc

ALTER TABLE CQL3 statement builder

Most used methods

  • addColumn
  • alterColumn
  • <init>
  • dropColumn
  • getQueryString
  • renameColumn
  • toString

Popular in Java

  • Creating JSON documents from java classes using gson
  • getApplicationContext (Context)
  • orElseThrow (Optional)
  • runOnUiThread (Activity)
  • Time (java.sql)
    Java representation of an SQL TIME value. Provides utilities to format and parse the time's represen
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • Dictionary (java.util)
    The Dictionary class is the abstract parent of any class, such as Hashtable, which maps keys to valu
  • Timer (java.util)
    A facility for threads to schedule tasks for future execution in a background thread. Tasks may be s
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now