Java Code Examples for io.debezium.relational.Column

Following code examples demonstrate how to use io.debezium.relational.Column from debezium. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use io.debezium.relational.Column and various code implementation of this class.
Example 1
Project : debezium Source File : TableChanges.java View Source Code on GitHub

        private Document toDocument(Column column) {
            Document document = Document.create();

            document.setString("name", column.name());
            document.setNumber("jdbcType", column.jdbcType());

            if (column.nativeType() != Column.UNSET_INT_VALUE) {
                document.setNumber("nativeType", column.nativeType());
            }

            document.setString("typeName", column.typeName());
            document.setString("typeExpression", column.typeExpression());
            document.setString("charsetName", column.charsetName());

            if (column.length() != Column.UNSET_INT_VALUE) {
                document.setNumber("length", column.length());
            }

            column.scale().ifPresent(s -> document.setNumber("scale", s));

            document.setNumber("position", column.position());
            document.setBoolean("optional", column.isOptional());
            document.setBoolean("autoIncremented", column.isAutoIncremented());
            document.setBoolean("generated", column.isGenerated());

            return document;
        }
			
Example 2
Project : debezium Source File : PropagateSourceTypeToSchemaParameterTest.java View Source Code on GitHub

    public void shouldAddTypeInformation() {
        int length = 255;
        Column column = Column.editor()
            .name("col")
            .type("VARCHAR")
            .jdbcType(Types.VARCHAR)
            .length(length)
            .create();

        SchemaBuilder schemaBuilder = SchemaBuilder.string();
        new PropagateSourceTypeToSchemaParameter().alterFieldSchema(column, schemaBuilder);

        assertThat(schemaBuilder.parameters().get("__debezium.source.column.type")).isEqualTo("VARCHAR");
        assertThat(schemaBuilder.parameters().get("__debezium.source.column.length")).isEqualTo(String.valueOf(length));
    }
			
Example 3
Project : debezium Source File : PropagateSourceTypeToSchemaParameter.java View Source Code on GitHub

    public void alterFieldSchema(Column column, SchemaBuilder schemaBuilder) {
       schemaBuilder.parameter(TYPE_NAME_PARAMETER_KEY, column.typeName().toUpperCase(Locale.ENGLISH));

       if (column.length() != Column.UNSET_INT_VALUE) {
           schemaBuilder.parameter(TYPE_LENGTH_PARAMETER_KEY, String.valueOf(column.length()));
       }
    }