public static ProducingResult createProducingResult(
            ResolvedSchema inputSchema, @Nullable Schema declaredSchema) {

        // no schema has been declared by the user,
        // the schema will be entirely derived from the input
        if (declaredSchema == null) {
            // go through data type to erase time attributes
            final DataType physicalDataType = inputSchema.toSourceRowDataType();
            final Schema schema = Schema.newBuilder().fromRowDataType(physicalDataType).build();
            return new ProducingResult(null, schema, null);
        }

        final List<UnresolvedColumn> declaredColumns = declaredSchema.getColumns();

        // the declared schema does not contain physical information,
        // thus, it only replaces physical columns with metadata rowtime or adds a primary key
        if (declaredColumns.stream().noneMatch(SchemaTranslator::isPhysical)) {
            // go through data type to erase time attributes
            final DataType sourceDataType = inputSchema.toSourceRowDataType();
            final DataType physicalDataType =
                    patchDataTypeWithoutMetadataRowtime(sourceDataType, declaredColumns);
            final Schema.Builder builder = Schema.newBuilder();
            builder.fromRowDataType(physicalDataType);
            builder.fromSchema(declaredSchema);
            return new ProducingResult(null, builder.build(), null);
        }

        return new ProducingResult(null, declaredSchema, null);
    }
@Test
    void testOutputToNoSchema() {
        final ResolvedSchema tableSchema =
                ResolvedSchema.of(
                        Column.physical("id", BIGINT()),
                        Column.metadata("rowtime", TIMESTAMP_LTZ(3), null, false),
                        Column.physical("name", STRING()));

        final ProducingResult result = SchemaTranslator.createProducingResult(tableSchema, null);

        assertThat(result.getProjections()).isEmpty();

        assertThat(result.getSchema())
                .isEqualTo(
                        Schema.newBuilder()
                                .column("id", BIGINT())
                                .column("rowtime", TIMESTAMP_LTZ(3)) // becomes physical
                                .column("name", STRING())
                                .build());

        assertThat(result.getPhysicalDataType()).isEmpty();
    }