You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "Otto Fowler (JIRA)" <ji...@apache.org> on 2018/06/14 13:39:00 UTC
[jira] [Comment Edited] (NIFI-5310) Not able to read record as
string type ending with \ (backslash)
[ https://issues.apache.org/jira/browse/NIFI-5310?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16512468#comment-16512468 ]
Otto Fowler edited comment on NIFI-5310 at 6/14/18 1:38 PM:
------------------------------------------------------------
{code:java}
@Test
public void testSimpleWithSlash() throws InitializationException, IOException, SQLException {
final MockRecordParser parser = new MockRecordParser();
parser.addSchemaField("name", RecordFieldType.STRING);
parser.addSchemaField("age", RecordFieldType.INT);
parser.addRecord("Tom\\", 49);
final MockRecordWriter writer = new MockRecordWriter("\"name\",\"points\"");
TestRunner runner = getRunner();
runner.addControllerService("parser", parser);
runner.enableControllerService(parser);
runner.addControllerService("writer", writer);
runner.enableControllerService(writer);
runner.setProperty(REL_NAME, "select name, age from FLOWFILE WHERE name <> ''");
runner.setProperty(QueryRecord.RECORD_READER_FACTORY, "parser");
runner.setProperty(QueryRecord.RECORD_WRITER_FACTORY, "writer");
final int numIterations = 1;
for (int i = 0; i < numIterations; i++) {
runner.enqueue(new byte[0]);
}
runner.setThreadCount(4);
runner.run(2 * numIterations);
runner.assertTransferCount(REL_NAME, 1);
final MockFlowFile out = runner.getFlowFilesForRelationship(REL_NAME).get(0);
System.out.println(new String(out.toByteArray()));
out.assertContentEquals("\"name\",\"points\"\n\"Tom\\\",\"49\"\n");
}
{code}
This test works, do you have the nifi-app.log with the full exception?
was (Author: ottobackwards):
{code:java}
@Test
public void testSimpleWithSlash() throws InitializationException, IOException, SQLException {
final MockRecordParser parser = new MockRecordParser();
parser.addSchemaField("name", RecordFieldType.STRING);
parser.addSchemaField("age", RecordFieldType.INT);
parser.addRecord("Tom\\", 49);
final MockRecordWriter writer = new MockRecordWriter("\"name\",\"points\"");
TestRunner runner = getRunner();
runner.addControllerService("parser", parser);
runner.enableControllerService(parser);
runner.addControllerService("writer", writer);
runner.enableControllerService(writer);
runner.setProperty(REL_NAME, "select name, age from FLOWFILE WHERE name <> ''");
runner.setProperty(QueryRecord.RECORD_READER_FACTORY, "parser");
runner.setProperty(QueryRecord.RECORD_WRITER_FACTORY, "writer");
final int numIterations = 1;
for (int i = 0; i < numIterations; i++) {
runner.enqueue(new byte[0]);
}
runner.setThreadCount(4);
runner.run(2 * numIterations);
runner.assertTransferCount(REL_NAME, 1);
final MockFlowFile out = runner.getFlowFilesForRelationship(REL_NAME).get(0);
System.out.println(new String(out.toByteArray()));
out.assertContentEquals("\"name\",\"points\"\n\"Tom\\\",\"49\"\n");
}
{code}
This test works, so the issue is probably with reader, do you have the nifi-app.log with the full exception?
> Not able to read record as string type ending with \ (backslash)
> ----------------------------------------------------------------
>
> Key: NIFI-5310
> URL: https://issues.apache.org/jira/browse/NIFI-5310
> Project: Apache NiFi
> Issue Type: Bug
> Components: Core Framework
> Affects Versions: 1.6.0
> Environment: Windows/Linux Both
> Reporter: Nishant Gupta
> Priority: Critical
> Labels: BackSlash, CSV, Nifi, QueryRecord,
> Attachments: IssueWithBackSlash.PNG
>
>
> *Processor* - QueryRecord
> *RecordReader* - CSVReader
> *RecordWriter* - CSVRecordSetWriter
> *Data* Type- String
> {
> "name": "Name",
> "type": ["string","null"]
> }
> *Data - John\ (Failing), John\M(passing)*
> *Query* - select Name, ID from FLOWFILE
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)