Class: Moku6::Generators::BigQueryGenerator

Inherits:
BaseGenerator show all
Defined in:
lib/moku6/generators/bigquery_generator.rb

Overview

Emits BigQuery DDL for the shared envelope (design section 12.5). Fields live in the ‘metadata JSON` column, consistent with section 8.

Constant Summary

Constants inherited from BaseGenerator

Moku6::Generators::BaseGenerator::AUTOGEN_NOTE

Instance Method Summary collapse

Methods inherited from BaseGenerator

#initialize, #write

Constructor Details

This class inherits a constructor from Moku6::Generators::BaseGenerator

Instance Method Details

#renderObject

: () -> String



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/moku6/generators/bigquery_generator.rb', line 10

def render
  <<~SQL
    -- #{AUTOGEN_NOTE}
    CREATE TABLE audit_events (
      event_id    STRING    NOT NULL,
      action      STRING    NOT NULL,
      occurred_at TIMESTAMP NOT NULL,
      actor       JSON,
      target      JSON,
      metadata    JSON,
      privacy     JSON,
      created_at  TIMESTAMP NOT NULL
    )
    PARTITION BY DATE(occurred_at)
    CLUSTER BY action;
  SQL
end