Штучний інтелект

Науковий журнал

ISSN 2710-1673

ONLINE: ISSN 2710-1681

Виберіть свою мову


Застосування LLM-агентів для генерації міграційних SQL-запитів у хмарних обчислювальних платформах

Булка І.І.1, Павлишенко Б.М.1
1 Львівський національний університет імені Івана Франка
ivan.bulka@lnu.edu.ua; bohdan.pavlyshenko@lnu.edu.ua

Повний текст (PDF)

УДК: 004.89
Мова публікації: Англійська
Stuc. intelekt. 2026; 31; (2):87-96

Анотація: Cloud data warehouse and queries migrations between platforms such as Snowflake and Google BigQuery present a persistent engineering challenge: while automated translation tools handle the bulk of SQL conversion, a significant fraction of transformed queries fail at execution time due to dialect divergence, type system incompatibilities, and platform-specific constraints. At scale, manually correcting these failures is time-consuming, error-prone, and does not fit into modern automated migration workflows. Each failed transformation traditionally requires a data engineer to inspect the error, reason about the root cause, produce a fix, and re-run validation, a cycle that becomes the dominant cost driver when hundreds or thousands of transformations are involved. This paper presents an LLM-based self-healing agent that automatically detects, diagnoses, and repairs failed SQL transformations. The system is implemented as a stateful ten-node directed graph using the LangGraph framework, combining large language model reasoning with Retrieval-Augmented Generation (RAG) over BigQuery-specific documentation stored in a FAISS vector index. On each iteration, the agent classifies the active error into one of six failure categories, retrieves semantically relevant documentation passages, performs structured root cause analysis, rewrites the failing query with an explanation of changes, and executes it against the live BigQuery environment. The agent was evaluated on 109 real-world failed SQL transformations from four independent migration projects. Of these, 28 involved irresolvable platform-level constraints and were correctly escalated without consuming the repair budget. On the remaining 81 addressable cases, the agent achieved a fix rate of 75.3%, with 52.5% of successful repairs resolved in a single iteration, demonstrating both effectiveness and efficiency.

Ключові слова: SQL, large language models, LangGraph, Retrieval-Augmented Generation, BigQuery

Посилання:

  1. Pavlyshenko, B. M. (2023). Financial news analytics using fine-tuned Llama 2 GPT model. arXiv preprint arXiv:2308.13032. Available: https://doi.org/10.48550/arXiv.2308.13032
  2. Pavlyshenko, B. M. (2023). Analysis of disinformation and fake news detection using fine-tuned large language model. arXiv preprint arXiv:2309.04704. Available: https://doi.org/10.48550/arXiv.2309.04704
  3. Pavlyshenko, B. M. (2025). Multilevel Analysis of Cryptocurrency News using RAG Approach with Fine-Tuned Mistral Large Language Model. arXiv preprint arXiv:2509.03527. Available: https://doi.org/10.48550/arXiv.2509.03527
  4. Pavlyshenko, B. M. (2025). AI Approaches to Qualitative and Quantitative News Analytics on NATO Unity. arXiv preprint arXiv:2505.06313. Available: https://doi.org/10.48550/arXiv.2505.06313
  5. Pavlyshenko, B., & Bulka, I. (2024). Metric-based comparison of fine-tuned LLaMA 2 and Mixtral large language models for instruction tasks. Electronics and information technologies/Електроніка та інфор-маційні технології, (26). Available: http://dx.doi.org/10.30970/eli.26.2
  6. Pavlyshenko, B., & Bulka, I. (2025). PARAMETER EFFICIENT FINE-TUNING AND OVERFITTING IN GPT LARGE LANGUAGE MODELS: A METRIC- BASED COMPARISON. Electronics and information technologies/Електроніка та інформаційні технології, (30), 33-42. Available: http://dx.doi.org/10.30970/eli.30.3
  7. Presler-Marshall, K., Heckman, S., & Stolee, K. (2021, May). SQLRepair: Identifying and repairing mistakes in student-authored SQL queries. In 2021 IEEE/ACM 43rd International Conference on Software Engineering: Software Engineering Education and Training (ICSE-SEET) (pp. 199-210). IEEE. Available: http://dx.doi.org/10.1109/ICSE-SEET52601.2021.00030
  8. Mohammed, A. K., Kashif, M., & Ansari, S. F. Cloud-Native Framework for Enterprise Business Intelligence with AI-Driven Scalability Using Snowflake and Big Query. Available: http://dx.doi.org/10.7753/IJSEA1412.1010
  9. Joel, S., Wu, J., & Fard, F. (2024). A survey on llm-based code generation for low-resource and domain-specific programming languages. ACM Transactions on Software Engineering and Methodology. Available: https://doi.org/10.1145/3770084
  10. Mu, F., Shi, L., Wang, S., Yu, Z., Zhang, B., Wang, C., ... & Wang, Q. (2024). Clarifygpt: A framework for enhancing llm-based code generation via requirements clarification. Proceedings of the ACM on Software Engineering, 1(FSE), 2332-2354. Available: https://doi.org/10.1145/3660810
  11. Zhang, Z., Wang, C., Wang, Y., Shi, E., Ma, Y., Zhong, W., ... & Zheng, Z. (2025). Llm hallucinations in practical code generation: Phenomena, mechanism, and mitigation. Proceedings of the ACM on Software Engineering, 2(ISSTA), 481-503. Available: https://doi.org/10.1145/3728894
  12. Orgad, H., Toker, M., Gekhman, Z., Reichart, R., Szpektor, I., Kotek, H., & Belinkov, Y. (2024). Llms know more than they show: On the intrinsic representation of llm hallucinations. arXiv preprint arXiv:2410.02707. Available: https://doi.org/10.48550/arXiv.2410.02707
  13. Bouzenia, I., Devanbu, P., & Pradel, M. (2025, April). Repairagent: An autonomous, llm-based agent for program repair. In 2025 IEEE/ACM 47th International Conference on Software Engineering (ICSE) (pp. 2188-2200). IEEE. Available: http://dx.doi.org/10.1109/ICSE55347.2025.00157
  14. Li, Z., Jiang, Z., Huang, Q., & Gu, Q. (2025, April). LLM-BL: Large Language Models are Zero-Shot Rankers for Bug Localization. In 2025 IEEE/ACM 33rd International Conference on Program Comprehension (ICPC) (pp. 548-559). IEEE Computer Society. Available: http://dx.doi.org/10.1109/ICPC66645.2025.00064
  15. Ságodi, Z., Antal, G., Bogenfürst, B., Isztin, M., Hegedűs, P., & Ferenc, R. (2024, June). Reality check: Assessing GPT-4 in fixing real-world software vulnerabilities. In Proceedings of the 28th International Conference on Evaluation and Assessment in Software Engineering (pp. 252-261). Available: https://doi.org/10.1145/3661167.3661207
  16. Zhang, Q., Fang, C., Xie, Y., Ma, Y., Sun, W., Yang, Y., & Chen, Z. (2024). A systematic literature review on large language models for automated program repair. ACM Transactions on Software Engineering and Methodology. Available: https://doi.org/10.1145/3799693
  17. Bag, S., Gupta, A., Kaushik, R., & Jain, C. (2024, July). RAG beyond text: enhancing image retrieval in RAG systems. In 2024 International Conference on Electrical, Computer and Energy Technologies (ICECET (pp. 1-6). IEEE. Available: http://dx.doi.org/10.1109/ICECET61485.2024.10698598
  18. AboulEla, S., Zabihitari, P., Ibrahim, N., Afshar, M., & Kashef, R. (2025, April). Exploring RAG solutions to reduce hallucinations in LLMs. In 2025 IEEE International systems Conference (SysCon) (pp. 1-8). IEEE. Available: http://dx.doi.org/10.1109/SysCon64521.2025.11014810
  19. Ni, X., Wang, Q., Zhang, Y., & Hong, P. (2025). Toolfactory: Automating tool generation by leveraging llm to understand rest api documentations. arXiv preprint arXiv:2501.16945. Available: https://doi.org/10.48550/arXiv.2501.16945
  20. Lai, J., Zhang, J., Liu, J., Li, J., Lu, X., & Guo, S. (2024). Spider: Any-to-many multimodal llm. arXiv preprint arXiv:2411.09439. Available: https://doi.org/10.48550/arXiv.2411.09439
  21. Wang, Y., Zhang, Y., Li, G., Zhi, C., Li, B., Huang, F., ... & Deng, S. (2025). InspectCoder: Dynamic Analysis-Enabled Self Repair through interactive LLM-Debugger Collaboration. arXiv preprint arXiv:2510.18327. Available: https://doi.org/10.48550/arXiv.2510.18327
  22. Douze, M., Guzhva, A., Deng, C., Johnson, J., Szilvasy, G., Mazaré, P. E., ... & Jégou, H. (2025). The faiss library. IEEE Transactions on Big Data. Available: http://dx.doi.org/10.1109/TBDATA.2025.3618474
  23. Qin, C., Deng, C., Huang, J., Shu, K., & Bai, M. (2020, April). An efficient faiss-based search method for mass spectral library searching. In 2020 3rd International Conference on Advanced Electronic Materials, Computers and Software Engineering (AEMCSE) (pp. 513-518). IEEE. Available: http://dx.doi.org/10.1109/AEMCSE50948.2020.00116
  24. Steck, H., Ekanadham, C., & Kallus, N. (2024, May). Is cosine-similarity of embeddings really about similarity? In Companion Proceedings of the ACM Web Conference 2024 (pp. 887-890). Available: https://doi.org/10.1145/3589335.3651526
  25. Huang, X., Peng, H., Zou, D., Liu, Z., Li, J., Liu, K., ... & Yu, P. S. (2024). Cosent: Consistent sentence embedding via similarity ranking. IEEE/ACM Transactions on Audio, Speech, and Language Processing, 32, 2800-2813. Available: http://dx.doi.org/10.1109/TASLP.2024.3402087

Переглянути повний текст статті (PDF)