use of org.apache.ignite.schema.definition.TableDefinition in project ignite-3 by apache.
the class TableManagerTest method testDropTable.
/**
* Tests drop a table through public API.
*
* @throws Exception If failed.
*/
@Test
public void testDropTable() throws Exception {
TableDefinition scmTbl = SchemaBuilders.tableBuilder("PUBLIC", DYNAMIC_TABLE_FOR_DROP_NAME).columns(SchemaBuilders.column("key", ColumnType.INT64).build(), SchemaBuilders.column("val", ColumnType.INT64).asNullable(true).build()).withPrimaryKey("key").build();
mockManagersAndCreateTable(scmTbl, tblManagerFut);
TableManager tableManager = tblManagerFut.join();
tableManager.dropTable(scmTbl.canonicalName());
assertNull(tableManager.table(scmTbl.canonicalName()));
assertEquals(0, tableManager.tables().size());
}
use of org.apache.ignite.schema.definition.TableDefinition in project ignite-3 by apache.
the class PlatformTestNodeRunner method main.
/**
* Entry point.
*
* @param args Args.
*/
public static void main(String[] args) throws Exception {
System.out.println("Starting test node runner...");
for (int i = 0; i < args.length; i++) {
System.out.println("Arg " + i + ": " + args[i]);
}
if (args.length > 0 && "dry-run".equals(args[0])) {
System.out.println("Dry run succeeded.");
return;
}
IgniteUtils.deleteIfExists(BASE_PATH);
Files.createDirectories(BASE_PATH);
List<Ignite> startedNodes = new ArrayList<>();
nodesBootstrapCfg.forEach((nodeName, configStr) -> startedNodes.add(IgnitionManager.start(nodeName, configStr, BASE_PATH.resolve(nodeName))));
var keyCol = "key";
var valCol = "val";
TableDefinition schTbl = SchemaBuilders.tableBuilder(SCHEMA_NAME, TABLE_NAME).columns(SchemaBuilders.column(keyCol, ColumnType.INT64).build(), SchemaBuilders.column(valCol, ColumnType.string()).asNullable(true).build()).withPrimaryKey(keyCol).build();
startedNodes.get(0).tables().createTable(schTbl.canonicalName(), tblCh -> SchemaConfigurationConverter.convert(schTbl, tblCh).changeReplicas(1).changePartitions(10));
String ports = startedNodes.stream().map(n -> String.valueOf(getPort((IgniteImpl) n))).collect(Collectors.joining(","));
System.out.println("THIN_CLIENT_PORTS=" + ports);
Thread.sleep(RUN_TIME_MINUTES * 60_000);
System.out.println("Exiting after " + RUN_TIME_MINUTES + " minutes.");
}
use of org.apache.ignite.schema.definition.TableDefinition in project ignite-3 by apache.
the class ItDataSchemaSyncTest method createTable.
/**
* Creates a table with the passed name on the specific schema.
*
* @param node Cluster node.
* @param schemaName Schema name.
* @param shortTableName Table name.
*/
protected void createTable(Ignite node, String schemaName, String shortTableName) {
// Create table on node 0.
TableDefinition schTbl1 = SchemaBuilders.tableBuilder(schemaName, shortTableName).columns(SchemaBuilders.column("key", ColumnType.INT64).build(), SchemaBuilders.column("valInt", ColumnType.INT32).asNullable(true).build(), SchemaBuilders.column("valStr", ColumnType.string()).withDefaultValueExpression("default").build()).withPrimaryKey("key").build();
node.tables().createTable(schTbl1.canonicalName(), tblCh -> convert(schTbl1, tblCh).changeReplicas(2).changePartitions(10));
}
use of org.apache.ignite.schema.definition.TableDefinition in project ignite-3 by apache.
the class ItJdbcResultSetSelfTest method beforeClass.
@BeforeAll
public static void beforeClass() {
Ignite ignite = clusterNodes.get(0);
List<ColumnDefinition> columns = new ArrayList<>();
columns.add(SchemaBuilders.column("ID", ColumnType.INT32).build());
columns.add(SchemaBuilders.column("BOOLVAL", ColumnType.INT8).asNullable(true).build());
columns.add(SchemaBuilders.column("BYTEVAL", ColumnType.INT8).asNullable(true).build());
columns.add(SchemaBuilders.column("SHORTVAL", ColumnType.INT16).asNullable(true).build());
columns.add(SchemaBuilders.column("INTVAL", ColumnType.INT32).asNullable(true).build());
columns.add(SchemaBuilders.column("LONGVAL", ColumnType.INT64).asNullable(true).build());
columns.add(SchemaBuilders.column("FLOATVAL", ColumnType.FLOAT).asNullable(true).build());
columns.add(SchemaBuilders.column("DOUBLEVAL", ColumnType.DOUBLE).asNullable(true).build());
columns.add(SchemaBuilders.column("BIGVAL", ColumnType.decimalOf()).asNullable(true).build());
columns.add(SchemaBuilders.column("STRVAL", ColumnType.string()).asNullable(true).build());
columns.add(SchemaBuilders.column("ARRVAL", ColumnType.blobOf()).asNullable(true).build());
columns.add(SchemaBuilders.column("DATEVAL", ColumnType.DATE).asNullable(true).build());
columns.add(SchemaBuilders.column("TIMEVAL", ColumnType.TemporalColumnType.time()).asNullable(true).build());
columns.add(SchemaBuilders.column("TSVAL", ColumnType.TemporalColumnType.timestamp()).asNullable(true).build());
columns.add(SchemaBuilders.column("URLVAL", ColumnType.blobOf()).asNullable(true).build());
TableDefinition personTableDef = SchemaBuilders.tableBuilder("PUBLIC", "TEST").columns(columns).withPrimaryKey("ID").build();
ignite.tables().createTable(personTableDef.canonicalName(), (tableChange) -> SchemaConfigurationConverter.convert(personTableDef, tableChange).changeReplicas(1).changePartitions(10));
RecordView<Tuple> tupleRecordView = ignite.tables().table("PUBLIC.TEST").recordView();
Tuple tuple = Tuple.create();
tuple.set("BOOLVAL", (byte) 1).set("BYTEVAL", (byte) 1).set("SHORTVAL", (short) 1).set("INTVAL", 1).set("LONGVAL", 1L).set("FLOATVAL", 1.0f).set("DOUBLEVAL", 1.0d).set("BIGVAL", new BigDecimal("1")).set("STRVAL", "1").set("DATEVAL", LocalDate.parse("1901-02-01")).set("TIMEVAL", LocalTime.parse("01:01:01")).set("TSVAL", Instant.ofEpochMilli(1));
tupleRecordView.insert(null, tuple.set("ID", 1));
tupleRecordView.insert(null, tuple.set("ID", 2));
}
use of org.apache.ignite.schema.definition.TableDefinition in project ignite-3 by apache.
the class AbstractSchemaChangeTest method createTable.
/**
* Creates tables.
*
* @param nodes Cluster nodes.
*/
protected static void createTable(List<Ignite> nodes) {
// Create table on node 0.
TableDefinition schTbl1 = SchemaBuilders.tableBuilder("PUBLIC", "tbl1").columns(SchemaBuilders.column("key", ColumnType.INT64).build(), SchemaBuilders.column("valInt", ColumnType.INT32).asNullable(true).build(), SchemaBuilders.column("valBlob", ColumnType.blobOf()).asNullable(true).build(), SchemaBuilders.column("valDecimal", ColumnType.decimalOf()).asNullable(true).build(), SchemaBuilders.column("valBigInt", ColumnType.numberOf()).asNullable(true).build(), SchemaBuilders.column("valStr", ColumnType.string()).withDefaultValueExpression("default").build()).withPrimaryKey("key").build();
nodes.get(0).tables().createTable(schTbl1.canonicalName(), tblCh -> convert(schTbl1, tblCh).changeReplicas(1).changePartitions(10));
}
Aggregations