# Fleet Intelligence Ebike

> E-bike fleet intelligence using synthetic datasets generated by Data Studio in ORS Control Panel. Reads from SYNTHETIC_DATASETS.UNIFIED via projection views (TRIPS, ORIGINS_ENRICHED) filtered by CONFIG table. Use when: setting up e-bike fleet data, e-bike fleet intelligence. Do NOT use for: car fleet simulation (use fleet-intelligence-car), route deviation analysis, or route optimization demos. Triggers: setup e-bike fleet, e-bike fleet intelligence, generate e-bike locations.

- Skill: `snowflake-labs/fleet-intelligence-ebike` (Agent Skill, multi-file: 3 files)
- Install (CLI): `npx skillmds@latest add snowflake-labs/fleet-intelligence-ebike`
- Raw SKILL.md: https://api.skillmd.com/api/skills/snowflake-labs/fleet-intelligence-ebike/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: snowflake-labs (https://skillmd.com/u/snowflake-labs)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/snowflake-labs/fleet-intelligence-ebike

---


# E-Bike Fleet Intelligence

E-bike fleet intelligence solution powered by **Data Studio** synthetic datasets.

## Data Source

Data is generated using **Data Studio** in the ORS Control Panel, which writes to:
- `SYNTHETIC_DATASETS.UNIFIED.FACT_VEHICLE_TELEMETRY`
- `SYNTHETIC_DATASETS.UNIFIED.FACT_TRIPS`

Projection views in `FLEET_INTELLIGENCE.FLEET_INTELLIGENCE_EBIKE` read active-dataset projections (`V_FACT_TRIPS_CURRENT`, `V_DIM_POIS_CURRENT`) and filter by vehicle type and region via a `CONFIG` table. See [`references/sql-projection-views.sql`](references/sql-projection-views.sql) for the complete view definitions.

**Objects created:**
- `CONFIG` - single-row filter table (VEHICLE_TYPE + REGION)
- `TRIPS` + `ORIGINS_ENRICHED` - React fleet page views

The San Francisco baseline is loaded by `install-fleet-apps` Step 8 into UNIFIED tables.

---

## Configuration

| Parameter | Default | Description |
|-----------|---------|-------------|
| `DATABASE` | `FLEET_INTELLIGENCE` | Target database for all objects |
| `SCHEMA` | `FLEET_INTELLIGENCE_EBIKE` | Schema for projection views and CONFIG |
| `WAREHOUSE` | `ROUTING_ANALYTICS` | Warehouse for queries |
| `VEHICLE_TYPE` | `ebike` | Vehicle type filter applied to UNIFIED tables |
| `REGION` | `san_francisco` | Region filter applied to UNIFIED tables |

## Prerequisites

1. **Snowflake Account** with appropriate privileges
2. **OpenRouteService Native App** installed from Snowflake Marketplace (for Data Studio generation)
3. **Data Studio** dataset generated in ORS Control Panel (or seed data loaded by `install-fleet-apps` Step 8)

## Required Privileges

| Privilege | Scope | Reason |
|-----------|-------|--------|
| CREATE DATABASE | Account | Creates FLEET_INTELLIGENCE database |
| CREATE WAREHOUSE | Account | Creates ROUTING_ANALYTICS warehouse |
| CREATE SCHEMA | Database (FLEET_INTELLIGENCE) | Creates FLEET_INTELLIGENCE_EBIKE schema |
| CREATE TABLE | Schema | Creates CONFIG table |
| CREATE VIEW | Schema | Creates projection views |
| SELECT ON SYNTHETIC_DATASETS.UNIFIED | Schema | Reads Data Studio output tables |

> **Note:** ACCOUNTADMIN is NOT required. Create a custom role with the above privileges.

---

## Error Logging

> Follow the Error Logging convention in AGENTS.md. Log file prefix: `fleet-intelligence-ebike`.

## Quick Start

The primary data path is **Data Studio** in the ORS Control Panel:
1. Open the ORS Control Panel > Data Studio page
2. Select the `ebike` (Urban E-Bike Fleet) profile
3. Configure region, fleet size, and generation parameters
4. Run the generation job

This writes to `SYNTHETIC_DATASETS.UNIFIED.FACT_VEHICLE_TELEMETRY` and `SYNTHETIC_DATASETS.UNIFIED.FACT_TRIPS`. The projection views in Step 10 read from these tables.

### Alternative: Load San Francisco Baseline from Seed Data

Seed data is pre-loaded by `install-fleet-apps` Step 8 into `SYNTHETIC_DATASETS.UNIFIED`. To create the projection views:

Execute `references/seed-data.sql`. This creates CONFIG, TRIPS, and ORIGINS_ENRICHED views over UNIFIED data.

## Workflow

Execute each step in order using `snowflake_sql_execute`. Substitute `{PLACEHOLDER}` values based on the user's chosen configuration before executing.

### CRITICAL: Execution Rules

> **These rules MUST be followed to avoid silent failures:**
>
> 1. **One statement per `snowflake_sql_execute` tool call.** Never combine multiple SQL statements (CREATE, INSERT, SET, USE) in a single tool call. Multi-statement blocks can silently fail -- tables may be created with 0 rows and no error is reported. This rule applies to the `snowflake_sql_execute` tool only; `snow sql -f` and other CLI execution is fine.
>
> 2. **Always use fully qualified object names.** Use `FLEET_INTELLIGENCE.FLEET_INTELLIGENCE_EBIKE.<object>` instead of relying on `USE DATABASE` / `USE SCHEMA`. Session context from `USE` statements does not persist across `snowflake_sql_execute` calls.
>
> 3. **Never use `SET` session variables.** Variables set with `SET VAR = 'value'` do not persist across calls. Instead, substitute literal values directly into the SQL before execution.
>
> 4. **Verify row counts after each CTAS.** Run `SELECT COUNT(*) FROM <table>` after every `CREATE TABLE ... AS SELECT` to catch silent failures early.
>
> 5. **All CREATE statements must include a COMMENT tracking tag** per AGENTS.md convention: `COMMENT = '{"origin":"sf_sit-is-fleet","name":"oss-fleet-intelligence-ebike",...}'`. See `references/sql-projection-views.sql` for tagged SQL.

### Step 1: Set Query Tag for Tracking

```sql
ALTER SESSION SET query_tag = '{"origin":"sf_sit-is-fleet","name":"oss-fleet-intelligence-ebike","version":{"major":1, "minor":0},"attributes":{"is_quickstart":1, "source":"sql"}}';
```

### Step 2: Configure Database, Warehouse, and Schema

Create `FLEET_INTELLIGENCE` database, `ROUTING_ANALYTICS` warehouse, and `FLEET_INTELLIGENCE_EBIKE` schema.

### Step 3: Create Projection Views

Run [`references/sql-projection-views.sql`](references/sql-projection-views.sql) to create CONFIG table + projection views from `SYNTHETIC_DATASETS.UNIFIED`. Creates 3 objects: 1 config table + 2 React views (TRIPS, ORIGINS_ENRICHED).

### Step 4: Verify

```sql
SELECT 'CONFIG' AS TBL, COUNT(*) AS CNT FROM FLEET_INTELLIGENCE.FLEET_INTELLIGENCE_EBIKE.CONFIG
UNION ALL SELECT 'TRIPS', COUNT(*) FROM FLEET_INTELLIGENCE.FLEET_INTELLIGENCE_EBIKE.TRIPS
UNION ALL SELECT 'ORIGINS_ENRICHED', COUNT(*) FROM FLEET_INTELLIGENCE.FLEET_INTELLIGENCE_EBIKE.ORIGINS_ENRICHED;
```

Expected: CONFIG=1, TRIPS and ORIGINS_ENRICHED > 0 (row counts depend on Data Studio generation or seed data).

---

## Troubleshooting

| Issue | Solution |
|-------|----------|
| No data in projection views | Run Data Studio generation with `ebike` profile for your region |
| CONFIG table missing | Run Step 3 to create CONFIG + projection views |

## Cleanup

To remove all objects created by this skill:

```sql
DROP VIEW IF EXISTS FLEET_INTELLIGENCE.FLEET_INTELLIGENCE_EBIKE.ORIGINS_ENRICHED;
DROP VIEW IF EXISTS FLEET_INTELLIGENCE.FLEET_INTELLIGENCE_EBIKE.TRIPS;
DROP TABLE IF EXISTS FLEET_INTELLIGENCE.FLEET_INTELLIGENCE_EBIKE.CONFIG;
DROP SCHEMA IF EXISTS FLEET_INTELLIGENCE.FLEET_INTELLIGENCE_EBIKE;
```

> **Tip:** Use the `cleanup` skill to auto-discover all tagged objects via COMMENT tracking.

