congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
TableBuilder.alter
Code IndexAdd Tabnine to your IDE (free)

How to use
alter
method
in
com.englishtown.vertx.cassandra.tablebuilder.TableBuilder

Best Java code snippets using com.englishtown.vertx.cassandra.tablebuilder.TableBuilder.alter (Showing top 9 results out of 315)

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: 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: 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 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 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 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: ef-labs/vertx-cassandra

List<AlterTable> alterStatements = TableBuilder.alter(tableMetadata, createTable);
com.englishtown.vertx.cassandra.tablebuilderTableBuilderalter

Javadoc

Returns a com.datastax.driver.core.BatchStatement with all the alter statements necessary to modify an existing table.

Note: Columns will only be added or modified, not dropped.

Popular methods of TableBuilder

  • create
    Returns a com.englishtown.vertx.cassandra.tablebuilder.CreateTable builder
  • drop
    Returns a com.englishtown.vertx.cassandra.tablebuilder.DropTable statement

Popular in Java

  • Creating JSON documents from java classes using gson
  • getSharedPreferences (Context)
  • getResourceAsStream (ClassLoader)
  • setRequestProperty (URLConnection)
  • FileInputStream (java.io)
    An input stream that reads bytes from a file. File file = ...finally if (in != null) in.clos
  • Time (java.sql)
    Java representation of an SQL TIME value. Provides utilities to format and parse the time's represen
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • JList (javax.swing)
  • Top 17 PhpStorm Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now