/** * Returns a {@code String} containing CQL queries representing this * keyspace and the table it contains. * * In other words, this method returns the queries that would allow to * recreate the schema of this keyspace, along with all its table. * * Note that the returned String is formatted to be human readable (for * some definition of human readable at least). * * @return the CQL queries representing this keyspace schema as a {code * String}. */ public String exportAsString() { StringBuilder sb = new StringBuilder(); sb.append(asCQLQuery()).append('\n'); for (TableMetadata tm : tables.values()) sb.append('\n').append(tm.exportAsString()).append('\n'); return sb.toString(); }
private Object[] populateTableMetaData(KeyspaceMetadata ks, TableMetadata t) { return new Object[]{ null, // TABLE_CAT ks.getName(), // TABLE_SCHEM t.getName(), // TABLE_NAME "TABLE", // TABLE_TYPE new StringBuilder().append("ID: [").append(t.getId()) .append("] \nDDL: \n").append(t.exportAsString()) .toString(), // REMARKS null, // TYPE_CAT null, // TYPE_SCHEM null, // TYPE_NAME null, // SELF_REFERENCING_COL_NAME "USER" // REF_GENERATION }; }
/** * Returns a {@code String} containing CQL queries representing this * keyspace and the user types and tables it contains. * <p/> * In other words, this method returns the queries that would allow to * recreate the schema of this keyspace, along with all its user * types/tables. * <p/> * Note that the returned String is formatted to be human readable (for * some definition of human readable at least). * * @return the CQL queries representing this keyspace schema as a {code * String}. */ public String exportAsString() { StringBuilder sb = new StringBuilder(); sb.append(asCQLQuery()).append('\n'); for (UserType udt : userTypes.values()) sb.append('\n').append(udt.exportAsString()).append('\n'); for (TableMetadata tm : tables.values()) sb.append('\n').append(tm.exportAsString()).append('\n'); for (FunctionMetadata fm : functions.values()) sb.append('\n').append(fm.exportAsString()).append('\n'); for (AggregateMetadata am : aggregates.values()) sb.append('\n').append(am.exportAsString()).append('\n'); return sb.toString(); }
/** * Returns a {@code String} containing CQL queries representing this * keyspace and the user types and tables it contains. * <p/> * In other words, this method returns the queries that would allow to * recreate the schema of this keyspace, along with all its user * types/tables. * <p/> * Note that the returned String is formatted to be human readable (for * some definition of human readable at least). * * @return the CQL queries representing this keyspace schema as a {code * String}. */ public String exportAsString() { StringBuilder sb = new StringBuilder(); sb.append(asCQLQuery()).append('\n'); for (UserType udt : userTypes.values()) sb.append('\n').append(udt.exportAsString()).append('\n'); for (TableMetadata tm : tables.values()) sb.append('\n').append(tm.exportAsString()).append('\n'); for (FunctionMetadata fm : functions.values()) sb.append('\n').append(fm.exportAsString()).append('\n'); for (AggregateMetadata am : aggregates.values()) sb.append('\n').append(am.exportAsString()).append('\n'); return sb.toString(); }
/** * Returns a {@code String} containing CQL queries representing this * keyspace and the user types and tables it contains. * <p/> * In other words, this method returns the queries that would allow to * recreate the schema of this keyspace, along with all its user * types/tables. * <p/> * Note that the returned String is formatted to be human readable (for * some definition of human readable at least). * * @return the CQL queries representing this keyspace schema as a {code * String}. */ public String exportAsString() { StringBuilder sb = new StringBuilder(); sb.append(asCQLQuery()).append('\n'); for (UserType udt : userTypes.values()) sb.append('\n').append(udt.exportAsString()).append('\n'); for (TableMetadata tm : tables.values()) sb.append('\n').append(tm.exportAsString()).append('\n'); for (FunctionMetadata fm : functions.values()) sb.append('\n').append(fm.exportAsString()).append('\n'); for (AggregateMetadata am : aggregates.values()) sb.append('\n').append(am.exportAsString()).append('\n'); return sb.toString(); }
/** * Validates that the row-level access definition is properly exposed when set on a table. * * @jira_ticket JAVA-1335 * @test_category metadata */ @Test(groups = "short") public void should_show_RLAC_for_table() throws Exception { session() .execute( String.format( "CREATE TABLE %s.reports (\n" + " report_user text,\n" + " report_number int,\n" + " report_month int,\n" + " report_year int,\n" + " report_text text,\n" + " PRIMARY KEY (report_user, report_number)\n" + ");", keyspace)); String rlacCql = String.format("RESTRICT ROWS ON %s.reports USING report_user;", keyspace); session().execute(rlacCql); TableMetadata table = cluster().getMetadata().getKeyspace(keyspace).getTable("reports"); assertThat(table.getOptions().getExtensions()).containsKey("DSE_RLACA"); assertThat(table.exportAsString()).contains(rlacCql); }
result = Result.createExecutionErrorResult("TABLE " + tableName + " was not found"); } else { result = CommandResult.createCommandResult(tableInfo.exportAsString());
assertThat(tm.getOptions()).isNull(); assertThat(tm.getKeyspace()).isEqualTo(km); assertThat(tm.exportAsString()) .isEqualTo( "/* VIRTUAL TABLE system_views.sstable_tasks (\n"