Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion spark_log_parser/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Tools for providing Spark event log"""

__version__ = "0.1.0"
__version__ = "0.1.1"
10 changes: 7 additions & 3 deletions spark_log_parser/parsing_models/application_model_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,14 @@ def getSQLinfo(self, appobj):
sql_jobs = []
sql_stages = []
sql_tasks = []
for jid, job in appobj.jobs.items():

if "end_time" not in sql.keys():
sql["end_time"] = appobj.finish_time
# Sometimes an SQL event will be missing. To be informative, both
# events must be present. But this information is not critical, so
# if either event is missing then simply reject the SQL data
if "start_time" not in sql.keys() or "end_time" not in sql.keys():
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not critical, but just to understand:

Could you do just if "end_time" not in sql.keys(). This is on the assumption that if an end_time exists, then a start_time should as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't work because "start_time" and "end_time" come from separate events in the Spark eventlog. So it's possible for one, or other other, or both to be missing.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see.

continue

for jid, job in appobj.jobs.items():

if (job.submission_time >= sql["start_time"]) and (
job.submission_time <= sql["end_time"]
Expand Down
Binary file added tests/logs/emr_missing_sql_events.zip
Binary file not shown.
10 changes: 10 additions & 0 deletions tests/test_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,13 @@ def test_simple_emr_log():
assert (
parsed["metadata"]["application_info"]["name"] == "Text Similarity"
), "Name is as expected"


def test_emr_missing_sql_events():
event_log_path = Path("tests", "logs", "emr_missing_sql_events.zip").resolve()

with tempfile.TemporaryDirectory() as temp_dir:
event_log = eventlog.EventLogBuilder(event_log_path.as_uri(), temp_dir).build()
obj = sparkApplication(eventlog=str(event_log))

assert list(obj.sqlData.index.values) == [0, 2, 3, 5, 6, 7, 8]