Get the FREE Ultimate OpenClaw Setup Guide →

query-translator

npx machina-cli add skill a5c-ai/babysitter/query-translator --openclaw
Files (1)
SKILL.md
2.2 KB

Query Translator Skill

Translates SQL queries between different database dialects, handling function mapping, syntax differences, and performance optimization.

Purpose

Enable SQL migration for:

  • Dialect conversion
  • Function mapping
  • Syntax translation
  • Performance hint conversion
  • Query optimization suggestions

Capabilities

1. Dialect Conversion

  • Oracle to PostgreSQL
  • SQL Server to MySQL
  • MySQL to PostgreSQL
  • And more combinations

2. Function Mapping

  • Date/time functions
  • String functions
  • Math functions
  • Custom function equivalents

3. Syntax Translation

  • Pagination (LIMIT/OFFSET/ROWNUM)
  • String concatenation
  • NULL handling
  • Boolean expressions

4. Performance Hint Conversion

  • Index hints
  • Join hints
  • Optimizer directives
  • Execution plan guidance

5. Query Optimization Suggestions

  • Index recommendations
  • Query restructuring
  • Join optimization
  • Subquery refactoring

Tool Integrations

ToolPurposeIntegration Method
SQLGlotUniversal SQL parserLibrary
AWS SCTSchema conversionCLI
ora2pgOracle to PostgreSQLCLI
pgLoaderMySQL to PostgreSQLCLI
SSMASQL Server migrationCLI

Output Schema

{
  "translationId": "string",
  "timestamp": "ISO8601",
  "source": {
    "dialect": "string",
    "query": "string"
  },
  "target": {
    "dialect": "string",
    "query": "string"
  },
  "transformations": [
    {
      "type": "function|syntax|hint",
      "original": "string",
      "translated": "string",
      "notes": "string"
    }
  ],
  "optimizations": [],
  "warnings": [],
  "manualReviewNeeded": []
}

Integration with Migration Processes

  • database-schema-migration: Query migration
  • cloud-migration: Cloud database adaptation

Related Skills

  • schema-comparator: Schema analysis
  • data-migration-validator: Validation queries

Related Agents

  • database-migration-orchestrator: Uses for migration

Source

git clone https://github.com/a5c-ai/babysitter/blob/main/plugins/babysitter/skills/babysit/process/specializations/code-migration-modernization/skills/query-translator/SKILL.mdView on GitHub

Overview

Translates SQL queries between database dialects, handling function mappings, syntax differences, and performance hints. Supports common migrations (Oracle to PostgreSQL, SQL Server to MySQL, and more) and returns structured transformation details for review and tooling integration.

How This Skill Works

The skill leverages universal parsers and dialect adapters to map functions, rewrite syntax (-pagination, string concat, NULL handling), and convert performance hints. It outputs a translation payload that includes the original and target queries, a list of transformations, and any warnings or required reviews.

When to Use It

  • Migrating a production query from Oracle to PostgreSQL.
  • Porting SQL Server queries to MySQL while preserving logic and behavior.
  • Standardizing queries across teams with PostgreSQL as the target engine.
  • Converting pagination, string concatenation, and NULL handling during migration.
  • Translating performance hints and optimizer directives for a new dialect.

Quick Start

  1. Step 1: Specify source dialect and the SQL query to translate.
  2. Step 2: Choose the target dialect and run the translator.
  3. Step 3: Review the transformations and test the translated query.

Best Practices

  • Define source and target dialects clearly before translation.
  • Explicitly map date/time, string, and math functions to target equivalents.
  • Validate translated queries against a representative test dataset.
  • Preserve or adapt index and join hints to match the target engine.
  • Review performance recommendations and refactor subqueries as needed.

Example Use Cases

  • Oracle → PostgreSQL: ROWNUM pagination and SYSDATE equivalents.
  • SQL Server → MySQL: TOP clause mapped to LIMIT with proper OFFSET handling.
  • Oracle → PostgreSQL: string concatenation from || to CONCAT or equivalent.
  • PostgreSQL → Oracle: NULL handling and three-valued logic adjustments.
  • MySQL → PostgreSQL: function mappings for date/time and numeric operations.

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers