Xpose通过双向工程提取复杂SQL查询,提升数据库逆向工程能力。
Xpose: Bi-directional Engineering for Hidden Query Extraction
- 结合正向工程与逆向工程,利用LLM理解业务描述生成查询框架。
- 成功提取含并集、嵌套子查询、外连接等复杂结构的SQL语句。
- 适用于数据库迁移、安全分析等真实场景,覆盖TPCH与STACK基准。
查询逆向工程(QRE)旨在根据给定的数据库和结果实例合成对应SQL查询。近期一种变体称为隐式查询提取(HQE),即在仅提供输入输出示例和一个包含真实查询的不可见可执行程序的前提下,非侵入式地还原该查询。现有工具仅能提取带键值等值连接和合取算术过滤条件的扁平查询,适用范围有限。本文提出Xpose,首次实现对真实复杂查询(如TPCH基准中典型查询)的高效提取。采用双路径策略:一是大幅扩展逆向工程能力,支持并集、代数过滤条件及值/谓词的析取;二是引入大语言模型进行正向工程,将应用业务描述转化为提取指导,识别嵌套子查询、外连接、标量函数等常见结构。正向工程确定查询整体轮廓,逆向工程填充细节。在扩展版TPCH(E-TPCH)和真实世界STACK基准上验证表明,该方法准确提取复杂查询,显著提升了HQE的覆盖范围。
原文摘要 · Abstract (English)
Query reverse engineering (QRE) aims to synthesize a SQL query to connect a given database and result instance. A recent variation of QRE is where an additional input, an opaque executable containing a ground-truth query, is provided, and the goal is to non-invasively extract this specific query through only input-output examples. This variant, called Hidden Query Extraction (HQE), has a spectrum of industrial use-cases including query recovery, database security, and vendor migration. The reverse engineering (RE) tools developed for HQE, which are based on database mutation and generation techniques, can only extract flat queries with key-based equi joins and conjunctive arithmetic filter predicates, making them limited wrt both query structure and query operators. In this paper, we present Xpose, a HQE solution that elevates the extraction scope to realistic complex queries, such as those found in the TPCH benchmark. A two-pronged approach is taken: (1) The existing RE scope is substantially extended to incorporate union connectors, algebraic filter predicates, and disjunctions for both values and predicates. (2) The predictive power of LLMs is leveraged to convert business descriptions of the opaque application into extraction guidance, representing ``forward engineering" (FE). The FE module recognizes common constructs, such as nesting of sub-queries, outer joins, and scalar functions. In essence, FE establishes the broad query contours, while RE fleshes out the fine-grained details. We have evaluated Xpose on (a) E-TPCH, a query suite comprising the complete TPCH benchmark extended with queries featuring unions, diverse join types, and sub-queries; and (b) the real-world STACK benchmark. The experimental results demonstrate that its bi-directional engineering approach accurately extracts these complex queries, representing a significant step forward with regard to HQE coverage.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。