Search in sources :

Example 1 with GreenplumCSV

use of org.greenplum.pxf.api.model.GreenplumCSV in project pxf by greenplum-db.

the class S3SelectAccessor method getCSVInput.

/**
 * Returns a {@link com.amazonaws.services.s3.model.CSVInput}
 * object with parsed values from the request context.
 *
 * @param context the request context
 * @return a {@link CSVInput}
 */
CSVInput getCSVInput(RequestContext context) {
    CSVInput csvInput = new CSVInput();
    GreenplumCSV csv = context.getGreenplumCSV();
    String fileHeaderInfo = context.getOption(FILE_HEADER_INFO);
    if (fileHeaderInfo != null) {
        LOG.debug("With CSV FileHeaderInfo '{}'", fileHeaderInfo);
        csvInput.setFileHeaderInfo(fileHeaderInfo);
    }
    if (csv.getDelimiter() != null) {
        LOG.debug("With CSV field delimiter '{}'", csv.getDelimiter());
        csvInput.setFieldDelimiter(csv.getDelimiter());
    }
    if (csv.getNewline() != null) {
        LOG.debug("With CSV NEWLINE '{}'", csv.getNewline());
        csvInput.setRecordDelimiter(csv.getNewline());
    }
    if (csv.getEscape() != null) {
        LOG.debug("With CSV quote escape character '{}'", csv.getEscape());
        csvInput.setQuoteEscapeCharacter(csv.getEscape());
    }
    LOG.debug("With CSV quote character '{}'", csv.getQuote());
    csvInput.setQuoteCharacter(csv.getQuote());
    return csvInput;
}
Also used : GreenplumCSV(org.greenplum.pxf.api.model.GreenplumCSV) CSVInput(com.amazonaws.services.s3.model.CSVInput)

Example 2 with GreenplumCSV

use of org.greenplum.pxf.api.model.GreenplumCSV in project pxf by greenplum-db.

the class S3SelectAccessor method getOutputSerialization.

/**
 * Returns a {@link com.amazonaws.services.s3.model.OutputSerialization}
 * object with parsed values from the request context.
 *
 * @param context the request context
 * @return a {@link OutputSerialization} object
 */
private OutputSerialization getOutputSerialization(RequestContext context) {
    GreenplumCSV csv = context.getGreenplumCSV();
    OutputSerialization outputSerialization = new OutputSerialization();
    CSVOutput csvOutput = new CSVOutput();
    csvOutput.setFieldDelimiter(csv.getDelimiter());
    csvOutput.setQuoteCharacter(csv.getQuote());
    csvOutput.setQuoteEscapeCharacter(csv.getEscape());
    csvOutput.setRecordDelimiter(csv.getNewline());
    outputSerialization.setCsv(csvOutput);
    return outputSerialization;
}
Also used : GreenplumCSV(org.greenplum.pxf.api.model.GreenplumCSV) OutputSerialization(com.amazonaws.services.s3.model.OutputSerialization) CSVOutput(com.amazonaws.services.s3.model.CSVOutput)

Aggregations

GreenplumCSV (org.greenplum.pxf.api.model.GreenplumCSV)2 CSVInput (com.amazonaws.services.s3.model.CSVInput)1 CSVOutput (com.amazonaws.services.s3.model.CSVOutput)1 OutputSerialization (com.amazonaws.services.s3.model.OutputSerialization)1