Skip to content

Glue crawler is treating each file as a single record instead of parsing the contents within each file

0

I am using KDS which pushes to Kinesis Data Firehose which loads data into my S3 bucket. My S3 bucket is currently structured as follows: s3://bucket_name/anyCompany/year/month/day/hour/jsonFiles Each jsonFile contains multiple Json records My crawler's data source is currently pointing at s3://bucket_name/anyCompany When I crawl using Glue crawler, it recognizes just one record instead of scanning the file and identifying json records within each file. My glue table correctly reflects the schema with partitions at year, month, hour and day.

For reference: This is the structure of my file. I am one single record in a one line. {"eventType": "newTicker", "ticker": "JNJ", "industry": "Healthcare", "timestamp": "2025-10-26 20:58:18", "price": 475.95}{"eventType": "newTicker", "ticker": "PFE", "industry": "Healthcare", "timestamp": "2025-10-26 20:58:18", "price": 242.09}

So instead of identifying two rows, it is still just adding one row in the table. I have tried pointing the glue data source to even individual files to see it picks up, but am facing the same issue.
I have tried changing crawler settings, recreating it via Athena, checking for partitions, check SerDes. I also looked into classifiers but I don't have a nested json, so I am not sure which applies.

I am failing to extract records correctly from this file. Athena shows the number of rows I have in the table is same. as the number of files I have in each folder instead of the total records I sent all to the stream.

2 Answers
0
Accepted Answer

The issue you're experiencing is that your JSON records in each file are not properly delimited for the Glue crawler to recognize them as separate records. When Glue crawler processes JSON files, it expects each JSON object to be separated by a newline character.

In your case, the JSON objects in your files are concatenated without any delimiter between them: {"eventType": "newTicker", "ticker": "JNJ"...}{"eventType": "newTicker", "ticker": "PFE"...}

This is a common issue when using Kinesis Data Firehose to deliver data to S3. By default, Firehose doesn't add delimiters between records.

To fix this issue, you need to configure your Kinesis Data Firehose delivery stream with a ProcessingConfiguration that adds a delimiter between records. Specifically, you need to add an AppendDelimiterToRecord processor to your Firehose configuration.

Here's how you can modify your Firehose configuration:

ProcessingConfiguration:
Enabled: True
Processors:
- Type: AppendDelimiterToRecord

After making this change, Firehose will append a newline character after each record, resulting in files that look like:

{"eventType": "newTicker", "ticker": "JNJ"...}
{"eventType": "newTicker", "ticker": "PFE"...}

With this format, the Glue crawler will be able to correctly identify each JSON object as a separate record, and your Athena queries will return the expected number of rows.
Sources
Community | Serverless statistics solution with Lambda@Edge

answered a year ago

0

You will need to use "Multi record deaggregation" in your destination setting for Firehose. Please refer to this documentation for more information: https://docs.aws.amazon.com/firehose/latest/dev/create-destination.html#create-destination-s3:~:text=configure%20dynamic%20partitioning.-,Multi%20record%20deaggregation,-This%20is%20the

Multi record deaggregation is specifically designed for this scenario. It "parses through the records in the Firehose stream and separating them based either on valid JSON or on the specified new line delimiter".

AWS

answered a year ago

  • I am not using Dynamic partitioning, so this feature is not applicable here.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.