<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Read a flowfile with groovy error in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Read-a-flowfile-with-groovy-error/m-p/233767#M195590</link>
    <description>&lt;P&gt;Thank you for your response. Actually it's my post.&lt;/P&gt;&lt;P&gt;I used SQL.mydb.execute(createTable.toString()) but I got the same error which due to this instruction &lt;/P&gt;&lt;PRE&gt;def schema = ff.read().withReader("UTF-8"){newJsonSlurper().parse(it). &lt;/PRE&gt;&lt;P&gt;So I changed the code&lt;/P&gt;&lt;PRE&gt;import groovy.json.JsonSlurper
import org.apache.commons.io.IOUtils
import java.nio.charset.StandardCharsets
def ff = session.get()
if(!ff)return
def schema = ''
session.read(ff, {inputStream -&amp;gt;
  schema= IOUtils.toString(inputStream, StandardCharsets.UTF_8)
} as InputStreamCallback)
//define type mapping
def typeMap = [
    "string"            : "varchar(255)",
    "long"              : "numeric(10)",
    [ "null", "string" ]: "varchar(255)",
    [ "null", "long" ]  : "numeric(10)",
]
//build create table statement
def createTable = "create table ${schema.name} (" +
    schema.fields.collect{ "\n  ${it.name.padRight(39)} ${typeMap[it.type]}" }.join(',') +
    "\n)"
//execute statement through the custom defined property
//SQL.mydb references &lt;A href="http://docs.groovy-lang.org/2.4.10/html/api/groovy/sql/Sql.html" target="_blank"&gt;http://docs.groovy-lang.org/2.4.10/html/api/groovy/sql/Sql.html&lt;/A&gt; object
SQL.mydb.execute(createTable.toString())
//transfer flow file to success
REL_SUCCESS &amp;lt;&amp;lt; ff&lt;/PRE&gt;&lt;PRE&gt;error : groovy.lang.missingpropertyexception no such property for class java.lang.string&lt;/PRE&gt;</description>
    <pubDate>Tue, 06 Mar 2018 00:26:49 GMT</pubDate>
    <dc:creator>AmiraKhalifa</dc:creator>
    <dc:date>2018-03-06T00:26:49Z</dc:date>
  </channel>
</rss>

