void generateTargetColumns()

in c3r-cli/src/main/java/com/amazonaws/c3r/io/schema/InteractiveSchemaGenerator.java [604:640]


    void generateTargetColumns(final ColumnHeader sourceHeader) {
        final String columnReference = SchemaGeneratorUtils.columnReference(sourceHeader, getCurrentSourceColumnPosition());

        final int defaultTargetColumnCount = 1;
        consoleOutput.println("\nExamining source " + columnReference + ".");
        final boolean isSupportedType = getCurrentSourceColumnDataType() != ClientDataType.UNKNOWN;

        final int targetColumnCount;
        if (isSupportedType || allowCleartextColumns) {
            if (!isSupportedType) {
                // Warn that this column can only appear as cleartext
                consoleOutput.println(SchemaGeneratorUtils.unsupportedTypeWarning(sourceHeader, getCurrentSourceColumnPosition()));
            }
            targetColumnCount = repeatUntilNotNull(() ->
                    promptNonNegativeInt(
                            "Number of target columns from source " + columnReference,
                            defaultTargetColumnCount,
                            Limits.ENCRYPTED_OUTPUT_COLUMN_COUNT_MAX));
        } else {
            // This column cannot even appear as cleartext because of collaboration settings,
            // so warn that it will be skipped
            consoleOutput.println(SchemaGeneratorUtils.unsupportedTypeSkippingColumnWarning(
                    sourceHeader,
                    getCurrentSourceColumnPosition()));
            unsupportedTypeColumnCount++;
            targetColumnCount = 0;
        }

        // schemas derived from the current source column are stored in this array
        final var targetSchemasFromSourceColumn = new ArrayList<ColumnSchema>(targetColumnCount);
        // 1-based indices since `i` is only used really to count and print user messages if `targetColumnCount > 1`
        // and `1 of N` looks better than `0 of N-1` in printed messages.
        for (int i = 1; i <= targetColumnCount; i++) {
            targetSchemasFromSourceColumn.add(promptColumnInfo(sourceHeader, i, targetColumnCount));
        }
        generatedColumnSchemas.add(targetSchemasFromSourceColumn);
    }