Skip to content

Instantly share code, notes, and snippets.

@ycku
Last active June 29, 2025 13:27
Show Gist options
  • Save ycku/0126cd36f576f8f057171457a06b2e84 to your computer and use it in GitHub Desktop.
Save ycku/0126cd36f576f8f057171457a06b2e84 to your computer and use it in GitHub Desktop.
FOCUS 1.0 with PostgreSQL
DROP TABLE IF EXISTS "focus_data";
CREATE TABLE "focus_data" (
"AvailabilityZone" varchar(50) DEFAULT NULL,
"BilledCost" decimal(18,11) DEFAULT NULL,
"BillingAccountId" varchar(100) DEFAULT NULL,
"BillingAccountName" varchar(100) DEFAULT NULL,
"BillingCurrency" varchar(5) DEFAULT NULL,
"BillingPeriodEnd" timestamptz NULL DEFAULT NULL,
"BillingPeriodStart" timestamptz NULL DEFAULT NULL,
"ChargeCategory" varchar(25) DEFAULT NULL,
"ChargeClass" varchar(25) DEFAULT NULL,
"ChargeDescription" varchar(1024) DEFAULT NULL,
"ChargeFrequency" varchar(50) DEFAULT NULL,
"ChargePeriodEnd" timestamptz NULL DEFAULT NULL,
"ChargePeriodStart" timestamptz NULL DEFAULT NULL,
"CommitmentDiscountCategory" varchar(25) DEFAULT NULL,
"CommitmentDiscountId" varchar(255) DEFAULT NULL,
"CommitmentDiscountName" varchar(255) DEFAULT NULL,
"CommitmentDiscountStatus" varchar(25) DEFAULT NULL,
"CommitmentDiscountType" varchar(100) DEFAULT NULL,
"ConsumedQuantity" decimal(32,15) DEFAULT NULL,
"ConsumedUnit" varchar(100) DEFAULT NULL,
"ContractedCost" decimal(18,11) DEFAULT NULL,
"ContractedUnitPrice" decimal(18,11) DEFAULT NULL,
"EffectiveCost" decimal(18,11) DEFAULT NULL,
"InvoiceIssuerName" varchar(50) DEFAULT NULL,
"ListCost" decimal(18,11) DEFAULT NULL,
"ListUnitPrice" varchar(100) DEFAULT NULL,
"PricingCategory" varchar(25) DEFAULT NULL,
"PricingQuantity" decimal(18,11) DEFAULT NULL,
"PricingUnit" varchar(100) DEFAULT NULL,
"ProviderName" varchar(100) DEFAULT NULL,
"PublisherName" varchar(100) DEFAULT NULL,
"RegionId" varchar(100) DEFAULT NULL,
"RegionName" varchar(100) DEFAULT NULL,
"ResourceId" varchar(1024) DEFAULT NULL,
"ResourceName" varchar(1024) DEFAULT NULL,
"ResourceType" varchar(255) DEFAULT NULL,
"ServiceCategory" varchar(255) DEFAULT NULL,
"Id" bigserial NOT NULL,
"ServiceName" varchar(255) DEFAULT NULL,
"SkuId" varchar(255) DEFAULT NULL,
"SkuPriceId" varchar(255) DEFAULT NULL,
"SubAccountId" varchar(100) DEFAULT NULL,
"SubAccountName" varchar(100) DEFAULT NULL,
"Tags" jsonb DEFAULT NULL,
PRIMARY KEY ("Id")
);
-- \copy focus_data from 'focus_data_table.csv' (format csv, header, null 'NULL', encoding utf8);
CREATE TABLE focus_data_daily (
charge_date date primary key,
cost decimal(18,11) NOT NULL DEFAULT 0,
ma7 decimal(18,11) NOT NULL DEFAULT 0,
ma30 decimal(18,11) NOT NULL DEFAULT 0
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment