use of org.apache.ignite.schema.definition.ColumnDefinition in project ignite-3 by apache.
the class SchemaDescriptorConverterTest method getBuilder.
/**
* Get TableSchemaBuilder with default table.
*
* @param nullable If all columns should be nullable.
* @param withPk If builder should contains primary key index.
* @return TableSchemaBuilder.
*/
private TableDefinitionBuilder getBuilder(boolean nullable, boolean withPk) {
Function<ColumnDefinitionBuilder, ColumnDefinition> postProcess = builder -> builder.asNullable(nullable).build();
TableDefinitionBuilder res = SchemaBuilders.tableBuilder("SCHEMA", "TABLE").columns(SchemaBuilders.column("ID", ColumnType.UUID).build(), postProcess.apply(SchemaBuilders.column("INT8", ColumnType.INT8)), postProcess.apply(SchemaBuilders.column("INT16", ColumnType.INT16)), postProcess.apply(SchemaBuilders.column("INT32", ColumnType.INT32)), postProcess.apply(SchemaBuilders.column("INT64", ColumnType.INT64)), postProcess.apply(SchemaBuilders.column("FLOAT", ColumnType.FLOAT)), postProcess.apply(SchemaBuilders.column("DOUBLE", ColumnType.DOUBLE)), postProcess.apply(SchemaBuilders.column("UUID", ColumnType.UUID)), postProcess.apply(SchemaBuilders.column("STRING", ColumnType.string())), postProcess.apply(SchemaBuilders.column("STRING_FS10", ColumnType.stringOf(10))), postProcess.apply(SchemaBuilders.column("BLOB", ColumnType.blobOf())), postProcess.apply(SchemaBuilders.column("BLOB_FS10", ColumnType.blobOf(10))), postProcess.apply(SchemaBuilders.column("DECIMAL", ColumnType.decimalOf(1, 1))), postProcess.apply(SchemaBuilders.column("NUMBER", ColumnType.numberOf(12))), postProcess.apply(SchemaBuilders.column("BITMASK_FS10", ColumnType.bitmaskOf(10))));
if (withPk) {
res.withPrimaryKey("ID");
}
return res;
}
use of org.apache.ignite.schema.definition.ColumnDefinition in project ignite-3 by apache.
the class ColumnDefinitionBuilderTest method testCreateColumn.
/**
* Check column parameters.
*/
@Test
public void testCreateColumn() {
ColumnDefinitionBuilder builder = SchemaBuilders.column("TEST", ColumnType.DOUBLE);
ColumnDefinition col = builder.withDefaultValueExpression("NOW()").build();
assertEquals("TEST", col.name());
assertEquals(ColumnType.DOUBLE, col.type());
assertEquals("NOW()", col.defaultValue());
assertFalse(col.nullable());
}
Aggregations