<?xml-model href='http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng' schematypens='http://relaxng.org/ns/structure/1.0'?><TEI xmlns="http://www.tei-c.org/ns/1.0">
	<teiHeader>
		<fileDesc>
			<titleStmt><title level='a'>Relational Query Synthesis ⋈ Decision Tree Learning</title></titleStmt>
			<publicationStmt>
				<publisher>ACM</publisher>
				<date>10/01/2023</date>
			</publicationStmt>
			<sourceDesc>
				<bibl> 
					<idno type="par_id">10625801</idno>
					<idno type="doi">10.14778/3626292.3626306</idno>
					<title level='j'>Proceedings of the VLDB Endowment</title>
<idno>2150-8097</idno>
<biblScope unit="volume">17</biblScope>
<biblScope unit="issue">2</biblScope>					

					<author>Aaditya Naik</author><author>Aalok Thakkar</author><author>Adam Stein</author><author>Rajeev Alur</author><author>Mayur Naik</author>
				</bibl>
			</sourceDesc>
		</fileDesc>
		<profileDesc>
			<abstract><ab><![CDATA[<p>We study the problem of synthesizing a core fragment of relational queries called select-project-join (SPJ) queries from input-output examples. Search-based synthesis techniques are suited to synthesizing projections and joins by navigating the network of relational tables but require additional supervision for synthesizing comparison predicates. On the other hand, decision tree learning techniques are suited to synthesizing comparison predicates when the input database can be summarized as a single labelled relational table. In this paper, we adapt and interleave methods from the domains of relational query synthesis and decision tree learning, and present an end-to-end framework for synthesizing relational queries with categorical and numerical comparison predicates. Our technique guarantees the completeness of the synthesis procedure and strongly encourages minimality of the synthesized program. We present Libra, an implementation of this technique and evaluate it on a benchmark suite of 1,475 instances of queries over 159 databases with multiple tables. Libra solves 1,361 of these instances in an average of 59 seconds per instance. It outperforms state-of-the-art program synthesis tools Scythe and PatSQL in terms of both the running time and the quality of the synthesized programs.</p>]]></ab></abstract>
		</profileDesc>
	</teiHeader>
	<text><body xmlns="http://www.tei-c.org/ns/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink">
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="1">INTRODUCTION</head><p>The problem of learning relational logic programs from inputoutput data has been widely studied in inductive logic programming (ILP) and program synthesis <ref type="bibr">[8,</ref><ref type="bibr">13]</ref>. Such programs offer a variety of benefits by virtue of being explainable, interpretable, generalizable, This work is licensed under the Creative Commons BY-NC-ND 4.0 International License. Visit <ref type="url">https://creativecommons.org/licenses/by-nc-nd/4.0/</ref> to view a copy of this license. For any use beyond those covered by this license, obtain permission by emailing info@vldb.org. Copyright is held by the owner/author(s). Publication rights licensed to the VLDB Endowment. Proceedings of the VLDB Endowment, Vol. 17, No. 2 ISSN 2150-8097. doi:10.14778/3626292.3626306 verifiable, and composable. The automated synthesis of such programs finds applications in a variety of settings including extracting and summarizing information from complex relational databases as well as data exploration and discovery without requiring indepth knowledge of the underlying schema <ref type="bibr">[8,</ref><ref type="bibr">33,</ref><ref type="bibr">39,</ref><ref type="bibr">43]</ref> (see <ref type="bibr">[42]</ref> for how interactions with human experts on Stack Overflow to search for the desired SQL query can be replaced by synthesis from input-output examples).</p><p>These programs involve two core components: joins across multiple tables in a database, and comparison predicates that filter out rows. As such, learning logic queries involves addressing two fundamental and inter-dependent challenges, which are synthesizing joins and synthesizing comparison predicates. Recent works in learning logic programs focus on addressing either of the two challenges in an automated manner, but not both. To address both challenges simultaneously, they rely on additional user supervision.</p><p>Consider the example of university records of students taking courses, subjects students are majoring in, and departments in a university, as shown in Figure <ref type="figure">1</ref>. Suppose the user intends to discover a concept that explains students 'Alice' and 'Bob', but excludes 'Charlie' and 'David'. The simplest explanation is that 'Alice' and 'Bob' take an undergraduate course (a course with ID less than 500) in the Engineering school. This explanation can be expressed as the SQL query shown in Figure <ref type="figure">1c</ref>. The output examples, both positive and negative, are represented by entries from a single column (or a subset of columns) as in Figure <ref type="figure">1b</ref>. We illustrate the two aforementioned challenges using this example.</p><p>Challenge 1: Learning the Join Policy. Learning the join policy corresponds to learning the projections and joins that correspond to the SELECT and FROM clauses in Figure <ref type="figure">1c</ref>. Search-based query synthesis techniques have made significant strides in learning relational queries over multiple tables <ref type="bibr">[27,</ref><ref type="bibr">28,</ref><ref type="bibr">39,</ref><ref type="bibr">40,</ref><ref type="bibr">43]</ref> by effectively enumerating the possible ways in which tables may be joined, thereby specializing in navigating the network of tables in a relational database. ILP techniques use language bias mechanisms such as mode declarations and meta-rules while program synthesis methods enumerate candidate programs using syntactic constraints or an explicit list of candidate rules to define a hypothesis space and explore the different key-foreign key pairs to join tables. Exampleguided techniques rely on the underlying patterns in the data to discover them. All of these techniques struggle to address the challenge of synthesizing comparison predicates like courseID &lt; 500 or school = Engineering required by the target query. Figure <ref type="figure">1</ref>: Example of a task to synthesize a relational query that takes instances of tables registration, department, and major (as in 1a) as input relations &#261; , and outputs a set of student constants that contains all elements of &#267; + and does not contain any elements in &#267; -(as in 1b). The query in 1c is a solution to this task.</p><p>Challenge 2: Learning Comparison Predicates. Most query synthesis techniques require additional supervision from the user in the form of an exhaustive list of constants that may be used in comparisons. On the other hand, decision tree learning techniques <ref type="bibr">[30,</ref><ref type="bibr">44]</ref> solve this problem in a limited setting in which the data is provided as a single table, where each row represents an instance of the input, and each column represents a feature of the instance <ref type="bibr">[25,</ref><ref type="bibr">29]</ref>. In such a setting, the labeling is given by a partition of the instances into positive and negative examples. These techniques then construct classifiers using greedy information gain heuristics to search for and combine locally optimal comparison predicates.</p><p>However, using these techniques requires additional user supervision to produce the single table they take as input. This is typically done by performing key-foreign key joins to construct such a single table and then applying a feature selection method <ref type="bibr">[17]</ref>. For example, the user would have to provide the table from Figure <ref type="figure">2a</ref> to the learning algorithm, along with the correct labels for each row, to obtain the decision tree in Figure <ref type="figure">2b</ref> that corresponds to the WHERE clause in the target query. To obtain this table, the user must manually join the registration and department tables over the deptCode column. This process is tedious and prodigal as it requires a careful analysis of the relational database, and errors in the process can introduce data redundancy and impact the efficiency of the learning algorithm. Manually doing so also becomes intractable for databases with several tables, necessitating the automation of this process. Additionally, the user must provide accurate labels to obtain the correct decision tree, though there is no clear way to do so given only the output examples.</p><p>Our Approach. We thus observe a dichotomy of existing techniques -they either support multi-table databases (as with searchbased relational query synthesis) or excel at learning comparison predicates (as in the case of decision trees), but not both. In this paper, we leverage the strengths of the two paradigms to design an end-to-end algorithm for the synthesis of relational queries that feature both comparison predicates and joins across multiple tables. Specifically, we focus on the class of select-project-join (SPJ) queries like the one in Figure <ref type="figure">1c</ref> which constitute an important fragment of relational algebra <ref type="bibr">[20]</ref>. These queries feature equi-joins, that is joins across tables parameterized by a set of columns (with matching types), as well as categorical and numerical comparisons for selections.</p><p>Our key insight is to interpret the query synthesis problem as a search across a two-dimensional space defined by comparison predicates on one side and candidate joins on the other. To efficiently search through this space, we introduce an interleaved approach that allows us to leverage the strengths of both decision tree learning and search-based synthesis.</p><p>This interleaved approach seeks to address the challenge of finding the optimal join policy by enumerating different projection and join policies as partial queries, each producing a single intermediate table over which a decision tree could be learned to generate the comparison predicates for the target query. We use the example-guided search strategy <ref type="bibr">[40]</ref> to enumerate these queries as it prioritize joins with fewer tables, thus synthesizing queries that contain only sufficient and necessary features from the database.</p><p>Once we generate a candidate single intermediate</p><p>table, the next step is to synthesize comparison predicates. Classical decision tree studentID deptCode courseID school label Alice Comp. 201 Engineering &#10003; Alice Chem. 310 Arts and Science &#215; Alice Mech. 550 Engineering &#215; Bob Mech. 320 Engineering &#10003; Bob Mech. 550 Engineering &#215; Charlie Chem. 310 Arts and Science &#215; David Comp. 500 Engineering &#215; David Mech. 502 Engineering &#215; Erin Chem. 310 Arts and Science ? (a) The result of joining registration and department over the deptCode columns of each table. courseID &lt; 500? &#215; school = Engineering? &#10003; &#215; (b) A decision tree for classifying rows of the table in Figure 2a. It can be flattened to a Boolean formula (courseID &lt; 500) ' (school = Engineering).</p><p>Figure <ref type="figure">2</ref>: Each candidate join can be translated to a single table. The table in 2a represents the join of registration and department tables. The label column denotes the ideal labels which result in learning the decision tree in Figure <ref type="figure">2b</ref>. The user can annotate the rows of this table as positive (&#10003;) or negative (&#215;) to support decision tree learning. On running a decision tree algorithm on it, we get the tree in Figure <ref type="figure">2b</ref>.</p><p>learning techniques require the rows of the intermediate table to be labeled, while in our setting, only certain constants (or tuples of constants) are labeled. There is no straightforward way to handle this discrepancy without additional user supervision. We fundamentally modify the classical decision tree learning algorithm ID3 <ref type="bibr">[30]</ref> by changing the definition of entropy and information gain used by it and present it in Section 3.2. Together, the search for candidate joins and the modified decision tree learning procedure can work in tandem to synthesize the relational queries with categorical and numerical comparisons. In practice, our algorithm synthesizes queries that are general (that is, it does not overfit the data) and of minimal size. We also prove the completeness of the algorithm-it synthesizes a query consistent with the training data iff there exists such a query. We implement this interleaved approach as Libra, and evaluate it on a benchmark suite of 1,475 instances of SPJ queries from the Spider <ref type="bibr">[46]</ref> and Geography <ref type="bibr">[12,</ref><ref type="bibr">21,</ref><ref type="bibr">47]</ref> datasets over 160 different databases, each with multiple tables. Libra solves 1,361 of these instances with a timeout of 10 minutes per task, and takes 58.9 seconds on average per instance. We also compare with state-of-the-art tools Scythe and PatSQL that can synthesize select-project-join queries. They can solve 195 and 673 instances, and take 139.50 and 23.13 seconds on average per task respectively. All the benchmarks solved by the baselines are also solved by at least one instance of our framework, and our framework additionally solves a significantly larger set of the total benchmarks which the baselines fail to solve.</p><p>In summary, our work makes the following contributions:</p><p>(1) We propose a novel approach to split the relational query synthesis problem into two separate sub-problems: synthesizing joins and learning comparison predicates. (2) We implement Libra, an end-to-end synthesis tool that realizes this algorithm, and demonstrate that it outperforms state-ofthe-art approaches on a variety of tasks in terms of synthesis time as well as the quality of the synthesized programs. (3) Further, we show that the algorithm is complete and in practice generates general and minimal queries.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2">PROBLEM FORMULATION</head><p>In this section, we briefly review the syntax and semantics of relational queries and formulate the synthesis problem.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.1">Syntax and Semantics</head><p>In this paper, we study select-project-join queries where selection supports categorical and numerical comparisons, and all joins are equi-joins. We will use SQL syntax to denote all queries.</p><p>To define the syntax of these queries, we first fix a set of input tables and a set of output tables. For simplicity, the columns of each table are of either of the kinds: categorical, numerical, and uncomparable.</p><p>The syntax of the select-project-join queries is defined by the grammar in Figure <ref type="figure">3</ref>. The JOIN operator featured in this query is an equi-join, that is a join parameterized by a set of columns &#258; . Comparisons of the form (&#272; .&#281; = &#289;) or (&#272; .&#281; &#8800; &#289;) are supported only for columns of the categorical kind, all other comparisons are only supported for the numerical kind, and no comparisons are supported for the uncomparable kind.</p><p>For this paper, the size of a query &#269; is defined as the sum of the number of input tables that are joined in it (that is the expansion of non-terminal &#262; ) and the size of the comparisons for the selection operator (&#258;) in disjunctive normal form. For instance, the size of the query &#269; EX is 4 as it has a join of two tables (registration and department) and two comparison operators (registration.courseID g 500) and (department.school = "&#257;&#292;&#285;&#287;&#292;&#283;&#283;&#296;&#287;&#292;&#285;").</p><p>The semantics for these queries are as defined in classical works on relational algebra <ref type="bibr">[1,</ref><ref type="bibr">10,</ref><ref type="bibr">20]</ref>. We denote the set of tuples produced by query &#269; on input tables &#261; as &#231;&#269;&#232;(&#261; ). In this paper we consider the set-semantics and not bag-semantics, that is, a relation is a set of literals with the same predicate (such as registration, instructor, and department).</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.2">Query Synthesis Problem</head><p>Our ultimate goal is to synthesize a select-project-join query (in the syntax of Figure <ref type="figure">3</ref>) that is consistent with the given input-output examples. In this context, an example consists of input and output tuples; the user has labeled the output tuples as either positive or negative. The objective then is to synthesize a program that is consistent with the examples, that is, a program that derives all of the positive tuples and none of the negative tuples.</p><p>Problem 2.1 (Query Synthesis). Given input tables &#261; and a set of output tuples partitioned as &#267; + and &#267; -, return a query &#269; such that &#267; + &#166; &#231;&#269;&#232;(&#261; ) and &#267; -&#8745; &#231;&#269;&#232;(&#261; ) = &#8709;, if such a query exists, and unsat otherwise.</p><p>We further refine the problem specification by identifying the columns of the input tables &#261; as either numerical, categorical, or uncomparable. numerical columns support ordered comparisons while categorical supports only equality checks. Consider the running example from the Introduction as in Figure <ref type="figure">1</ref>. Given the input tables &#261; as registration, department, and major, we aim to synthesize a query &#269; such that it generates both the positively labelled tuples in &#267; + (Alice and Bob) and neither of the negatively labelled tuples in &#267; -(Charlie and David). The query &#269; EX in Figure <ref type="figure">1c</ref> is an example of such a query. Here, courseID is numerical while school is categorical.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3">ALGORITHM</head><p>In this section we describe the end-to-end Libra algorithm, which takes input-output examples &#257; = (&#261;, &#267; + , &#267; -) as input and returns a relational query &#269; consistent with &#257;, that is, it solves Problem 2.1. Algorithm 1 summarises the procedure and Figure <ref type="figure">4</ref> presents its architecture.</p><p>We start with an example-guided search to construct a partial query with projection and joins (and without the comparisons for the selection operator). This partial query is constructed by analyzing patterns of co-occurrence of constants in the input-output examples Section 3.1 formalizes these patterns as enumeration contexts that can be translate into partial queries with projection and join operators. These correspond to the step 2 of the algorithm.</p><p>To synthesize categorical and numerical comparisons for the selection operator we turn to supervised learning. We maintain the enumeration contexts in a priority queue &#264; ordered by increasing size, where the size of each context is given by the number of tuples forming that context. For each context &#255; in &#264;, we convert &#255; into a single table &#272; through a join of the input relation tables that occur in &#255;. This is followed by the modified decision tree learning procedure (DTL) which completes the query. This corresponds to step 4a-4c.</p><p>Algorithm 1 Libra(&#261;, &#267; + , &#267; -), where &#261; is the set of input tuples, and &#267; + and &#267; -are the sets of positively and negatively labeled output tuples respectively.</p><p>(1) Set &#279;&#292;&#297; = unsat and &#266; = &#8734;.</p><p>(2) For an arbitrary &#298; &#8712; &#267; + , let C be the initial contexts that explain &#298; as defined in Equation <ref type="formula">1</ref>. (c) For each table &#272; constructed using Equation <ref type="formula">4</ref>:</p><p>(i) Let &#166; be a node of an empty decision tree. Run</p><p>For each tuple &#298; &#8242; that shares a constant with a tuple in &#255;, update:</p><p>(5) Return &#279;&#292;&#297;.</p><p>In step 4d, we expand the context by one tuple. This corresponds to considering a join with an additional table. Therefore, the steps 4a-4c explore comparison predicates and step 4d explores joins. We thus search through the two-dimensional search space.</p><p>Throughout the algorithm, we maintain the size of the query &#269; as variable &#266; and guarantee that the query &#269; has minimal size among all queries consistent with the input-output example (subject to the optimality of the decision tree). Additionally, if no such query exists, the algorithm terminates and returns unsat. We prove this completeness result in Theorem 3.1.</p><p>Problem 2.1 is known to be co-NP complete in the case of queries without selection with categorical or numerical operators <ref type="bibr">[40]</ref>, and therefore we propose Algorithm 1 that runs in EXPTIME. Observe that the DTL sub-process is analogous to the ID3 algorithm and hence its running time is &#267; (&#292;&#291; log &#291;), where &#292; is the cardinality of input tuples &#261; and &#291; is the total size of output tuples &#267; + and &#267; - <ref type="bibr">[31]</ref>. Therefore, Algorithm 2 runs in time polynomial in the size of the input. In step 4, for each context &#255; in queue &#264;, we construct the possible tables &#272; which are polynomial in the size of the input and for each of them the process DTL is called exactly once. Observe that a context can be dequeued from &#264; at most once and hence, the number of calls to Algorithm 2 are at most polynomial in the total number of possible contexts. As any subset of the input tuples &#261; can be considered as a context, the end-to-end algorithm has EXPTIME complexity.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.1">Example-Guided Enumeration of Projection and Joins</head><p>An enumeration context is a non-empty subset of the input tuples, &#255; &#166; &#261; . The shaded part of Figure <ref type="figure">5</ref>  (Alice, Mech., 550) (Alice, Comp., 201) (David, Comp., 500) (Mech., Engineering) (Comp., Engineering) (Alice, Chem.) (Charlie,Math.)  <ref type="formula">2</ref>.</p><p>Given a tuple &#298; &#8712; &#267; + , we construct the initial set of enumeration contexts for step 2 of Algorithm 1 by considering enumeration contexts: C = {{&#298; : for each column &#281; of &#298;,</p><p>In step 4d we extend a context &#255; by adding a tuple &#298; &#8242; such that for some &#298; &#8712; &#255;, there is an edge &#298; &#8594; &#298; &#8242; &#8712; &#257; with appropriate labels. One can translate a context &#255; = {&#298; 1 , . . . , &#298; } and an output tuple &#298; into a partial query with projection and joins.</p><p>Consider the output 'Alice' that is explained by the context &#255; = {(Alice, Comp., 201), (Comp., Engineering)}</p><p>. This can be translated to the query:</p><p>This is because the constant 'Alice' occurs in the column studentID of registration, and the tuples from the tables registration and department share a constant for the columns department.deptCode and registration.deptCode. In general, given an output tuple &#298; and a context &#255; &#166; &#261; , we first consider the sequence of columns (&#272; 1 .&#281; 1 , . . . &#272; &#289; .&#281; &#289; ) from where we get the constants in &#298;. These will correspond to the columns for the projection operator. For each tuple &#298; in &#255;, we consider the table &#272; . These will correspond to the tables to be joined. In order to construct the parameters for the join, for each &#298; &#8712; &#255;, let &#257; be the set of predicates of the form</p><p>Then, we can construct the queries of the form:</p><p>Where each &#258; is a conjunction of comparison predicates that label edges in &#257; . We consider all possible non-empty subsets of the labels in &#257; , and therefore, for each pair (&#298;, &#255;) of output tuple and context, there may be multiple candidate joins.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.2">Supervised Learning of Comparisons for Selection</head><p>We now turn to decision trees to add a selection operator to the query in Equation <ref type="formula">3</ref>. Our approach is motivated by the Iterative Dichotomiser 3 (ID3) algorithm for learning decision trees <ref type="bibr">[30]</ref>. We first need to convert the tables &#272; 1 , . . . ,&#272; in context &#255; into one single table &#272; . This is achieved by implementing the join in Equation <ref type="formula">3</ref>, that is we consider the output of the SQL query:</p><p>This join produces a single table. As before, each context corresponds to multiple joins and hence there are multiple candidates for &#272; . We consider all of them in our search.</p><p>We start by introducing some notation. Let &#256; be the schema of the output tuples, that is the types of the columns from which we draw output tuples. Let &#255; (&#272; ) represent the projection of &#272; to the columns in &#256;. Then, the entropy of a node &#266; is defined as:</p><p>Here, we restrict our analysis to output tuples that occur in &#267; + or &#267; -only. Consider the joined table in Figure <ref type="figure">2a</ref>. We can compute the entropy of the node with label (school = Engineering):</p><p>Here, we do not consider 'Erin. ' This is our first concrete modification to the decision tree learning algorithm.</p><p>A comparison predicate &#279; splits the table &#272; into two: &#258; (&#272; ) which comprises of rows that satisfy &#279; and &#258; &#172; (&#272; ) which comprises of rows that do not satisfy &#279;. Let &#258; (&#272; ) correspond to a node &#264; and &#258; &#172; (&#272; ) correspond to a node &#270;. Then we can compute their entropies &#271; (&#264;) and &#271; (&#270;) just as above. Consider the predicate (school = Engineering) which splits the joined table in Figure <ref type="figure">2a</ref> into two tables as shown in Figure <ref type="figure">6</ref>. Let &#258; (school=Engineering) (&#272; ) form node &#264; and &#258; &#172;(school=Engineering) (&#272; ) form node &#270;. The entropies &#271; (&#264;) and &#271; (&#270;) are 0.918 and 1 respectively.</p><p>We can now compute the information gain. Information gain is defined as the difference between the entropy of the node and the weighted sum of the entropy of its children. That is, the information gain at node &#266; is of the form:</p><p>where &#258; + &#255; = 1. In a classical setting, the coefficients &#258; and &#255; are the ratio of the number of rows corresponding to the child nodes &#264; and &#270;. In our study, we focus on projection, and only the tuples in &#267; + and &#267; -. For ease of notation, let |&#255; (&#258; (&#272; )) &#8745; &#267; + &#8746; &#267; -|, the number of rows in &#258; (&#272; ), projected to columns &#256;, that occur in either &#267; + or &#267; -be &#261; (and analogously for &#258; &#172; (&#272; ) be &#261; &#172; ). Then information gain at Node &#266; with comparison predicate &#279; is defined as:</p><p>In our running example, &#261; is 3 and &#261; &#172; is 2. This gives us an information gain of 0.0328. The change in the weighted sum is our second concrete modification to decision tree learning.</p><p>The decision tree learning algorithm as described in Algorithm 2 starts with the table &#272; and node &#266; as an input. We introduce node &#266; so we can call this procedure recursively. If &#267; + or &#267; -is empty, we return the trivial tree with &#266; as the only node. Otherwise, we construct a set of comparison predicates of the form (&#272; .&#281; &#8765; &#289;), where &#272; .&#281; is a column of the table &#272; , &#289; is a constant that occurs in the column &#272; .&#281;, and &#8765; is a comparison operator (in our case either =, &lt;, or f. Then, similar to the classical algorithm, we pick a comparison predicate &#279; that maximizes the information gain Algorithm 2 DTL(&#272; , &#266; , &#267; + , &#267; -), where &#272; is a table, &#266; is a node, and &#267; + and &#267; -are the sets of positively and negatively labeled tuples respectively.</p><p>(1) If &#267; + is empty, label &#266; with &#215;, return the leaf node &#266; , and terminate.</p><p>(2) If &#267; -is empty, label &#266; with &#10003;, return the leaf node &#266; , and terminate. (3) Otherwise, let &#253; = {}. (4) For each column &#281; in &#272; , (a) if &#281; is of the categorical type, then for each constant &#289; in column &#281;, update:</p><p>if &#281; is of the numerical type, then for each constant &#289; in column &#281;, update:</p><p>(5) For each &#279; &#8712; &#253;, compute &#261;&#259; (&#266; , &#279;) using the formula in Equation <ref type="formula">5</ref>. (6) Find a predicate &#279; for which &#261;&#259; (&#266; , &#279;) is maximum. If the maximum for &#261;&#259; (&#266; , &#279;) is 0, label &#266; as ?, return the leaf node &#266; , and terminate the process. ( <ref type="formula">7</ref>) Otherwise, label &#266; with predicate &#279; and create new nodes &#264; and &#270; as left child and right child of &#266; respectively. (8) Recursively compute:</p><p>where &#256; is the sequence of projected columns for the output. (9) Return the tree with root node &#266; , left sub-tree and right sub-tree .</p><p>&#261;&#259; (&#266; , &#279;). If no comparison predicate can maximize the information gain beyond 0, we return the trivial tree with &#266; as the only node, labeled with '?' and terminate the process. This is the case where there is no classifier for the given input data. Otherwise, we split the table &#272; on predicate &#279; as tables &#258; (&#272; ) and &#258; &#172; (&#272; ), introduce child nodes &#264; and &#270; corresponding to them, and call the DTL process recursively on the children of &#266; . When we call DTL on the &#264; and &#270; nodes, we ensure that the &#267; + and &#267; - are updated to the output tuples that occur in &#258; (&#272; ) and &#258; &#172; (&#272; ).</p><p>On executing the DTL procedure on our running algorithm, we get a tree as in Figure <ref type="figure">7</ref>. Observe that it has a redundant right subtree, and one of the leaves is labeled '?'. Instead, the desired tree is the one in Figure <ref type="figure">2b</ref>.</p><p>The problem of finding a minimal decision tree, or even approximating it, is NP-complete <ref type="bibr">[36]</ref>. Therefore we opt for a greedy search that is computationally efficient. Instead of considering all possible Boolean combinations of comparison predicates, Algorithm 2 makes locally optimal decisions, enabling it to handle large data-sets efficiently and produces satisfactory results in practice. While it is possible that locally optimal choices may not lead to the smallest decision tree, it most often leads to a good enough solution that is succinct and general, as observed in Section 4 The soundness check of Algorithm 1 also ensures that while DTL may generate a larger tree, the synthesized query will always be consistent with</p><p>&#272; with (school = Engineering) studentID deptCode courseID school Alice Comp. 201 Engineering Bob Mech. 320 Engineering Alice Mech. 550 Engineering Bob Mech. 550 Engineering David Comp. 500 Engineering David Mech. 502 Engineering (a) Table with rows of &#255; that satisfy the predicate (school = Engineering). &#272; with &#172;(school = Engineering) studentID deptCode courseID school Alice Chem. 310 Arts and Science Charlie Chem. 310 Arts and Science Erin Chem. 310 Arts and Science (b) Table with rows of &#255; that do not satisfy the predicate (school = Engineering).</p><p>Figure <ref type="figure">6</ref>: In order to compute the information gain of a comparison predicate at a given node, we split the rows at the node into two parts, those that satisfy the predicate and the others that don't. Here, we have split the joined table &#272; (from Figure <ref type="figure">2a</ref>) on the predicate (school = Engineering).</p><p>courseID &lt; 500? school = Engineering? courseID f 502?</p><p>The decision tree generated by the DTL on &#272; (from Figure <ref type="figure">2a</ref>) with &#267; + = {Alice, Bob} and &#267; -= {Charlie, David}.</p><p>the given input-output examples. Greedy heuristics based on information gain commonly used in decision tree learning and search algorithms for this reason <ref type="bibr">[30,</ref><ref type="bibr">37,</ref><ref type="bibr">38]</ref>. By using the greedy heuristic, DTL generates a perfect separator between &#267; + and &#267; -, however, we only need a partial separator. That is, we seek a relational query &#269; that captures some derivation for each tuple in &#267; + , and no derivation for any tuple in &#267; -. We do not have a stronger requirement that &#269; should capture all derivations for tuples in &#267; + . On the other hand, the decision tree attempts to branch till every node is at entropy 0, that is every node either leads to tuples in &#267; + or &#267; -exclusively, instead of stopping when there is at least one leaf node corresponding to every tuple in &#267; + . As our setting allows for a weaker notion of separation, we can further trim the decision trees.</p><p>More concretely, the right branch of the root node in the tree in Figure <ref type="figure">2b</ref> corresponds to rows with studentID values in {Alice, Bob David}, as all three of them are taking courses with courseID g 500. DTL naturally assumes that one needs to branch further to separate Alice and Bob from David. However, it is not necessary as the node labeled &#10003;can explain Alice and Bob. Similarly, at the leaf labeled '?, ' the projected column has values {Alice, Charlie}, and we do not have any comparison predicate that separates them.</p><p>We implement an lazy version of DTL to achieve the trimmed decision trees. This is our third modification to classical decision tree learning. In the DTL process, we introduce a set of unexplained output tuples &#267; ? , initialized to &#267; + and a first-in-first-out (FIFO) queue that maintains a list of nodes, initialized to {&#266; }. Throughout the algorithm, we update &#267; ? by removing the output tuples that are already explained by a particular leaf of the decision tree.</p><p>While there exist any unexplained tuples, we dequeue a node from the queue and branch it out as described in Algorithm 2. Instead of calling the process recursively, we enqueue the children and then eventually get to them only when there are unexplained tuples. This lazy evaluation allows us to generate smaller trees with fewer redundancies. With this modification, we get the desired tree depicted in Figure <ref type="figure">2b</ref>.</p><p>In summary, we make three modifications to adapt the classical decision tree learning algorithm to our setting: we first modify the entropy formula in order to support partial labeling, we then change the weights in the information gain formula to overcome the ambiguity that results from projections and partial labeling, and finally, we implement a lazy version of DTL to generate small decision trees that act as partial separators between &#267; + and &#267; -to avoid producing redundancies. Note that these modifications do not compromise any guarantees about termination of the procedure or size of the learned decision tree <ref type="bibr">[29]</ref>.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.3">Interleaving Decision Tree Learning with Example-Guided Search for Joins</head><p>A decision tree can then be converted to a boolean formula &#258; in disjunctive normal form. For each leaf of the tree that is marked &#10003;, we consider a clause that is composed of the conjunction of the predicate at its parent node (if the node is a left child, and the negation of the predicate otherwise). And then, we construct the disjunction of each of these clauses. For example, we can translate the tree in Figure <ref type="figure">2b</ref> to the formula (courseID &lt; 500) ' (school = Engineering). The negations, if any, can be removed by considering the negated comparison operators (&#8800;, &gt;, and g).</p><p>Therefore we can convert a joined table &#272; and decision tree into a query &#269; (&#272; , ) by using the boolean formula &#258; to complete the query in Equation <ref type="formula">3</ref>. This gives us the query:</p><p>Figure <ref type="figure">4</ref> summarizes Libra. The end-to-end algorithm guarantees completeness: Theorem 3.1 (Completeness). If there exists a relational query consistent with the input-output example &#257; = (&#261;, &#267; + , &#267; -), then Libra produces a query &#269; consistent with &#257;.</p><p>The proof of this theorem relies on the completeness of the example-guided enumeration and the completeness of decision tree learning. We assume the reader is familiar with the analogous guarantees for example-guided synthesis of conjunctive queries <ref type="bibr">[40]</ref>, and those for classical decision trees. Observe that if a context &#255; explains a tuple &#298;, then all contexts &#255; &#8242; &#167; &#255;, also explain &#298;. We can consider the largest context &#255; = &#261; , that is, the set of all input tuples, to prove the following lemma: Lemma 3.2. If there exists a relational query consistent with the input-output example &#257; = (&#261;, &#267; + , &#267; -), then there exist a decision tree with predicates of the form (&#272; .&#281; &#8765; &#289;) where &#272; is an input table, &#281; is a column of &#272; , and &#289; is a constant in the column &#281;, such that the query &#269; (&#272; , ) is consistent with &#257;.</p><p>It follows from the completeness of example-guided enumeration that a decision tree must exist, however, it remains to show that the predicates for the decision tree must be of the said form. Without loss of generality, suppose the comparison predicate is of the form (&#272; .&#281; &gt; &#289; 1 ), where &#289; 1 does not occur in &#281;. The arguments for other comparison operators is analogous. Observe that must exist the greatest lower bound &#289; 2 of &#289; 1 in &#281; (that is, &#289; 2 = max{&#289; &#8712; &#281; : &#289; &lt; &#289; 1 }). Replacing the predicate by (&#272; .&#281; &gt; &#289; 2 ) does not change the semantics of the query with respect to input &#261; , as there are no constants in between &#289; 1 and &#289; 2 . By systematically replacing the predicates in a query consistent with &#257;, we can prove that there must exist a query where the selection operator corresponds to a decision tree of the said form. As we exhaustively enumerate all possible predicates, we can guarantee: Lemma 3.3. Given a table&#272; , a node &#266; and output tuples partitioned as &#267; + and &#267; -, if there exists a decision tree that separates &#267; + from &#267; -, then DTL(&#272; , &#266; , &#267; + , &#267; -) will return such a tree.</p><p>Together, Lemma 3.2 and Lemma 3.3 can prove Theorem 3.1. Additionally, observe that at each step of the algorithm, we maintain the constant &#266; that tracks the size of the query. As the contexts are maintained in increasing order of size, the number of joins in the enumerated queries is always increasing.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4">EVALUATION</head><p>We have implemented the Libra algorithm in Scala. In this section, we evaluate it on a large-scale benchmark suite. First, we measure the performance of our algorithm compared to state-of-the-art synthesis tools. We do so by comparing the number of instances solved by each tool and the time taken by each tool to do so. Next, we evaluate the generality of the solutions generated by each tool.</p><p>To do so at scale, we leverage Occam's razor to use the succinctness of a query as a proxy of how specific a query is to the training data. We then test the sensitivity of Libra to partial labels. We do so by dropping a fraction of labels and evaluating the number of instances solved by Libra. As such, we propose to answer three main research questions: Q1. Performance: How effective is Libra on synthesis tasks from different domains in terms of synthesis time? Q2. Succinctness: How large are the programs synthesized by Libra compared to the reference solution? Q3. Sensitivity to Partial Labels: How is the performance of Libra affected by partial labels? We discuss our benchmark suite in Section 4.1 and the baselines against which we compare Libra in Section 4.2 along with the setup for each. We present our findings in Sections 4.3, 4.4, and 4.5. We performed all experiments on a Linux server with an 18-core, 36-thread, 3 GHz Xeon Gold 6154 CPU and 394 GB of RAM.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.1">Benchmarks</head><p>In order to effectively evaluate Libra, we put together a benchmark suite of SPJ instances with the following requirements based on our problem statement: first, the queries must be over a variety of different databases; second, some of them must query more than one table; and last, some of them must contain at least a comparison with a constant. Upon exploring various query datasets, we find the Spider <ref type="bibr">[46]</ref> and Geography <ref type="bibr">[12,</ref><ref type="bibr">21,</ref><ref type="bibr">47]</ref> datasets to contain queries that satisfy our requirements. We, therefore, evaluate Libra on the set of all SPJ instances from the Spider <ref type="bibr">[46]</ref> and Geography <ref type="bibr">[12,</ref><ref type="bibr">21,</ref><ref type="bibr">47]</ref> datasets. Spider is an open-access large-scale manually annotated dataset. There are 1,203 SPJ instances in the Spider dataset over 159 databases. On the other hand, Geography is a dataset of SQL queries about US geography. We use version 4 of the modified SQL dataset for Geography from <ref type="bibr">[12,</ref><ref type="bibr">21,</ref><ref type="bibr">47]</ref>. Additional statistics for each benchmark are provided in Table <ref type="table">1</ref>. Upon deduplication of the queries, we extract 272 SPJ instances, all over the same database, giving us a total of 1,475 instances over both datasets. For each benchmark, we consider the tables from its corresponding database as the input tables and the result of running the ground truth query over that database as the output table.</p><p>Each benchmark has 2 to 26 input tables (with a median of 8), each with 1 to 352 columns (with a median of 30), containing 8 to around 553k tuples in the input tables (with a median of 937). Additionally, each benchmark is labeled with a ground truth query that serves as a reference solution. This reference solution is used to obtain the output examples for the corresponding benchmark. Overall, the reference solutions feature a join of at most 6 tables and the use of at most 3 predicates.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.2">Baselines and Setup</head><p>We compare Libra against baselines that are at least as expressive as Libra itself. We therefore compare Libra against the following baselines in Sections 4.3 and 4.4: Scythe <ref type="bibr">[43]</ref>, which synthesizes SQL queries using enumerative search, and PatSQL <ref type="bibr">[39]</ref>, which uses relational algebra properties to perform a more scalable enumerative search. Both these baselines are more expressive than Libra, supporting aggregations, group-by operators, nested queries, etc. However, in order to support these operators, they also require more human supervision. On the other hand, while Libra uses insights from EGS such as the example-guided enumeration technique, a large majority of the benchmarks require the generation of queries that include comparisons, which EGS does not support. We therefore do not compare with EGS in our evaluations.</p><p>For each benchmark, we provide each tool with the corresponding input and output tables as described in Section 4.1. We initialize &#267; + as the set of all expected output tuples. Scythe and PatSQL require exhaustive labeling, i.e. any tuple not labeled as &#267; + is considered to be &#267; -, so we initialize &#267; -to be all tuples of appropriate arity that do not occur in &#267; + for each tool. The benchmarks are labeled with a reference solution which identifies each column of the input tables as either categorical, numerical, or uncomparable.</p><p>For the baselines Scythe and PatSQL, the user is required to specify constants that may occur in the comparison predicates. We recover the list of constants that occur in the reference solution and provide it to the two baselines as additional supervision which is not provided to Libra.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.3">Q1: Performance</head><p>We run Libra, Scythe, and PatSQL on all 1,475 benchmarks with a timeout of 10 minutes and summarize the performance of each tool in a cactus plot in Figure <ref type="figure">8</ref>. From this figure, we see that Libra solves most number of benchmarks, solving 1,361 out of 1,475 in an average of 58.9 seconds, and solves 1,097 of those within 10 seconds. Of the 1,361 solved benchmarks, 1,090 are SPJ instances from the Spider dataset, while 271 are from the Geography dataset.</p><p>The plot for Libra plateaus at 600 seconds since it searches for a minimal solution to a benchmark, but returns the best solution found so far when it times out. PatSQL is outperformed by Libra, solving 673 benchmarks in an average of 23.13 seconds, and 548 in 10 seconds. Scythe solves only 195 benchmarks, in an average of 139.50 seconds, and only 15 in 10 seconds. All of the benchmarks solved by PatSQL and Scythe are instances from the Spider dataset; neither tool solves a single instance from the Geography dataset. Also, PatSQL solves 2 benchmarks unsolved by Libra, while all benchmarks solved by Scythe are solved by Libra and PatSQL.</p><p>Among the benchmarks that Libra uniquely solves, a significant portion of the benchmarks have ground truths involving many joins, but with a few shared constants between tables, leading to a sparse tuple co-occurrence graph while there are syntactically many possible joins. The following generated query which Libra is the only one to produce (and which happens to match the reference solution) shows how the example-guided technique allows for learning very large queries and combined with decision tree learning allows for learning complex SPJ queries: The example-guided strategy used by Libra allows it to explore solutions of a larger size more quickly than syntax-guided strategies since the smaller joins that are syntactically valid but don't explain any output tuple are skipped. This results in Libra solving benchmarks with reference solutions of a larger size where other baselines would require a longer time to search through the hypothesis space despite the additional supervision provided. However, it is difficult to scale Libra over larger input databases. The largest benchmark solved by Libra consists of 5303 tuples in its input, in 4 tables and 26 columns, and 20 tuples in its output. The size of its target query is 5. On the other hand, for the 114 benchmarks unsolved by Libra, over 70% have more than 5,000 tuples, and all have tables with over 20 columns, with a median of 64 columns. Libra faces two main issues when solving these benchmarks. First, it may struggle to build the tuple co-occurrence graph that it uses to enumerate contexts, and second, frequently occurring constants can result in a large number of contexts being enumerated. The second case is true for the 2 benchmarks that PatSQL solved which were unsolved by Libra, since they contained 43 and 20 columns, with 103 and 577 rows respectively. However, the ground truth solutions for those benchmarks could be easily explored by syntaxguided processes, with one of the benchmarks consisting only of joins, and so PatSQL was able to synthesize them.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.4">Q2: Succinctness</head><p>We now turn to evaluating the quality of the programs in terms of succinctness. Algorithm 1 is sound by construction, that is the synthesized query is always consistent with the training data. In order to inspect for generalizability, we use the size of the query as a measure of its specificity with respect to the training data, where a more succinct query is assumed to be less specific to the particular data, and we rely on Occam's razor to assess over-fitting.</p><p>As discussed in Section 2.1, the size of the query is defined as the sum of the number of tables joined and the number of comparison predicates in the selection operator in the disjunctive normal form (DNF). We summarize the size of the programs synthesized by both instances of Libra and the baselines in Figure <ref type="figure">9</ref>.</p><p>We observe that 1,339 of the 1,361 programs (around 99%) synthesized by Libra are minimal, that is, the size of the query is equal to or smaller than that of the reference solution. In 271 of the 1,361 programs, Libra generates a smaller query than the reference solution. This is a peculiar case common to programming-by-examples where the input-output examples under-specify the task. That is, the input-output examples do not feature all the cases that the synthesis tool should consider. For example, consider the benchmark where the input table campuses consists of columns for the id, campus, location, county, and year for a set of college campuses, and the input table csu_fees consists of columns for campus, year, and campus fee for a set of campuses. The reference solution is: 1 2 3 4 5 6 7 Size of t he t arget query 0 100 200 300 400 500 600 Num ber of benchm arks Scyt he Pat SQL Libra Reference This is because the campus name "San Francisco State University" occurs only once in campuses with id "18", and the only row with campus "18" in csu_fees has year of 1996. Therefore, the conjunction on both the campus name and year is unnecessary and there is also no longer a need for the join of campuses with csu_fees since selecting campus "18" directly from csu_fees is sufficient.</p><p>There are 22 benchmarks where the size of the query generated by Libra is larger than the reference solution. On manual inspection of these benchmarks, we observe that the larger size is due to the sub-optimal size of the decision tree generated by DTL. As discussed before, the problem of finding a minimal decision tree is intractable and hence we adopt a greedy heuristic-based search. Therefore, any minimality guarantee will be subject to the performance of the decision tree, but we quantitatively observe that 99% of the synthesized programs are minimal.</p><p>For the baselines, we observe that the size of the synthesized programs is usually large. In contrast to Libra, only 115 of the 673 (17%) programs synthesized by PatSQL are minimal, and only 99 of the 195 (51%) programs synthesized by Scythe are minimal. Figure <ref type="figure">9</ref> shows the number of benchmarks each tool finds a solution for at each reference benchmark size shown on the x-axis, and the subset of these solutions which are minimal is shown in a bright color. We see Libra consistently outputs minimal solutions across program sizes while PatSQL and Scythe do not output minimal programs when the reference solution has size 2-4.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.5">Sensitivity to Partial Labels</head><p>We conduct experiments in order to evaluate the ability of Libra to solve problems with partial labels. Since neither PatSQL nor Scythe support partial labels, we do not compare Libra with them.</p><p>We run sensitivity experiments by dropping a fraction of both positive and negative labels. To do this, we choose the desired fraction X% of labels to be dropped. We then choose with uniform randomness X% of the positive and X% of the negative tuples, and drop them from the instance. Dropping these tuples effectively simulates a partially labeled instance, since these tuples are now labeled as unknown. We then ask Libra to solve these instances. This process is repeated for each benchmark with increasingly  larger fractions of dropped tuples, from 10% to 70%. We conduct this experiment three times for each fraction to account for randomness.</p><p>We measure both the average F1 score of the solved benchmarks (shown in blue in Figure <ref type="figure">10</ref>) and the number of perfectly solved benchmarks, i.e. solved with an F1 score of 1.0 (shown in red in Figure <ref type="figure">10</ref>). We see from Figure <ref type="figure">10</ref> that the number of perfectly solved examples drops from 1090 by around 7.8% when 10% of the tuples are removed, and drops by around 46.8% when 70% of those tuples are removed. The average F1 score remains relatively high, dropping by only 0.12 points when 70% of the labels are removed.</p><p>This shows that even after removing a significant proportion of labels, positive or negative, Libra can synthesize queries that come close to representing user intent, even if the synthesized query is not the target solution itself.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5">RELATED WORK</head><p>We discuss related work on the synthesis of relational queries, inductive logic programming (ILP), decision tree learning, and exampleguided search.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.1">Synthesis of Relational Queries</head><p>Program synthesis and Inductive Logic Programming have made significant progress in the synthesis of rules from input-output examples. Each of these techniques specializes to support specific features (such as aggregation, invented predicates, recursive predicates, etc.) and require additional instance-specific supervision in the form of templates such as predicate signatures, mode declarations, or candidate rules.</p><p>GenSynth <ref type="bibr">[28]</ref> is an evolutionary search-based approach for synthesizing Datalog programs. The evolutionary strategy maintains a population of candidate programs that are incrementally mutated to optimize the fitness score for those programs. Gen-Synth can synthesize recursive predicates when the signatures of invented predicates are specified (unless they coincide with that of an input or output relation). Scythe <ref type="bibr">[43]</ref> and PatSQL <ref type="bibr">[39]</ref> are enumerative techniques that require the exhaustive list of constants that may occur in the selection operator and the list of aggregation operators that may be used by the query. Scythe uses a two-phase approach where it first searches for partial queries that can potentially explain the training data, and then instantiates them and ranks the results. PatSQL also adopts a two-phase approach, but it additionally uses properties of relational algebra to rewrite the partial queries so that a combinatorial blow-up (due to the projection operator) can be avoided.</p><p>While Scythe and PatSQL are both two-phase approaches, they differ from Libra in two concrete ways. Both the phases for Libra are data-driven (the first phase is built on EGS while the second is a modified decision tree learning algorithm) while Scythe and Pat-SQL use enumerative techniques that do not take the input-output data into consideration. And secondly, the interaction between the two phases in Libra are interleaved so as to minimize the number of joins and the number of comparison predicates, while PatSQL and Scythe run sequentially.</p><p>Additionally, the problem of synthesis of relational queries has been studied in an interactive setting <ref type="bibr">[2,</ref><ref type="bibr">42]</ref>, and from natural language <ref type="bibr">[11,</ref><ref type="bibr">23,</ref><ref type="bibr">45]</ref> and other specifications <ref type="bibr">[5,</ref><ref type="bibr">49]</ref>.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.2">Inductive Logic Programming</head><p>ILASP <ref type="bibr">[27]</ref>, a constraint solving-based approach, can synthesize recursive Answer Set Programs producing constraints over the hypothesis space. The hypothesis space for ILASP is defined using mode declarations that bound the number of joins and variables in the synthesized rules. Extensions of ILASP can support noisy data.</p><p>Popper <ref type="bibr">[9]</ref> is a constraint solving ILP technique that implements the 'learning from failures' strategy. It supports Answer Set Programs and Prolog syntax and can reason about lists, numbers, and textual data. Similar to ILASP, Popper uses mode declarations to restrict the expressiveness of the queries, and requires instancespecific supervision from the user in form of these modes.</p><p>First-Order Inductive Learner (FOIL) <ref type="bibr">[32]</ref> is an iterative algorithm that searches for a first-order clause that maximally covers a set of positive examples while minimizing the number of negative examples covered. QuickFOIL <ref type="bibr">[48]</ref> is a parallel and scalable implementation of the FOIL algorithm and supports scalable and robust learning using parallelization. While FOIL and QuickFOIL do not restrict the hypothesis space using mode declarations, they employ greedy heuristics that do not explore the space of all possible rules and hence cannot guarantee the completeness of the search.</p><p>These techniques also do not support numerical reasoning as required for the synthesis of comparison predicates. In order to support such predicates, the user must augment the input database with additional tables corresponding to each comparison constant, causing a blow-up in space and significant increases in run-time.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.3">Decision Tree Learning</head><p>In this paper, we implement a straightforward decision tree learning algorithm based on the Iterative Dichotomiser 3 (ID3) algorithm <ref type="bibr">[30]</ref>. Several modifications and extensions of this algorithm have been studied <ref type="bibr">[34,</ref><ref type="bibr">35,</ref><ref type="bibr">38]</ref>. The applications of decision trees for invariant synthesis <ref type="bibr">[14,</ref><ref type="bibr">24]</ref> as well as to support noisy and uncertain data <ref type="bibr">[15,</ref><ref type="bibr">41]</ref> have been studied. Ideas and algorithms from these works can be integrated into query synthesis.</p><p>MRDTL is a decision tree learning algorithm that supports the multi-table setting <ref type="bibr">[18]</ref>. However, it assumes a primary table whose rows are labeled as positive and negative examples. In that respect, it supports joins (by drawing information from other tables in the database) and comparison predicates (through the decision tree), but not projection. It differs from our setting, especially in the case where projection may draw columns from different tables.</p><p>The problem of summarising a multi-table input database in a single table is studied in the context of supervised learning. Hamlet <ref type="bibr">[25]</ref> is a system of handcrafted decision rules to predict joins across the input database so analysts balance between performance and accuracy. ARDA <ref type="bibr">[7]</ref> proposes a framework for automated relational data augmentation which can discover joins of input tables efficiently and improve the performance of predictive models in a multi-table setting.</p><p>Applications of decision tree learning in program synthesis have been studied in the context of syntax-guided search for programs with conditional operators. EUSolver <ref type="bibr">[3]</ref>uses a divide-and-conquer technique that first enumerates expressions that are consistent with a subset of input-output examples and then constructs a decision tree to combine these expressions using conditional predicates in order to scalably synthesize complex programs. DryadSynth <ref type="bibr">[19]</ref> is a synthesis tool for conditional linear integer arithmetic (CLIA) programs that uses decision trees to represent conditional programs and uses a combination of enumerative and symbolic reasoning techniques to synthesize them. E3Solver <ref type="bibr">[22]</ref>, a unification-based solver for programming-by-example enumerates an expression for each example and then incrementally identifies unification strategies for them using decision trees. While these tools combine searchbased synthesis and decision trees, they do not tackle the challenge of learning relational queries over multiple tables.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.4">Example-Guided Search</head><p>Example-guided and data-driven search techniques have previously been used for synthesizing relational queries, regular expressions, string transformations, and spreadsheet operators.</p><p>EGS <ref type="bibr">[40]</ref> is an end-to-end synthesis engine for conjunctive queries that feature only projection and equi-joins. As discussed in Section 3.1, the search technique for joins in Libra is motivated by this work. However, we differ from it primarily in the way in which we summarize the data and explore the input tables. In particular, EGS constructs a constant co-occurrence graph and then uses the ExplainCell procedure that explains an output tuple in a columnby-column fashion. Instead, we do not need any such construction and explain all columns of an output tuple at once based on our construction of the initial context.</p><p>FlashFill <ref type="bibr">[16]</ref>, a tool available in Microsoft Excel which synthesizes string transformations using input-output pairs to generate trace expressions and then uses these expressions to construct a program that is consistent with the training data. This is analogous to our construction of partial queries (with only join and projection) from input-output examples, and then using a modified decision tree to add a selection operator. Beyond program synthesis, example-guided search techniques have also been used for domains such as graph search and grammatical inference <ref type="bibr">[4,</ref><ref type="bibr">6]</ref>.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="6">LIMITATIONS AND FUTURE WORK</head><p>We discuss some limitations of Libra in this section. First, Libra does not support aggregation operators and nested queries. While it is certainly a desirable feature, including support for such operators can be extremely computationally expensive, and may require sacrificing other features to be supported. For instance, while Scythe and PatSQL do support aggregation, they do so at the cost of additional supervision. Second, the underlying algorithm of Libra is not incremental, and as such does not support incremental updates to the input database. However, since for most cases, the turnaround time of Libra is relatively low, Libra can be rerun upon every update to the database. Third, as discussed in Section 4.3, Libra struggles to scale up as the sizes of the input database and the number of constants increase. Syntax-guided approaches face similar difficulties as highlighted by the performance of PatSQL and Scythe, especially when synthesizing target queries that involve large numbers of joins. Works such as <ref type="bibr">[26]</ref> explore joinable tables in a database, but require additional heuristics. In the future, we intend to further explore the issue of finding optimal joins to address problems with scalability.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="7">CONCLUSION</head><p>We have presented a novel approach to the problem of synthesizing select-project-join queries from input-output examples. Our insight is to view this problem as a two-dimensional search for synthesizing joins and learning comparison predicates. We designed an example-guided enumerator to synthesize joins and modify the classical decision tree learning technique to learn predicates (while maintaining the guarantees about the termination of the procedure and size of the learned tree). We then propose a way to interleave the two to synthesize relational queries with categorical and numerical comparison predicates. We show that our algorithm strongly encourages minimality of the synthesized program and we prove the completeness of its search. We implement the algorithm in a tool named Libra and evaluate it to show that it outperforms stateof-the-art approaches on a variety of tasks in terms of synthesis time as well as the quality of the programs.</p><p>We outline three lines of future research for this work. Firstly, we would like to extend Libra to support the full SQL syntax including disjunction (union), aggregation operators, and nested queries. Secondly, the short synthesis time of Libra creates an opportunity to develop an interactive interface that allows the user to provide real-time feedback on the synthesized query. This allows the user to start with a small input-output example and progressively add more complexity to cover all features of the desired query. And finally, the insight of example-guided search for candidate joins can be developed agnostic to the downstream supervised learning task (as done for Hamlet and ARDA <ref type="bibr">[7,</ref><ref type="bibr">25]</ref>). This can allow us to develop an end-to-end system that can translate a multi-table database to a single augmented table that can balance performance with generalizability.</p></div></body>
		</text>
</TEI>
