更新日:私のアルゴリズム(またはそのような任意のアルゴリズム)のすべてのエッジケースのデータを計算する手法を探しています。
私はこれまでに試したことがありますちょうどエッジケース+いくつかの "ランダム"データを生成するかもしれないことについて考えているが、私は本当のユーザーができることを何か"他の行のデータからグループ化"アルゴリズムのテストデータを生成する方法
タスクは、以下のとおりです。私は私は私のアルゴリズムで重要な何かを見逃していなかったと私はすべての可能な状況をカバーするためにテストデータを生成する方法がわからない確認したい。..
をめちゃくちゃEvent_Date
のデータのスナップショットを報告しますが、に属する可能性のある編集のために別の行を作成します。Event_Date
- 入力と出力データイラスト上でグループ2)を参照してください:私のアルゴリズム
:
event_date
のリストを作り、彼らのためにnext_event_date
秒- を計算結果を
main_audit_table
に合算し、各スナップショット(私のillustraのグループ1〜4)について最大でtransaction_id
を計算してくださいン) -event_date
、id
によってgrouppedとtransaction_date < next_event_date
が真であるかどうか - かどうかに基づいて、2つのオプションによって、結果に
costs_audit_table
に参加する同じtransaction_id
- から他のデータを取得するために、結果に
main_audit_table
に参加 - 最大transaction_id
を使用-
:それは結果から
マイ質問(複数可)transaction_id
よりも小さくなっています
マイコード(テストする必要があります):
select
snapshots.id,
snapshots.event_date,
main.event,
main.transaction_date as last_change,
costs.costs as costs_2012
from (
--snapshots that return correct transaction ids grouped by event_date
select
main_grp.id,
main_grp.event_date,
max(main_grp.transaction_id) main_transaction_id,
max(costs_grp.transaction_id) costs_transaction_id
from main_audit_table main_grp
join (
--list of all event_dates and their next_event_dates
select
id,
event_date,
coalesce(lead(event_date) over (partition by id order by event_date),
'1.1.2099') next_event_date
from main_audit_table
group by main_grp.id, main_grp.event_date
) list on list.id = main_grp.id and list.event_date = main_grp.event_date
left join costs_audit_table costs_grp
on costs_grp.id = main_grp.id and
costs_grp.year = 2012 and
costs_grp.transaction_id <= main_grp.transaction_id
group by
main_grp.id,
main_grp.event_date,
case when main_grp.transaction_date < list.next_event_date
then 1
else 0 end
) snapshots
join main_audit_table main
on main.id = snapshots.id and
main.transaction_id = snapshots.main_transaction_id
left join costs_audit_table costs
on costs.id = snapshots.id and
costs.transaction_id = snapshots.costs_transaction_id
このデータがどのようにモデル化され、どのようにこれらのグループを割り当てられたかを明確にすることはできますか? – Kodra
@Kodraはモデルとして - IBM Tivoli Service Request Manager *監査テーブル(カスタムフィールドが数多くあるa_workorder)+カスタム監査テーブル - 最新のドキュメントやリバースエンジニアリングスキルはあなたのものと同じくらい良いものです。 。 – Aprillion
@Kodraグループ割り当ては私のアルゴリズムのポイント2から明らかにする必要があります - そうでない場合は正確には何かを教えてください。私はそれを言い換えることができます、ありがとう – Aprillion