/** * Get the catalog of the truncate statement. * * @return com.stratio.crossdata.common.data.CatalogName */ public CatalogName getCatalog() { return tableName.getCatalogName(); }
/** * Constructor Class. * @param tableName The table Name * @param whereClauses A list with the conditions */ public DeleteStatement(TableName tableName, List<Filter> whereClauses) { this.tableName = tableName; if (tableName.isCompletedName()) { catalogInc = true; catalog = tableName.getCatalogName().getName(); } this.whereClauses = whereClauses; }
/** * Class Constructor. * * @param tableName The table name of the truncate statement. */ public TruncateStatement(TableName tableName) { this.tableName = tableName; this.catalogInc= tableName.isCompletedName(); this.catalog= tableName.getCatalogName().getName(); }
@Override public String toString() { StringBuilder sb = new StringBuilder("ALTER TABLE "); sb.append(Utils.toCaseSensitive(tableName.getCatalogName().getName())).append('.').append(Utils.toCaseSensitive (tableName.getName())); switch (option) {
@Override public String toString() { StringBuilder sb = new StringBuilder("UPDATE "); sb.append(Utils.toCaseSensitive(tableName.getCatalogName().getName())).append('.') .append(Utils.toCaseSensitive(tableName .getName()));
CatalogName catalogName = tableName.getCatalogName(); catalog = catalogName.getName();
int primaryKeyType, String properties, boolean ifNotExists) throws ExecutionException { this.tableName = tableMetadata.getName().getName(); this.catalog = tableMetadata.getName().getCatalogName().getName(); this.catalogInc = true; this.tableColumns = tableMetadata.getColumns();
/** * Class constructor. * * @param index The name of the index. * @param ifExists Whether it should be removed only if exists. */ public DropIndexStatement(IndexMetadata index, boolean ifExists) { if (index.getColumns() != null && !index.getColumns().isEmpty()) { this.catalogInc = true; this.catalog = index.getName().getTableName().getCatalogName().getName(); } else { String[] indexQ = index.getName().getQualifiedName().split("\\."); if (indexQ.length > 1) { this.catalog = indexQ[0]; catalogInc = true; } else { catalogInc = false; } } this.indexName = index.getName().getName(); this.ifExists = ifExists; }
private String insertBlock(Row row, TableMetadata targetTable, boolean ifNotExists) throws ExecutionException { Set<String> keys = row.getCells().keySet(); Map<ColumnName, ColumnMetadata> columnsWithMetadata = targetTable.getColumns(); Map<String, ColumnInsertCassandra> columnsMetadata = new HashMap<>(); try { for (String key : keys) { ColumnName col = new ColumnName(targetTable.getName().getCatalogName().getName(), targetTable.getName().getName(), key); columnsMetadata.put(key, new ColumnInsertCassandra(columnsWithMetadata.get(col).getColumnType(), row.getCell(key).toString(), key)); } } catch (Exception e) { throw new ExecutionException("Trying insert data in a not existing column", e); } InsertIntoStatement insertStatement = new InsertIntoStatement(targetTable, columnsMetadata, ifNotExists); return insertStatement.toString(); }
this.type = indexMetadata.getType(); this.tableName = indexMetadata.getName().getTableName().getName(); this.keyspace = indexMetadata.getName().getTableName().getCatalogName().getName(); if (keyspace != null) { this.keyspaceIncluded = true; String catalog= Utils.toCaseSensitive(indexMetadata.getName().getTableName().getCatalogName() .getName()); String table=Utils.toCaseSensitive(indexMetadata.getName().getTableName().getName());
/** * Get the Crossdata TableMetadata from a tableName that is search into cassandra table metadata. * * @param session The cassandra session. * @param tableName The table name to search. * @return A {@link com.stratio.crossdata.common.metadata.TableMetadata} . */ public static TableMetadata getTablesByTableName(Session session, TableName tableName, String cluster) throws ConnectorException { Metadata clusterMetadata = session.getCluster().getMetadata(); String ks = Utils.toCaseSensitive(tableName.getCatalogName().getName()); KeyspaceMetadata ksMetadata = clusterMetadata.getKeyspace(ks); if(clusterMetadata.getKeyspace(ks) == null){ throw new ConnectorException("Catalog " + ks + " not found"); } String tn = Utils.toCaseSensitive(tableName.getName()); com.datastax.driver.core.TableMetadata cassandraTableMetadata = ksMetadata.getTable(tn); if(ksMetadata.getTable(tn) == null){ throw new ConnectorException("Table " + ks + "." + tn + " not found"); } return getXDTableMetadata(session, cassandraTableMetadata, cluster); }
String catalog = Utils.toCaseSensitive(indexMetadata.getName().getTableName().getCatalogName().getName()); String remove = "ALTER TABLE " + catalog + "." + tableName + " DROP " + indexMetadata .getName().getName();
/** * Drop Index that was created previously. * * @param targetCluster The target cluster. * @param indexMetadata The IndexName of the index. * @throws ConnectorException */ @Override public void dropIndex(ClusterName targetCluster, IndexMetadata indexMetadata) throws ConnectorException { String remove; session = sessions.get(targetCluster.getName()); DropIndexStatement indexStatement = new DropIndexStatement(indexMetadata, false); //remove de column create for the index and automatically delete the index too String tableName = Utils.toCaseSensitive(indexMetadata.getName().getTableName().getName()); String catalog = Utils.toCaseSensitive(indexMetadata.getName().getTableName().getCatalogName().getName()); if (indexMetadata.getType() == IndexType.FULL_TEXT) { remove = "ALTER TABLE " + catalog + "." + tableName + " DROP " + Utils.toCaseSensitive(indexMetadata.getName().getName()); CassandraExecutor.execute(remove, session); } else { remove = "DROP INDEX " + catalog + "." + Utils.toCaseSensitive(indexMetadata.getName().getName()); /* String removeColumn = "ALTER TABLE " + catalog + "." + tableName + " DROP " + Utils.toCaseSensitive (indexMetadata .getName().getName());*/ CassandraExecutor.execute(remove, session); //CassandraExecutor.execute(removeColumn, session); } }
public static String getFormatType(ColumnSelector left, Selector right, Session session) { .getCatalogName().getName())).getTable( Utils.toCaseSensitive(left.getColumnName().getTableName().getName())).getColumn (Utils.toCaseSensitive(left.getColumnName().getName())).getType().getName()) {