diff --git a/models/descriptions/succeeded.md b/models/descriptions/succeeded.md new file mode 100644 index 0000000..890aabe --- /dev/null +++ b/models/descriptions/succeeded.md @@ -0,0 +1,5 @@ +{% docs succeeded %} + +A boolean value indicating if the event succeeded. + +{% enddocs %} \ No newline at end of file diff --git a/models/gold/core/core__fact_blocks.sql b/models/gold/core/core__fact_blocks.sql index 099fad3..37114cc 100644 --- a/models/gold/core/core__fact_blocks.sql +++ b/models/gold/core/core__fact_blocks.sql @@ -22,8 +22,8 @@ SELECT coinbase_target, cumulative_proof_target, cumulative_weight, - block_reward, - puzzle_reward, + CASE WHEN block_id = 0 THEN 0 ELSE block_reward END AS block_reward, + CASE WHEN block_id = 0 THEN 0 ELSE puzzle_reward END AS puzzle_reward, {{ dbt_utils.generate_surrogate_key(['block_id']) }} AS fact_blocks_id, SYSDATE() AS inserted_timestamp, SYSDATE() AS modified_timestamp, diff --git a/models/gold/core/core__fact_blocks.yml b/models/gold/core/core__fact_blocks.yml index 74f395f..c0e4434 100644 --- a/models/gold/core/core__fact_blocks.yml +++ b/models/gold/core/core__fact_blocks.yml @@ -6,7 +6,7 @@ models: tests: - dbt_utils.unique_combination_of_columns: combination_of_columns: - - NETWORK_ID + - NETWORK - block_id columns: - name: block_id diff --git a/models/gold/core/core__fact_transactions.yml b/models/gold/core/core__fact_transactions.yml index 9aff075..8a0dd6b 100644 --- a/models/gold/core/core__fact_transactions.yml +++ b/models/gold/core/core__fact_transactions.yml @@ -48,8 +48,7 @@ models: - not_null - dbt_expectations.expect_column_values_to_be_in_type_list: column_type_list: - - STRING - - VARCHAR + - BOOLEAN - name: TX_TYPE description: "{{ doc('tx_type') }}" tests: diff --git a/models/silver/core/silver__blocks.yml b/models/silver/core/silver__blocks.yml index e5672d9..fb42619 100644 --- a/models/silver/core/silver__blocks.yml +++ b/models/silver/core/silver__blocks.yml @@ -34,11 +34,6 @@ models: description: "{{ doc('network_id') }}" tests: - not_null - - dbt_expectations.expect_column_values_to_be_in_type_list: - column_type_list: - - STRING - - VARCHAR - - NUMBER - name: TX_COUNT description: "{{ doc('tx_count') }}" tests: diff --git a/models/silver/core/silver__transactions.yml b/models/silver/core/silver__transactions.yml index 2eb3428..89cb623 100644 --- a/models/silver/core/silver__transactions.yml +++ b/models/silver/core/silver__transactions.yml @@ -29,14 +29,8 @@ models: tests: - not_null - - name: inner_type - tests: - - not_null - - name: FEE_MSG description: "{{ doc('fee_msg') }}" - tests: - - not_null - name: execution_msg diff --git a/models/silver/core/silver__transitions.sql b/models/silver/core/silver__transitions.sql index 29206e9..57259c8 100644 --- a/models/silver/core/silver__transitions.sql +++ b/models/silver/core/silver__transitions.sql @@ -54,7 +54,7 @@ rej_trans AS ( t.tx_id, t.block_timestamp, FALSE AS succeeded, - f.value: TYPE :: STRING AS TYPE, + 'execution' AS TYPE, f.value AS transition, f.index AS transition_index FROM @@ -73,30 +73,28 @@ transitions AS ( * FROM rej_trans -) {# , -parsed AS ( - #} - SELECT - block_id, - block_timestamp, - tx_id, - INDEX, - transition :id :: STRING AS transition_id, - succeeded, - TYPE, - transition :program :: STRING AS program_id, - transition :function :: STRING AS FUNCTION, - TRY_PARSE_JSON( - transition :inputs - ) AS inputs, - TRY_PARSE_JSON( - transition :outputs - ) AS outputs, - {{ dbt_utils.generate_surrogate_key( - ['tx_id','transition_id'] - ) }} AS transitions_id, - SYSDATE() AS inserted_timestamp, - SYSDATE() AS modified_timestamp, - '{{ invocation_id }}' AS invocation_id - FROM - transitions +) +SELECT + block_id, + block_timestamp, + tx_id, + INDEX, + transition :id :: STRING AS transition_id, + succeeded, + TYPE, + transition :program :: STRING AS program_id, + transition :function :: STRING AS FUNCTION, + TRY_PARSE_JSON( + transition :inputs + ) AS inputs, + TRY_PARSE_JSON( + transition :outputs + ) AS outputs, + {{ dbt_utils.generate_surrogate_key( + ['tx_id','transition_id'] + ) }} AS transitions_id, + SYSDATE() AS inserted_timestamp, + SYSDATE() AS modified_timestamp, + '{{ invocation_id }}' AS invocation_id +FROM + transitions diff --git a/models/silver/core/silver__transitions_fee.sql b/models/silver/core/silver__transitions_fee.sql index 32ec6fd..945c1fd 100644 --- a/models/silver/core/silver__transitions_fee.sql +++ b/models/silver/core/silver__transitions_fee.sql @@ -18,9 +18,11 @@ WITH base AS ( fee_msg :transition AS transition FROM {{ ref('silver__transactions') }} + WHERE + fee_msg IS NOT NULL {% if is_incremental() %} -WHERE +AND modified_timestamp >= DATEADD( MINUTE, -5,( diff --git a/models/silver/core/silver__transitions_fee.yml b/models/silver/core/silver__transitions_fee.yml index 81bdffd..657f1d8 100644 --- a/models/silver/core/silver__transitions_fee.yml +++ b/models/silver/core/silver__transitions_fee.yml @@ -18,9 +18,9 @@ models: description: "{{ doc('tx_id') }}" tests: - not_null - - - name: INDEX - description: "{{ doc('program_id') }}" + + - name: SUCCEEDED + description: "{{ doc('succeeded') }}" tests: - not_null @@ -29,16 +29,11 @@ models: tests: - not_null - unique - - - name: TYPE - tests: - - not_null - name: PROGRAM_ID description: "{{ doc('program_id') }}" tests: - not_null - - name: FUNCTION description: "{{ doc('transition_function') }}" tests: @@ -50,7 +45,7 @@ models: - name: OUTPUTS description: "{{ doc('transition_outputs') }}" - - name: TRANSITIONS_ID + - name: TRANSITIONS_FEE_ID description: "{{ doc('pk') }}" tests: - unique