A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.rs/datafusion/latest/datafusion/sql/unparser/fn.plan_to_sql.html below:

plan_to_sql in datafusion::sql::unparser - Rust

Function plan_to_sqlSource
pub fn plan_to_sql(plan: &LogicalPlan) -> Result<Statement, DataFusionError>
Expand description

Convert a DataFusion LogicalPlan to ast::Statement

This function is the opposite of SqlToRel::sql_statement_to_plan and can be used to, among other things, to convert LogicalPlans to SQL strings.

§Errors

This function returns an error if the plan cannot be converted to SQL.

§See Also §Example
use arrow::datatypes::{DataType, Field, Schema};
use datafusion_expr::{col, logical_plan::table_scan};
use datafusion_sql::unparser::plan_to_sql;
let schema = Schema::new(vec![
    Field::new("id", DataType::Utf8, false),
    Field::new("value", DataType::Utf8, false),
]);
let plan = table_scan(Some("table"), &schema, None)
    .unwrap()
    .project(vec![col("id"), col("value")])
    .unwrap()
    .build()
    .unwrap();
let sql = plan_to_sql(&plan).unwrap(); assert_eq!(sql.to_string(), "SELECT \"table\".id, \"table\".\"value\" FROM \"table\"")

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4