---
phase: 34.1-close-ddl-gaps-vs-snowflake
plan: 02
subsystem: ddl
tags: [show, dimensions, metrics, facts, vtab, parser, introspection]

# Dependency graph
requires:
  - phase: 34.1-01
    provides: AlterRename DdlKind variants, updated parse.rs pattern
provides:
  - SHOW SEMANTIC DIMENSIONS (IN view_name | cross-view)
  - SHOW SEMANTIC METRICS (IN view_name | cross-view)
  - SHOW SEMANTIC FACTS (IN view_name | cross-view)
  - ShowDimensions, ShowMetrics, ShowFacts DdlKind variants
  - 6 new table functions registered in extension
affects: [34.1-03-verification, documentation, Snowflake parity]

# Tech tracking
tech-stack:
  added: []
  patterns: [VTab pair pattern (single-view + all-views), SHOW with optional IN clause]

key-files:
  created:
    - src/ddl/show_dims.rs
    - src/ddl/show_metrics.rs
    - src/ddl/show_facts.rs
    - test/sql/phase34_1_show_commands.test
  modified:
    - src/parse.rs
    - src/ddl/mod.rs
    - src/lib.rs
    - test/sql/TEST_LIST

key-decisions:
  - "Each SHOW entity has two VTab structs (single-view with 1 param, cross-view with 0 params) sharing BindData/InitData types"
  - "SHOW DIMENSIONS/METRICS output 5 columns (semantic_view_name, name, expr, source_table, data_type); FACTS output 4 columns (no data_type since Fact has no output_type)"
  - "Empty source_table/data_type rendered as empty string (not NULL) for consistency with model defaults"
  - "SHOW commands detect IN keyword case-insensitively for view name scoping"

patterns-established:
  - "VTab pair pattern: single-view variant takes VARCHAR param, cross-view variant takes no params, both share bind/init types"
  - "SHOW with optional IN clause: rewrite_ddl branches on empty vs IN-prefixed remainder"

requirements-completed: [DDL-03, DDL-04, DDL-05, DDL-06]

# Metrics
duration: 13min
completed: 2026-03-22
---

# Phase 34.1 Plan 02: SHOW SEMANTIC DIMENSIONS/METRICS/FACTS Summary

**Three SHOW commands with parser detection, VTab implementations for single-view and cross-view introspection, 6 registered table functions, and sqllogictest coverage**

## Performance

- **Duration:** 13 min
- **Started:** 2026-03-22T12:39:05Z
- **Completed:** 2026-03-22T12:52:17Z
- **Tasks:** 2
- **Files modified:** 8

## Accomplishments
- SHOW SEMANTIC DIMENSIONS with IN view_name and cross-view forms for dimension introspection
- SHOW SEMANTIC METRICS with IN view_name and cross-view forms for metric introspection
- SHOW SEMANTIC FACTS with IN view_name and cross-view forms for fact introspection
- Full sqllogictest coverage: scoped queries, cross-view queries, error cases, case insensitivity

## Task Commits

Each task was committed atomically:

1. **Task 1: Parser detection, VTabs, and registration** - `26c916d` (feat)
2. **Task 2: sqllogictest coverage** - `803da9d` (test)

## Files Created/Modified
- `src/ddl/show_dims.rs` - ShowSemanticDimensionsVTab and ShowSemanticDimensionsAllVTab table functions
- `src/ddl/show_metrics.rs` - ShowSemanticMetricsVTab and ShowSemanticMetricsAllVTab table functions
- `src/ddl/show_facts.rs` - ShowSemanticFactsVTab and ShowSemanticFactsAllVTab table functions (4 columns, no data_type)
- `src/parse.rs` - ShowDimensions, ShowMetrics, ShowFacts DdlKind variants, detection, rewrite, validation
- `src/ddl/mod.rs` - Module declarations for show_dims, show_metrics, show_facts
- `src/lib.rs` - Registration of 6 new table functions via register_table_function_with_extra_info
- `test/sql/phase34_1_show_commands.test` - 8 test cases for all SHOW commands
- `test/sql/TEST_LIST` - Added phase34_1_show_commands.test to test runner list

## Decisions Made
- Each SHOW entity type uses a VTab pair: single-view variant (1 VARCHAR param, errors on non-existent view) and cross-view variant (0 params, iterates all catalog entries)
- SHOW DIMENSIONS and METRICS output 5 VARCHAR columns; SHOW FACTS outputs 4 columns (Fact model has no output_type field)
- Empty values (no source_table, no output_type) rendered as empty strings rather than NULLs, consistent with model defaults
- Results sorted by (semantic_view_name, name) for deterministic output

## Deviations from Plan

### Auto-fixed Issues

**1. [Rule 3 - Blocking] Fixed DDL syntax in test (plan used non-existent := / SOURCE / TYPE syntax)**
- **Found during:** Task 2 (sqllogictest creation)
- **Issue:** Plan's test DDL used `:=` assignment and `SOURCE`/`TYPE` keywords that don't exist in the body parser. Actual DDL syntax is `alias.name AS expr` with source_table inferred from alias prefix.
- **Fix:** Wrote test using actual DDL syntax (`alias.name AS expr`), adjusted expected output (data_type is empty string, not explicit type)
- **Files modified:** test/sql/phase34_1_show_commands.test
- **Verification:** All 15 sqllogictests pass

**2. [Rule 3 - Blocking] Added test file to TEST_LIST**
- **Found during:** Task 2 (sqllogictest verification)
- **Issue:** New test file was not discovered by the test runner because tests are driven by `test/sql/TEST_LIST` file, not auto-discovery
- **Fix:** Added `test/sql/phase34_1_show_commands.test` to `test/sql/TEST_LIST`
- **Files modified:** test/sql/TEST_LIST
- **Verification:** Test runner now picks up and passes the new test file (15/15 pass)

**3. [Rule 1 - Bug] Fixed `statement error` format in sqllogictest**
- **Found during:** Task 2 (sqllogictest verification)
- **Issue:** DuckDB sqllogictest requires error substring after `----` separator, not inline with `statement error`
- **Fix:** Added `----` separator and `does not exist` error substring
- **Files modified:** test/sql/phase34_1_show_commands.test
- **Verification:** Test runner parses and passes the error test case

---

**Total deviations:** 3 auto-fixed (1 bug, 2 blocking)
**Impact on plan:** All auto-fixes necessary for test correctness. No scope creep.

## Issues Encountered

Parallel execution with Plan 01: Both plans modified `src/parse.rs`, `src/ddl/mod.rs`, and `src/lib.rs` concurrently. Plan 01 committed first (`a6240a5`) and its commit inadvertently captured Plan 02's in-progress edits to these files. Plan 02's commit (`26c916d`) correctly adds only the 3 new VTab files. All changes are committed across the two commits.

## User Setup Required

None - no external service configuration required.

## Next Phase Readiness
- All 3 SHOW commands operational and tested
- Phase 34.1-03 (verification) can proceed -- all DDL surface parity features from Phase 34.1 are implemented

## Self-Check: PASSED

- [x] src/ddl/show_dims.rs exists
- [x] src/ddl/show_metrics.rs exists
- [x] src/ddl/show_facts.rs exists
- [x] test/sql/phase34_1_show_commands.test exists
- [x] Commit 26c916d exists (Task 1)
- [x] Commit 803da9d exists (Task 2)

---
*Phase: 34.1-close-ddl-gaps-vs-snowflake*
*Completed: 2026-03-22*
