Glossary/Semantic Layer & Metrics

Query Abstraction

Query abstraction is the separation of user-facing query logic from underlying database implementation, allowing users to specify what data they want without knowing how to retrieve it.

Query abstraction enables users to express analytical intent in high-level terms. Instead of writing SQL ("SELECT SUM(amount) FROM orders WHERE status = 'completed' GROUP BY customer_id"), users specify intent ("revenue by customer"). The abstraction layer translates this into optimized SQL, determines the correct tables and joins, applies necessary filters, and handles aggregation. Users focus on what they want to analyze; the system handles the how.

Query abstraction solves the complexity and fragility of direct database access. Raw SQL is powerful but error-prone: analysts write different queries to answer the same question, make join mistakes, and struggle with performance tuning. Query abstraction enforces consistency: the system generates correct, optimized queries automatically. It also democratizes analytics: users without SQL expertise can access data through abstraction layers.

Query abstraction is implemented through multiple mechanisms: semantic models and metric definitions (declarative specification of metrics), BI tool interfaces (drag-and-drop query builders), natural language interfaces (conversational analytics), and API layers. The key is that the abstraction translates high-level requests to optimized low-level execution without user involvement. The abstraction layer can change SQL generation (add new optimization techniques) without changing the user interface.

Key Characteristics

  • Hides SQL complexity from users
  • Accepts high-level analytical intent or declarative specifications
  • Translates requests to optimized database queries
  • Enforces defined relationships and business rules
  • Caches results and optimizes performance
  • Supports multiple query interfaces (UI, API, natural language)

Why It Matters

  • Accessibility: Non-SQL users access data independently
  • Speed: Abstraction layer optimizes queries automatically
  • Consistency: Same query always produces consistent results
  • Governance: Enforces access control and data quality rules
  • Evolution: Database changes don't break queries

Example

A user specifies "Show me monthly revenue by product for the last 12 months" through a BI interface. Query abstraction translates this to optimized SQL joining orders, items, and products tables, applying filters for the date range, grouping by product and month, and aggregating amounts. The user never writes SQL.

Coginiti Perspective

Coginiti provides query abstraction through Semantic SQL, where analysts write queries against SMDL entities rather than physical tables. The Apache DataFusion engine handles translation to platform-specific SQL, abstracting differences in float casting, DATE_TRUNC argument order, window frame syntax, and identifier quoting across PostgreSQL, BigQuery, Snowflake, Redshift, and Yellowbrick. CoginitiScript blocks add a second abstraction layer, allowing complex transformation logic to be encapsulated in named, parameterized blocks invoked with {{ block-name(args) }} syntax.

See Semantic Intelligence in Action

Coginiti operationalizes business meaning across your entire data estate.