-
Notifications
You must be signed in to change notification settings - Fork 35
feat(datafabric-tool): ground relationship-field joins in text-to-SQL prompt [DS-8791] #962
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
7515c08
f69f837
8487c17
df93952
312b81c
b46a4ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -157,10 +157,15 @@ | |
|
|
||
| ### 2. Multi-Entity Joins (≤4 adapters) | ||
| - INNER JOIN chains via entity model (up to 4 tables) | ||
| - Equi-joins only (ON left.col = right.col) | ||
| - LEFT JOIN is allowed ONLY for relationship (foreign-key) joins on the related | ||
| entity's Id (see "Relationship fields" guidance) — use it for optional | ||
| relationships to keep parent rows | ||
|
Comment on lines
+161
to
+163
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When callers render this builder with Useful? React with 👍 / 👎.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. v0 is not going to be used |
||
| - Shared intermediates | ||
|
|
||
| **Examples:** | ||
| - SELECT o.id, c.name FROM Order o INNER JOIN Customer c ON o.customer_id = c.id | ||
| - SELECT o.id, a.Name FROM Order o LEFT JOIN Account a ON a.Id = o.account -- relationship join, keeps orders with no account | ||
| - Fields spanning 3-4 adapters with proper INNER JOIN chains | ||
|
|
||
| ### 3. Predicate Distribution & Pushdown | ||
|
|
@@ -253,7 +258,7 @@ | |
| - Common Table Expressions (WITH/CTE) | ||
| - Window functions (ROW_NUMBER, RANK, PARTITION BY) | ||
| - Self-joins | ||
| - LEFT JOIN, RIGHT JOIN, FULL OUTER JOIN (only INNER JOIN supported) | ||
| - RIGHT JOIN, FULL OUTER JOIN (general joins must be INNER; LEFT JOIN only for relationship/foreign-key joins on Id) | ||
| - CROSS JOIN | ||
|
|
||
| **Examples:** | ||
|
|
@@ -275,17 +280,17 @@ | |
|
|
||
| ### 4. ADVANCED_JOINS | ||
| - More than 4 tables in JOIN chain | ||
| - LEFT JOIN | ||
| - LEFT JOIN for non-relationship joins (LEFT JOIN is allowed ONLY to join a relationship/foreign-key field to its related entity on Id) | ||
| - RIGHT JOIN | ||
| - FULL OUTER JOIN | ||
| - CROSS JOIN | ||
| - Self-joins | ||
| - Non-equi joins (theta joins) | ||
|
|
||
| **Examples:** | ||
| - SELECT * FROM t1 RIGHT JOIN t2 -- ❌ | ||
| - SELECT * FROM t1, t2 -- ❌ (implicit CROSS JOIN) | ||
| - SELECT * FROM Employee e1 JOIN Employee e2 ON e1.manager_id = e2.id -- ❌ (self-join) | ||
| - SELECT c.id FROM t1 c RIGHT JOIN t2 d ON d.id = c.fk -- ❌ | ||
| - SELECT c.id FROM t1 c, t2 d -- ❌ (implicit CROSS JOIN) | ||
| - SELECT e1.id FROM Employee e1 JOIN Employee e2 ON e1.manager_id = e2.id -- ❌ (self-join) | ||
|
|
||
| ### 5. UNSUPPORTED_FUNCTIONS | ||
| - Date/time manipulation functions (DATE_ADD, DATE_SUB, DATEDIFF) | ||
|
|
@@ -336,7 +341,7 @@ | |
|
|
||
| 1. **ALWAYS use explicit column names** - Never use SELECT * | ||
| 2. **Use COUNT(column_name)** - Never use COUNT(*) | ||
| 3. **Only INNER JOIN** - No LEFT JOIN, RIGHT JOIN, FULL OUTER JOIN, or CROSS JOIN | ||
| 3. **INNER JOIN by default; LEFT JOIN only for relationships** - General joins must be INNER JOIN (equi-join). LEFT JOIN is permitted ONLY to join a relationship (foreign-key) field to its related entity on Id — use it for optional relationships to keep parent rows, INNER JOIN when the related row must exist. No RIGHT JOIN, FULL OUTER JOIN, CROSS JOIN, or self-joins | ||
| 4. **Maximum 4 tables** - No more than 4 tables in a JOIN chain | ||
| 5. **No subqueries** - No subqueries in any clause | ||
| 6. **No CTEs** - No WITH clauses | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed