title: How AWS Athena deals with single line JSONs?
body: <p>I am currently using Athena along with <code>Kinesis Firehose</code>, <code>Glue Crawler</code>. <code>Kinesis Firehose</code> is saving JSON to single line files as below</p>
  
  <pre><code>{"name": "Jone Doe"}{"name": "Jane Doe"}{"name": "Jack Doe"}
  </code></pre>
  
  <p>But I noticed that the athena query <code>select count(*) from db.names</code>  returns 1 instead of 3. After searching for the problem. I found the following document.</p>
  
  <p><a href="https://aws.amazon.com/premiumsupport/knowledge-center/select-count-query-athena-json-records/?nc1=h_ls" rel="nofollow noreferrer">https://aws.amazon.com/premiumsupport/knowledge-center/select-count-query-athena-json-records/?nc1=h_ls</a></p>
  
  <p>The article says that JSON files files should stored with new lines.</p>
  
  <pre><code>{"name": "Jone Doe"}
  {"name": "Jane Doe"}
  {"name": "Jack Doe"}
  </code></pre>
  
  <p>Is there some smart tricks to run athena query on the single line JSON files?</p>
  
  <h2><br></h2>
  
  <h2>Update</h2>
  
  <p>Thanks to @Constantine, AWS Athena is performing distributed processing. Since, single-line JSON files doesn't have seperator, It can't perform distributed processing. So, You must transform the files before saving it. </p>
  
  <p>Kinesis Firehose offers transformation using Lambda, I added following transformation, in order to query data from AWS Athena.</p>
  
  <pre><code>​const addNewLine = (data) =&gt; {
     const parsedData = JSON.parse(new Buffer.from(data,'base64').toString('utf8'));
     return new Buffer.from(JSON.stringify(parsedData) + '\n').toString('base64')
  }
  ​
  exports.handler = async (event, context) =&gt; {
     const output = event.records.map((record) =&gt; ({
         recordId: record.recordId,
         result: 'Ok',
         data: addNewLine(record.data),
     }));
     return { records: output };
  };​
  </code></pre>
  
  <p>I've come up with this code through following link
  <a href="https://stackoverflow.com/questions/56044001/aws-firehose-newline-character">AWS Firehose newline Character</a></p>