Inferring a Hierarchical Input Type for an SQL Query