This is a practice lab, so the solution code is provided, but this is just the output. If the datastream is “USA,” the records are written successfully; but if it’s “International,” there’s an error reading each record. I double-checked the code against the solution, and it’s identical. Here is the log of the read info and then the error when writing a record:
Read User Session {
‘session_id’: ‘f1f80298-1d88-4098-8094-ceb1c666af30’,
‘customer_number’: 250,
‘city’: ‘Amsterdam’,
‘country’: ‘Netherlands’,
‘credit_limit’: 69126,
‘browse_history’: [
{‘product_code’: ‘S24_2972’, ‘quantity’: ‘6’, ‘in_shopping_cart’: False},
{‘product_code’: ‘S24_3969’, ‘quantity’: ‘5’, ‘in_shopping_cart’: True},
{‘product_code’: ‘S700_2047’, ‘quantity’: ‘5’, ‘in_shopping_cart’: True},
{‘product_code’: ‘S18_2238’, ‘quantity’: ‘6’, ‘in_shopping_cart’: True}]}
from Shard shardId-000000000002 at position 49663610404079420682966555204251411191511788918086303778
2025-05-25 00:45:02 root ERROR
{‘message’: ‘Error producing record’, ‘error’: “‘International’”, ‘record’: {
‘session_id’: ‘f1f80298-1d88-4098-8094-ceb1c666af30’,
‘customer_number’: 250,
‘city’: ‘Amsterdam’,
‘country’: ‘Netherlands’,
‘credit_limit’: 69126,
‘browse_history’: [
{‘product_code’: ‘S24_2972’, ‘quantity’: ‘6’, ‘in_shopping_cart’: False},
{‘product_code’: ‘S24_3969’, ‘quantity’: ‘5’, ‘in_shopping_cart’: True},
{‘product_code’: ‘S700_2047’, ‘quantity’: ‘5’, ‘in_shopping_cart’: True},
{‘product_code’: ‘S18_2238’, ‘quantity’: ‘6’, ‘in_shopping_cart’: True}],
‘processing_timestamp’: datetime.datetime(2025, 5, 25, 0, 45, 2, 728434),
‘overall_product_quantity’: 22,
‘overall_in_shopping_cart’: 16,
‘total_different_products’: 4}
}