Skip to content

Commit

Permalink
chore: ⚡️ add metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgasquez committed Dec 20, 2023
1 parent 0975df3 commit 51b9a8d
Show file tree
Hide file tree
Showing 4 changed files with 384 additions and 223 deletions.
30 changes: 30 additions & 0 deletions dbt/models/projects.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
with source as (
select * from {{ source('public', 'raw_projects') }}
),

renamed as (
select
{{ adapter.quote("id") }} as project_id,
{{ adapter.quote("projectNumber") }} as project_number,
{{ adapter.quote("metaPtr") }} as meta_ptr,
{{ adapter.quote("metadata") }} as metadata,
{{ adapter.quote("owners") }} as owners,
{{ adapter.quote("createdAtBlock") }} as created_at_block,
{{ adapter.quote("chainId") }} as chain_id
from source
),

extracted_metadata as (
select
*,
json_extract_path_text(metadata, 'title') as title,
json_extract_path_text(metadata, 'description') as description,
json_extract_path_text(metadata, 'website') as website,
json_extract_path_text(metadata, 'projectTwitter') as project_twitter,
json_extract_path_text(metadata, 'logoImg') as logo_image,
json_extract_path_text(metadata, 'bannerImg') as banner_image,
json_extract_path_text(metadata, 'createdAt')::numeric as created_at,
from renamed
)

select * from extracted_metadata
2 changes: 2 additions & 0 deletions ggdp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from dagster import Definitions, load_assets_from_modules
from dagster_dbt import dbt_cli_resource, load_assets_from_dbt_project
from dagster_duckdb import DuckDBResource
from dagster_duckdb_pandas import DuckDBPandasIOManager

from . import assets
Expand All @@ -17,6 +18,7 @@

resources = {
"dbt": dbt_resource,
"duckdb": DuckDBResource(database="data/local.duckdb"),
"io_manager": DuckDBPandasIOManager(
database="data/local.duckdb",
),
Expand Down
60 changes: 60 additions & 0 deletions notebooks/chain-data.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"cells": [
{
"cell_type": "raw",
"metadata": {},
"source": [
"---\n",
"title: \"Getting Chain Data\"\n",
"format: html\n",
"---"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"import duckdb\n",
"\n",
"duckdb.sql(\n",
" \"\"\"\n",
" set s3_region = \"auto\";\n",
" set s3_url_style = \"path\";\n",
" set s3_endpoint = 'ed5d915e0259fcddb2ab1ce5592040c3.r2.cloudflarestorage.com';\n",
" set s3_access_key_id = '43c31ff797ec2387177cabab6d18f15a';\n",
" set s3_secret_access_key = 'afb354f05026f2512557922974e9dd2fdb21e5c2f5cbf929b35f0645fb284cf7';\n",
"\n",
" create table ethereum_raw_blocks as (\n",
" select\n",
" *\n",
" from read_parquet(\"s3://indexed-xyz/ethereum/raw/blocks/v1.2.0/partition_key=9d/dt=2023/*.parquet\")\n",
" );\n",
"\"\"\"\n",
")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading

0 comments on commit 51b9a8d

Please sign in to comment.