Dial: A Knowledge-Grounded Dialect-Specific NL2SQL System

This paper introduces Dial, a knowledge-grounded framework that addresses the challenges of generating executable SQL across heterogeneous database systems by employing dialect-aware logical planning, a hierarchical intent-aware knowledge base, and an execution-driven debugging loop, achieving significant improvements in translation accuracy and dialect feature coverage on the newly constructed DS-NL2SQL benchmark.

Xiang Zhang, Hongming Xu, Le Zhou, Wei Zhou, Xuanhe Zhou, Guoliang Li, Yuyu Luo, Changdong Liu, Guorun Chen, Jiang Liao, Fan Wu

Published Tue, 10 Ma
📖 4 min read☕ Coffee break read

Imagine you are a master chef (the AI) who needs to cook a specific dish (a database query) for a customer. The customer gives you a simple description: "I want a spicy soup with chicken and carrots."

In the world of databases, this is called NL2SQL (Natural Language to SQL). The problem is that every restaurant (database system like Oracle, MySQL, or PostgreSQL) has its own dialect.

  • Restaurant A says: "You can't use salt; use soy sauce instead."
  • Restaurant B says: "You must chop the carrots before adding them, or the pot explodes."
  • Restaurant C says: "If you want spicy, you must add the pepper after the soup boils, not before."

Most existing AI chefs are trained only on Restaurant A's menu. If you ask them to cook for Restaurant B, they might bring the wrong ingredients, use the wrong knife, or ignore the safety rules, causing the kitchen to shut down (an error).

"Dial" is a new, super-smart kitchen manager designed to solve this. Here is how it works, broken down into simple steps:

1. The "Universal Recipe Card" (Dialect-Aware Logical Query Planning)

Instead of immediately shouting out the specific ingredients for a specific restaurant, Dial first translates the customer's request into a universal, abstract recipe.

  • Analogy: Instead of saying "Add 2 cups of soy sauce," it writes: "Add a salty liquid seasoning."
  • Why it helps: This separates the intent (what the user wants) from the syntax (how the specific database says it). It ensures the chef understands the goal before worrying about the specific rules of the kitchen.

2. The "Giant Rule Book" (HINT-KB)

Dial doesn't just guess; it carries a massive, organized library called HINT-KB. Think of this as a library with three specific sections:

  • The Dictionary: Tells you that "Soy Sauce" in Restaurant A is called "Salt" in Restaurant B.
  • The Safety Manual: Reminds you that in Restaurant C, you cannot put the lid on while the soup is boiling (a hidden rule).
  • The Cheat Sheet: Shows you exactly how to chop carrots for Restaurant D so they don't burn.
  • Why it helps: Most AI models try to memorize these rules in their brain. If they forget, they hallucinate. Dial looks them up in a structured book, ensuring it never mixes up the rules.

3. The "Taste Test & Fix" Loop (Adaptive Debugging)

Even with a recipe and a book, mistakes happen. Maybe the chef used a slightly wrong knife.

  • The Old Way: If the soup tastes bad, the AI just guesses a new recipe from scratch, often changing the flavor entirely (e.g., turning soup into a salad).
  • The Dial Way: Dial runs the query in the database. If the database says, "Error! You can't use soy sauce here," Dial doesn't panic.
    1. It checks the Rule Book to see the correct ingredient.
    2. It swaps the ingredient.
    3. Crucially: It checks the Universal Recipe Card to make sure it didn't accidentally change the soup into a salad while fixing the salt. It keeps the flavor (logic) the same while fixing the ingredients (syntax).

4. The "Learning Kitchen" (Incremental Knowledge)

Every time Dial fixes a mistake, it writes a new note in its Rule Book.

  • Analogy: If a new chef joins and learns that "Restaurant X hates cilantro," Dial writes that down so the next time someone orders for Restaurant X, it remembers immediately. It gets smarter over time without needing to be retrained from scratch.

The Result?

The researchers tested Dial on six different "restaurants" (databases like Oracle, MySQL, PostgreSQL, etc.).

  • Old AI Chefs: Often failed because they tried to use MySQL rules in an Oracle kitchen, leading to broken dishes (errors).
  • Dial: Successfully cooked the dish correctly in almost every kitchen, using the right local ingredients and following all local safety rules.

In short: Dial is a translator that doesn't just translate words; it translates intent while respecting the unique grammar, laws, and quirks of every specific database system, ensuring the final result actually works.