@Test public void testFailsToParseNullDataSource() { thrown.expect(NullPointerException.class); RequestContext context = new RequestContext(); new S3SelectAccessor().generateBaseCSVRequest(context); }
SelectObjectContentRequest generateBaseCSVRequest(RequestContext context) { InputSerialization inputSerialization = getInputSerialization(context); String fileHeaderInfo = context.getOption(FILE_HEADER_INFO); boolean usePositionToIdentifyColumn = inputSerialization.getCsv() != null && (StringUtils.isBlank(fileHeaderInfo) || !StringUtils.equalsIgnoreCase(FILE_HEADER_INFO_USE, fileHeaderInfo)); String query = null; try { S3SelectQueryBuilder queryBuilder = new S3SelectQueryBuilder(context, usePositionToIdentifyColumn); query = queryBuilder.buildSelectQuery(); } catch (SQLException e) { LOG.error("Unable to build select query for filter string {}", context.getFilterString()); } LOG.trace("Select query: {}", query); SelectObjectContentRequest request = new SelectObjectContentRequest(); request.setBucketName(name.getHost()); request.setKey(StringUtils.removeStart(name.getPath(), "/")); request.setExpression(query); request.setExpressionType(ExpressionType.SQL); LOG.debug("With bucket name '{}'", request.getBucketName()); LOG.debug("With key '{}'", request.getKey()); LOG.debug("With expression query '{}'", query); request.setInputSerialization(inputSerialization); OutputSerialization outputSerialization = getOutputSerialization(context); request.setOutputSerialization(outputSerialization); return request; }
S3SelectAccessor extends BasePlugin implements Accessor { SelectObjectContentRequest generateBaseCSVRequest(RequestContext context) { InputSerialization inputSerialization = getInputSerialization(context); String fileHeaderInfo = context.getOption(FILE_HEADER_INFO); boolean usePositionToIdentifyColumn = inputSerialization.getCsv() != null && (StringUtils.isBlank(fileHeaderInfo) || !StringUtils.equalsIgnoreCase(FILE_HEADER_INFO_USE, fileHeaderInfo)); String query = null; try { S3SelectQueryBuilder queryBuilder = new S3SelectQueryBuilder(context, usePositionToIdentifyColumn); query = queryBuilder.buildSelectQuery(); } catch (SQLException e) { LOG.error("Unable to build select query for filter string {}", context.getFilterString()); } LOG.trace("Select query: {}", query); SelectObjectContentRequest request = new SelectObjectContentRequest(); request.setBucketName(name.getHost()); request.setKey(StringUtils.removeStart(name.getPath(), "/")); request.setExpression(query); request.setExpressionType(ExpressionType.SQL); LOG.debug("With bucket name '{}'", request.getBucketName()); LOG.debug("With key '{}'", request.getKey()); LOG.debug("With expression query '{}'", query); request.setInputSerialization(inputSerialization); OutputSerialization outputSerialization = getOutputSerialization(context); request.setOutputSerialization(outputSerialization); return request; } }
S3SelectAccessor extends BasePlugin implements Accessor { SelectObjectContentRequest generateBaseCSVRequest(RequestContext context) { InputSerialization inputSerialization = getInputSerialization(context); String fileHeaderInfo = context.getOption(FILE_HEADER_INFO); boolean usePositionToIdentifyColumn = inputSerialization.getCsv() != null && (StringUtils.isBlank(fileHeaderInfo) || !StringUtils.equalsIgnoreCase(FILE_HEADER_INFO_USE, fileHeaderInfo)); String query = null; try { S3SelectQueryBuilder queryBuilder = new S3SelectQueryBuilder(context, usePositionToIdentifyColumn); query = queryBuilder.buildSelectQuery(); } catch (SQLException e) { LOG.error("Unable to build select query for filter string {}", context.getFilterString()); } LOG.trace("Select query: {}", query); SelectObjectContentRequest request = new SelectObjectContentRequest(); request.setBucketName(name.getHost()); request.setKey(StringUtils.removeStart(name.getPath(), "/")); request.setExpression(query); request.setExpressionType(ExpressionType.SQL); LOG.debug("With bucket name '{}'", request.getBucketName()); LOG.debug("With key '{}'", request.getKey()); LOG.debug("With expression query '{}'", query); request.setInputSerialization(inputSerialization); OutputSerialization outputSerialization = getOutputSerialization(context); request.setOutputSerialization(outputSerialization); return request; }  }
S3SelectAccessor extends BasePlugin implements Accessor { SelectObjectContentRequest generateBaseCSVRequest(RequestContext context) { InputSerialization inputSerialization = getInputSerialization(context); String fileHeaderInfo = context.getOption(FILE_HEADER_INFO); boolean usePositionToIdentifyColumn = inputSerialization.getCsv() != null && (StringUtils.isBlank(fileHeaderInfo) || !StringUtils.equalsIgnoreCase(FILE_HEADER_INFO_USE, fileHeaderInfo)); String query = null; try { S3SelectQueryBuilder queryBuilder = new S3SelectQueryBuilder(context, usePositionToIdentifyColumn); query = queryBuilder.buildSelectQuery(); } catch (SQLException e) { LOG.error("Unable to build select query for filter string {}", context.getFilterString()); } LOG.trace("Select query: {}", query); SelectObjectContentRequest request = new SelectObjectContentRequest(); request.setBucketName(name.getHost()); request.setKey(StringUtils.removeStart(name.getPath(), "/")); request.setExpression(query); request.setExpressionType(ExpressionType.SQL); LOG.debug("With bucket name '{}'", request.getBucketName()); LOG.debug("With key '{}'", request.getKey()); LOG.debug("With expression query '{}'", query); request.setInputSerialization(inputSerialization); OutputSerialization outputSerialization = getOutputSerialization(context); request.setOutputSerialization(outputSerialization); return request; }  @Override void initialize(RequestContext requestContext); @Override boolean openForRead(); @Override OneRow readNextObject(); @Override void closeForRead(); @Override boolean openForWrite(); @Override boolean writeNextObject(OneRow onerow); @Override void closeForWrite(); }
S3SelectAccessor extends BasePlugin implements Accessor { SelectObjectContentRequest generateBaseCSVRequest(RequestContext context) { InputSerialization inputSerialization = getInputSerialization(context); String fileHeaderInfo = context.getOption(FILE_HEADER_INFO); boolean usePositionToIdentifyColumn = inputSerialization.getCsv() != null && (StringUtils.isBlank(fileHeaderInfo) || !StringUtils.equalsIgnoreCase(FILE_HEADER_INFO_USE, fileHeaderInfo)); String query = null; try { S3SelectQueryBuilder queryBuilder = new S3SelectQueryBuilder(context, usePositionToIdentifyColumn); query = queryBuilder.buildSelectQuery(); } catch (SQLException e) { LOG.error("Unable to build select query for filter string {}", context.getFilterString()); } LOG.trace("Select query: {}", query); SelectObjectContentRequest request = new SelectObjectContentRequest(); request.setBucketName(name.getHost()); request.setKey(StringUtils.removeStart(name.getPath(), "/")); request.setExpression(query); request.setExpressionType(ExpressionType.SQL); LOG.debug("With bucket name '{}'", request.getBucketName()); LOG.debug("With key '{}'", request.getKey()); LOG.debug("With expression query '{}'", query); request.setInputSerialization(inputSerialization); OutputSerialization outputSerialization = getOutputSerialization(context); request.setOutputSerialization(outputSerialization); return request; }  @Override void initialize(RequestContext requestContext); @Override boolean openForRead(); @Override OneRow readNextObject(); @Override void closeForRead(); @Override boolean openForWrite(); @Override boolean writeNextObject(OneRow onerow); @Override void closeForWrite(); static final String COMPRESSION_TYPE; static final String FILE_HEADER_INFO; static final String FILE_HEADER_INFO_NONE; static final String FILE_HEADER_INFO_IGNORE; static final String FILE_HEADER_INFO_USE; static final String JSON_TYPE; }