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

Function roundtrip_expr

datafusion/sql/tests/cases/plan_to_sql.rs:98–112  ·  view source on GitHub ↗
(table: TableReference, sql: &str)

Source from the content-addressed store, hash-verified

96}
97
98fn roundtrip_expr(table: TableReference, sql: &str) -> Result<String> {
99 let dialect = GenericDialect {};
100 let sql_expr = Parser::new(&dialect).try_with_sql(sql)?.parse_expr()?;
101 let state = MockSessionState::default().with_aggregate_function(sum_udaf());
102 let context = MockContextProvider { state };
103 let schema = context.get_table_source(table)?.schema();
104 let df_schema = DFSchema::try_from(schema)?;
105 let sql_to_rel = SqlToRel::new(&context);
106 let expr =
107 sql_to_rel.sql_to_expr(sql_expr, &df_schema, &mut PlannerContext::new())?;
108
109 let ast = expr_to_sql(&expr)?;
110
111 Ok(ast.to_string())
112}
113
114#[test]
115fn roundtrip_statement() -> Result<()> {

Callers 4

test_roundtrip_expr_1Function · 0.70
test_roundtrip_expr_2Function · 0.70
test_roundtrip_expr_3Function · 0.70
test_roundtrip_expr_4Function · 0.70

Calls 8

newFunction · 0.85
expr_to_sqlFunction · 0.85
parse_exprMethod · 0.80
schemaMethod · 0.45
get_table_sourceMethod · 0.45
sql_to_exprMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…