Complete SQL diagnostics and editor accessibility

This commit is contained in:
2026-07-31 17:18:26 +02:00
parent 28a92feb32
commit 8724591bf9
7 changed files with 494 additions and 76 deletions
+42
View File
@@ -138,6 +138,48 @@ class DataflowGraphAndSqlTests(unittest.TestCase):
with self.subTest(sql=sql), self.assertRaises(SqlCompilationError):
compile_sql(sql, source_nodes=[inline_source()])
def test_sql_diagnostics_include_stable_source_locations(self) -> None:
cases = (
(
"SELECT *\nFROM monthly_files\nQUALIFY amount > 2",
"sql.unsupported_clause",
(3, 9, 3, 18, 36, 45),
),
(
"SELECT *\nFROM monthly_files\n"
"WHERE status = 'open' OR amount > 1",
"sql.or",
(3, 7, 3, 35, 34, 62),
),
(
"SELECT *\nFROM",
"sql.parse",
(2, 1, 2, 4, 9, 12),
),
)
for sql, code, expected_location in cases:
with self.subTest(code=code), self.assertRaises(SqlCompilationError) as raised:
compile_sql(sql, source_nodes=[inline_source()])
diagnostic = raised.exception.diagnostics[0]
self.assertEqual(code, diagnostic.code)
self.assertEqual("sql_text", diagnostic.field)
self.assertIsNotNone(diagnostic.source_location)
location = diagnostic.source_location
assert location is not None
self.assertEqual(
expected_location,
(
location.start_line,
location.start_column,
location.end_line,
location.end_column,
location.start_offset,
location.end_offset,
),
)
def test_compiles_renders_and_executes_two_source_join(self) -> None:
sql = """
SELECT monthly_files.department, lookup.label