.quote(context.getProperty(QUOTE_STRING).evaluateAttributeExpressions(inputFlowFile).getValue()) .escape(context.getProperty(ESCAPE_STRING).evaluateAttributeExpressions(inputFlowFile).getValue()) .linesToSkip(context.getProperty(HEADER_LINE_SKIP_COUNT).evaluateAttributeExpressions(inputFlowFile).asInteger()) .header(header.get()) .hasHeader(hasHeader.get())
.escape(context.getProperty(ESCAPE).evaluateAttributeExpressions(incomingCSV).getValue()) .hasHeader(context.getProperty(HAS_HEADER).evaluateAttributeExpressions(incomingCSV).asBoolean()) .linesToSkip(context.getProperty(LINES_TO_SKIP).evaluateAttributeExpressions(incomingCSV).asInteger()) .build();
.header(header) .hasHeader(!noHeader) .linesToSkip(linesToSkip) .charset(charsetName) .build();
.escape(context.getProperty(ESCAPE).evaluateAttributeExpressions(incomingCSV).getValue()) .hasHeader(context.getProperty(HAS_HEADER).evaluateAttributeExpressions(incomingCSV).asBoolean()) .linesToSkip(context.getProperty(LINES_TO_SKIP).evaluateAttributeExpressions(incomingCSV).asInteger()) .build();
.header(header) .hasHeader(!noHeader) .linesToSkip(linesToSkip) .charset(charsetName) .build();
.quote(context.getProperty(QUOTE_STRING).evaluateAttributeExpressions(inputFlowFile).getValue()) .escape(context.getProperty(ESCAPE_STRING).evaluateAttributeExpressions(inputFlowFile).getValue()) .linesToSkip(context.getProperty(HEADER_LINE_SKIP_COUNT).evaluateAttributeExpressions(inputFlowFile).asInteger()) .header(header.get()) .hasHeader(hasHeader.get())
InputStream stream = new ByteArrayInputStream(csvLines.getBytes("utf8")); Schema schema = CSVUtil.inferSchema("TestRecord", stream, new CSVProperties.Builder().linesToSkip(1).build(), ImmutableSet.of("long", "field_1"));
@Test public void testSchemaInferenceMissingExample() throws Exception { InputStream stream = new ByteArrayInputStream( "\none,two\n34,\n".getBytes("utf8")); Schema schema = CSVUtil.inferSchema("TestRecord", stream, new CSVProperties.Builder().linesToSkip(1).hasHeader().build()); Assert.assertNotNull(schema.getField("one")); Assert.assertNotNull(schema.getField("two")); Assert.assertEquals("Should infer a long", schema(Schema.Type.LONG), schema.getField("one").schema()); Assert.assertEquals("Should default to a string", nullable(Schema.Type.STRING), schema.getField("two").schema()); }