Skip to content
This repository was archived by the owner on Mar 13, 2020. It is now read-only.

Commit e28dab3

Browse files
authored
Execution table schema changes (#37)
* make total_rows_processed a big int * make execution track total time in s not ms
1 parent 68291b9 commit e28dab3

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

rdl/alembic/versions/955122a76711_create_an_execution_summary_table.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ def upgrade():
2525
sa.Column('execution_started', sa.DateTime(timezone=True),
2626
server_default=sa.text('now()'), nullable=True),
2727
sa.Column('execution_ended', sa.DateTime(timezone=True), nullable=True),
28-
sa.Column('execution_time_ms', sa.Integer(), nullable=True),
29-
sa.Column('total_rows_processed', sa.Integer(), nullable=True),
28+
sa.Column('execution_time_s', sa.Integer(), nullable=True),
29+
sa.Column('total_rows_processed', sa.BigInteger(), nullable=True),
3030
sa.Column('total_models_processed', sa.Integer(), nullable=True),
3131
sa.Column('status', sa.String(length=25), nullable=False),
3232
sa.PrimaryKeyConstraint('id'),
@@ -38,11 +38,11 @@ def upgrade():
3838
'''
3939
INSERT INTO rdl.execution (
4040
id, execution_started,
41-
execution_ended, execution_time_ms, total_rows_processed, total_models_processed, status
41+
execution_ended, execution_time_s, total_rows_processed, total_models_processed, status
4242
)
4343
SELECT
4444
execution_id, MAX(completed_on) - make_interval(secs := SUM(execution_time_ms)::decimal / 1000),
45-
MAX(completed_on), SUM(execution_time_ms), SUM(rows_processed), COUNT(id), 'UNKNOWN'
45+
MAX(completed_on), SUM(execution_time_ms) / 1000, SUM(rows_processed), COUNT(id), 'UNKNOWN'
4646
FROM rdl.data_load_execution
4747
GROUP BY execution_id
4848
''')

rdl/data_load_tracking/DataLoadTrackerRepository.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def complete_execution(self, execution_id, total_number_of_models,
4747
current_execution.total_models_processed = total_number_of_models
4848
current_execution.status = status
4949
current_execution.execution_ended = execution_end_time
50-
current_execution.execution_time_ms = int(total_execution_seconds * 1000)
50+
current_execution.execution_time_s = total_execution_seconds
5151
current_execution.total_rows_processed = self.get_execution_rows(current_execution.id)
5252
session.commit()
5353
self.logger.info(current_execution)

rdl/entities/execution_entity.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import uuid
22

3-
from sqlalchemy import Column, DateTime, Integer, String
3+
from sqlalchemy import Column, DateTime, Integer, String, BigInteger
44
from sqlalchemy.sql import func
55
from sqlalchemy.dialects.postgresql import UUID
66

@@ -14,16 +14,16 @@ class ExecutionEntity(Base):
1414
id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
1515
execution_started = Column(DateTime(timezone=True), server_default=func.now())
1616
execution_ended = Column(DateTime(timezone=True))
17-
execution_time_ms = Column(Integer, nullable=True)
18-
total_rows_processed = Column(Integer, nullable=True)
17+
execution_time_s = Column(Integer, nullable=True)
18+
total_rows_processed = Column(BigInteger, nullable=True)
1919
total_models_processed = Column(Integer, nullable=True)
2020
status = Column(String(25), nullable=False, default=Constants.ExecutionStatus.STARTED)
2121

2222
def __str__(self):
2323
if self.status == Constants.ExecutionStatus.STARTED:
2424
return f"Started Execution ID: {self.id} at {self.execution_started}"
2525

26-
total_execution_seconds = self.execution_time_ms // 1000
26+
total_execution_seconds = self.execution_time_s
2727
execution_hours = total_execution_seconds // 3600
2828
execution_minutes = (total_execution_seconds // 60) % 60
2929
execution_seconds = total_execution_seconds % 60

0 commit comments

Comments
 (0)