MCPcopy Create free account
hub / github.com/apache/datafusion / roundtrip_statement

Function roundtrip_statement

datafusion/sql/tests/cases/plan_to_sql.rs:115–261  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

113
114#[test]
115fn roundtrip_statement() -> Result<()> {
116 let tests: Vec<&str> = vec![
117 "select 1;",
118 "select 1 limit 0;",
119 "select ta.j1_id from j1 ta join (select 1 as j1_id) tb on ta.j1_id = tb.j1_id;",
120 "select ta.j1_id from j1 ta join (select 1 as j1_id) tb using (j1_id);",
121 "select ta.j1_id from j1 ta join (select 1 as j1_id) tb on ta.j1_id = tb.j1_id where ta.j1_id > 1;",
122 "select ta.j1_id from (select 1 as j1_id) ta;",
123 "select ta.j1_id from j1 ta;",
124 "select ta.j1_id from j1 ta order by ta.j1_id;",
125 "select * from j1 ta order by ta.j1_id, ta.j1_string desc;",
126 "select * from j1 limit 10;",
127 "select ta.j1_id from j1 ta where ta.j1_id > 1;",
128 "select ta.j1_id, tb.j2_string from j1 ta join j2 tb on (ta.j1_id = tb.j2_id);",
129 "select ta.j1_id, tb.j2_string, tc.j3_string from j1 ta join j2 tb on (ta.j1_id = tb.j2_id) join j3 tc on (ta.j1_id = tc.j3_id);",
130 "select * from (select id, first_name from person)",
131 "select * from (select id, first_name from (select * from person))",
132 "select id, count(*) as cnt from (select id from person) group by id",
133 "select (id-1)/2, count(*) / (sum(id/10)-1) as agg_expr from (select (id-1) as id from person) group by id",
134 "select CAST(id/2 as VARCHAR) NOT LIKE 'foo*' from person where NOT EXISTS (select ta.j1_id, tb.j2_string from j1 ta join j2 tb on (ta.j1_id = tb.j2_id))",
135 r#"select "First Name" from person_quoted_cols"#,
136 "select DISTINCT id FROM person",
137 "select DISTINCT on (id) id, first_name from person",
138 "select DISTINCT on (id) id, first_name from person order by id",
139 r#"select id, count("First Name") as cnt from (select id, "First Name" from person_quoted_cols) group by id"#,
140 "select id, count(*) as cnt from (select p1.id as id from person p1 inner join person p2 on p1.id=p2.id) group by id",
141 "select id, count(*), first_name from person group by first_name, id",
142 "select id, sum(age), first_name from person group by first_name, id",
143 "select id, count(*), first_name
144 from person
145 where id!=3 and first_name=='test'
146 group by first_name, id
147 having count(*)>5 and count(*)<10
148 order by count(*)",
149 r#"select id, count("First Name") as count_first_name, "Last Name"
150 from person_quoted_cols
151 where id!=3 and "First Name"=='test'
152 group by "Last Name", id
153 having count_first_name>5 and count_first_name<10
154 order by count_first_name, "Last Name""#,
155 r#"select p.id, count("First Name") as count_first_name,
156 "Last Name", sum(qp.id/p.id - (select sum(id) from person_quoted_cols) ) / (select count(*) from person)
157 from (select id, "First Name", "Last Name" from person_quoted_cols) qp
158 inner join (select * from person) p
159 on p.id = qp.id
160 where p.id!=3 and "First Name"=='test' and qp.id in
161 (select id from (select id, count(*) from person group by id having count(*) > 0))
162 group by "Last Name", p.id
163 having count_first_name>5 and count_first_name<10
164 order by count_first_name, "Last Name""#,
165 r#"SELECT j1_string as string FROM j1
166 UNION ALL
167 SELECT j2_string as string FROM j2"#,
168 r#"SELECT j1_string as string FROM j1
169 UNION ALL
170 SELECT j2_string as string FROM j2
171 ORDER BY string DESC
172 LIMIT 10"#,

Callers

nothing calls this directly

Calls 8

newFunction · 0.85
plan_to_sqlFunction · 0.85
with_scalar_functionMethod · 0.80
sql_statement_to_planMethod · 0.80
parse_statementMethod · 0.45
with_expr_plannerMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…