Skip to content

Commit

Permalink
Rename types to reflect proposal
Browse files Browse the repository at this point in the history
  • Loading branch information
notfilippo committed Jul 17, 2024
1 parent e1eca31 commit 5be9029
Show file tree
Hide file tree
Showing 96 changed files with 634 additions and 634 deletions.
6 changes: 3 additions & 3 deletions datafusion-examples/examples/advanced_parquet_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use datafusion::physical_optimizer::pruning::PruningPredicate;
use datafusion::physical_plan::metrics::ExecutionPlanMetricsSet;
use datafusion::physical_plan::ExecutionPlan;
use datafusion::prelude::*;
use datafusion_common::logical_type::schema::LogicalSchemaRef;
use datafusion_common::logical_type::schema::LogicalPhysicalSchemaRef;
use datafusion_common::{
internal_datafusion_err, DFSchema, DataFusionError, Result, ScalarValue,
};
Expand Down Expand Up @@ -454,8 +454,8 @@ impl TableProvider for IndexTableProvider {
self
}

fn schema(&self) -> LogicalSchemaRef {
LogicalSchemaRef::new(self.indexed_file.schema.as_ref().clone().into())
fn schema(&self) -> LogicalPhysicalSchemaRef {
LogicalPhysicalSchemaRef::new(self.indexed_file.schema.as_ref().clone().into())
}

fn table_type(&self) -> TableType {
Expand Down
12 changes: 6 additions & 6 deletions datafusion-examples/examples/custom_datasource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ use datafusion_expr::LogicalPlanBuilder;
use datafusion_physical_expr::EquivalenceProperties;

use async_trait::async_trait;
use datafusion_common::logical_type::field::LogicalField;
use datafusion_common::logical_type::schema::{LogicalSchema, LogicalSchemaRef};
use datafusion_common::logical_type::field::LogicalPhysicalField;
use datafusion_common::logical_type::schema::{LogicalPhysicalSchema, LogicalPhysicalSchemaRef};
use tokio::time::timeout;

/// This example demonstrates executing a simple query against a custom datasource
Expand Down Expand Up @@ -164,10 +164,10 @@ impl TableProvider for CustomDataSource {
self
}

fn schema(&self) -> LogicalSchemaRef {
LogicalSchemaRef::new(LogicalSchema::new(vec![
LogicalField::new("id", DataType::UInt8, false),
LogicalField::new("bank_account", DataType::UInt64, true),
fn schema(&self) -> LogicalPhysicalSchemaRef {
LogicalPhysicalSchemaRef::new(LogicalPhysicalSchema::new(vec![
LogicalPhysicalField::new("id", DataType::UInt8, false),
LogicalPhysicalField::new("bank_account", DataType::UInt64, true),
]))
}

Expand Down
16 changes: 8 additions & 8 deletions datafusion-examples/examples/expr_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ use datafusion::functions_aggregate::first_last::first_value_udaf;
use datafusion::optimizer::simplify_expressions::ExprSimplifier;
use datafusion::physical_expr::{analyze, AnalysisContext, ExprBoundaries};
use datafusion::prelude::*;
use datafusion_common::logical_type::field::LogicalField;
use datafusion_common::logical_type::schema::LogicalSchema;
use datafusion_common::logical_type::field::LogicalPhysicalField;
use datafusion_common::logical_type::schema::LogicalPhysicalSchema;
use datafusion_common::{ScalarValue, ToDFSchema};
use datafusion_expr::execution_props::ExecutionProps;
use datafusion_expr::expr::BinaryExpr;
Expand Down Expand Up @@ -159,7 +159,7 @@ fn simplify_demo() -> Result<()> {

// you need to tell DataFusion the type of column "ts":
let schema =
LogicalSchema::from(Schema::new(vec![make_ts_field("ts")])).to_dfschema_ref()?;
LogicalPhysicalSchema::from(Schema::new(vec![make_ts_field("ts")])).to_dfschema_ref()?;

// And then build a simplifier
// the ExecutionProps carries information needed to simplify
Expand All @@ -180,7 +180,7 @@ fn simplify_demo() -> Result<()> {
);

// here are some other examples of what DataFusion is capable of
let schema = LogicalSchema::from(Schema::new(vec![
let schema = LogicalPhysicalSchema::from(Schema::new(vec![
make_field("i", DataType::Int64),
make_field("b", DataType::Boolean),
]))
Expand Down Expand Up @@ -297,14 +297,14 @@ fn expression_type_demo() -> Result<()> {
// a schema. In this case we create a schema where the column `c` is of
// type Utf8 (a String / VARCHAR)
let schema = DFSchema::from_unqualified_fields(
vec![LogicalField::new("c", DataType::Utf8, true)].into(),
vec![LogicalPhysicalField::new("c", DataType::Utf8, true)].into(),
HashMap::new(),
)?;
assert_eq!("Utf8", format!("{}", expr.get_type(&schema).unwrap()));

// Using a schema where the column `foo` is of type Int32
let schema = DFSchema::from_unqualified_fields(
vec![LogicalField::new("c", DataType::Int32, true)].into(),
vec![LogicalPhysicalField::new("c", DataType::Int32, true)].into(),
HashMap::new(),
)?;
assert_eq!("Int32", format!("{}", expr.get_type(&schema).unwrap()));
Expand All @@ -314,8 +314,8 @@ fn expression_type_demo() -> Result<()> {
let expr = col("c1") + col("c2");
let schema = DFSchema::from_unqualified_fields(
vec![
LogicalField::new("c1", DataType::Int32, true),
LogicalField::new("c2", DataType::Float32, true),
LogicalPhysicalField::new("c1", DataType::Int32, true),
LogicalPhysicalField::new("c2", DataType::Float32, true),
]
.into(),
HashMap::new(),
Expand Down
2 changes: 1 addition & 1 deletion datafusion-examples/examples/function_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use datafusion::error::Result;
use datafusion::execution::context::{
FunctionFactory, RegisterFunction, SessionContext, SessionState,
};
use datafusion_common::logical_type::ExtensionType;
use datafusion_common::logical_type::TypeRelation;
use datafusion_common::tree_node::{Transformed, TreeNode};
use datafusion_common::{exec_err, internal_err, DataFusionError};
use datafusion_expr::simplify::{ExprSimplifyResult, SimplifyInfo};
Expand Down
20 changes: 10 additions & 10 deletions datafusion-examples/examples/logical_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ use datafusion::error::Result;
use datafusion::execution::context::SessionState;
use datafusion::physical_plan::ExecutionPlan;
use datafusion::prelude::SessionContext;
use datafusion_common::logical_type::field::LogicalField;
use datafusion_common::logical_type::schema::{LogicalSchema, LogicalSchemaRef};
use datafusion_common::logical_type::field::LogicalPhysicalField;
use datafusion_common::logical_type::schema::{LogicalPhysicalSchema, LogicalPhysicalSchemaRef};
use datafusion_common::logical_type::signature::LogicalType;
use datafusion_common::logical_type::{ExtensionType, ExtensionTypeRef};
use datafusion_common::logical_type::{TypeRelation, TypeRelationRef};
use datafusion_expr::{Expr, TableType};
use std::any::Any;
use std::sync::Arc;
Expand Down Expand Up @@ -41,7 +41,7 @@ impl Default for CustomMagicalType {
}
}

impl ExtensionType for CustomMagicalType {
impl TypeRelation for CustomMagicalType {
fn logical(&self) -> &LogicalType {
&self.logical
}
Expand All @@ -62,17 +62,17 @@ impl TableProvider for ExampleTableSource {
self
}

fn schema(&self) -> LogicalSchemaRef {
fn schema(&self) -> LogicalPhysicalSchemaRef {
// TODO: ugly?
let custom_magical_type: ExtensionTypeRef =
let custom_magical_type: TypeRelationRef =
Arc::new(CustomMagicalType::default());

// This schema will be equivalent to:
// a -> Timestamp(Microsecond, None)
// b -> Utf8
// c -> Int64
Arc::new(LogicalSchema::new(vec![
LogicalField::new(
Arc::new(LogicalPhysicalSchema::new(vec![
LogicalPhysicalField::new(
"a",
DataType::RunEndEncoded(
Arc::new(Field::new("run_ends", DataType::Int64, false)),
Expand All @@ -84,8 +84,8 @@ impl TableProvider for ExampleTableSource {
),
false,
),
LogicalField::new("b", custom_magical_type, false),
LogicalField::new("c", DataType::Int64, true),
LogicalPhysicalField::new("b", custom_magical_type, false),
LogicalPhysicalField::new("c", DataType::Int64, true),
]))
}

Expand Down
6 changes: 3 additions & 3 deletions datafusion-examples/examples/parquet_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use datafusion::parquet::arrow::{
use datafusion::physical_optimizer::pruning::{PruningPredicate, PruningStatistics};
use datafusion::physical_plan::ExecutionPlan;
use datafusion::prelude::*;
use datafusion_common::logical_type::schema::LogicalSchemaRef;
use datafusion_common::logical_type::schema::LogicalPhysicalSchemaRef;
use datafusion_common::{
internal_datafusion_err, DFSchema, DataFusionError, Result, ScalarValue,
};
Expand Down Expand Up @@ -213,8 +213,8 @@ impl TableProvider for IndexTableProvider {
self
}

fn schema(&self) -> LogicalSchemaRef {
LogicalSchemaRef::new(self.index.schema().into())
fn schema(&self) -> LogicalPhysicalSchemaRef {
LogicalPhysicalSchemaRef::new(self.index.schema().into())
}

fn table_type(&self) -> TableType {
Expand Down
6 changes: 3 additions & 3 deletions datafusion-examples/examples/simple_udtf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use datafusion::execution::context::{ExecutionProps, SessionState};
use datafusion::physical_plan::memory::MemoryExec;
use datafusion::physical_plan::ExecutionPlan;
use datafusion::prelude::SessionContext;
use datafusion_common::logical_type::schema::LogicalSchemaRef;
use datafusion_common::logical_type::schema::LogicalPhysicalSchemaRef;
use datafusion_common::{plan_err, ScalarValue};
use datafusion_expr::simplify::SimplifyContext;
use datafusion_expr::{Expr, TableType};
Expand Down Expand Up @@ -85,8 +85,8 @@ impl TableProvider for LocalCsvTable {
self
}

fn schema(&self) -> LogicalSchemaRef {
LogicalSchemaRef::new(self.schema.clone().into())
fn schema(&self) -> LogicalPhysicalSchemaRef {
LogicalPhysicalSchemaRef::new(self.schema.clone().into())
}

fn table_type(&self) -> TableType {
Expand Down
18 changes: 9 additions & 9 deletions datafusion-examples/examples/sql_frontend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

use arrow::datatypes::DataType;
use datafusion_common::config::ConfigOptions;
use datafusion_common::logical_type::field::LogicalField;
use datafusion_common::logical_type::schema::{LogicalSchema, LogicalSchemaRef};
use datafusion_common::logical_type::TypeRelation;
use datafusion_common::logical_type::field::LogicalPhysicalField;
use datafusion_common::logical_type::schema::{LogicalPhysicalSchema, LogicalPhysicalSchemaRef};
use datafusion_common::logical_type::LogicalPhysicalType;
use datafusion_common::{plan_err, Result};
use datafusion_expr::{
AggregateUDF, Expr, LogicalPlan, ScalarUDF, TableProviderFilterPushDown, TableSource,
Expand Down Expand Up @@ -142,9 +142,9 @@ impl ContextProvider for MyContextProvider {
fn get_table_source(&self, name: TableReference) -> Result<Arc<dyn TableSource>> {
if name.table() == "person" {
Ok(Arc::new(MyTableSource {
schema: Arc::new(LogicalSchema::new(vec![
LogicalField::new("name", DataType::Utf8, false),
LogicalField::new("age", DataType::UInt8, false),
schema: Arc::new(LogicalPhysicalSchema::new(vec![
LogicalPhysicalField::new("name", DataType::Utf8, false),
LogicalPhysicalField::new("age", DataType::UInt8, false),
])),
}))
} else {
Expand All @@ -160,7 +160,7 @@ impl ContextProvider for MyContextProvider {
None
}

fn get_variable_type(&self, _variable_names: &[String]) -> Option<TypeRelation> {
fn get_variable_type(&self, _variable_names: &[String]) -> Option<LogicalPhysicalType> {
None
}

Expand All @@ -187,15 +187,15 @@ impl ContextProvider for MyContextProvider {

/// TableSource is the part of TableProvider needed for creating a LogicalPlan.
struct MyTableSource {
schema: LogicalSchemaRef,
schema: LogicalPhysicalSchemaRef,
}

impl TableSource for MyTableSource {
fn as_any(&self) -> &dyn Any {
self
}

fn schema(&self) -> LogicalSchemaRef {
fn schema(&self) -> LogicalPhysicalSchemaRef {
self.schema.clone()
}

Expand Down
10 changes: 5 additions & 5 deletions datafusion/common/src/column.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
//! Column

use crate::error::_schema_err;
use crate::logical_type::field::{LogicalField, LogicalFieldRef};
use crate::logical_type::field::{LogicalPhysicalField, LogicalPhysicalFieldRef};
use crate::utils::{parse_identifiers_normalized, quote_identifier};
use crate::{DFSchema, DataFusionError, Result, SchemaError, TableReference};
use std::collections::HashSet;
Expand Down Expand Up @@ -348,15 +348,15 @@ impl From<String> for Column {
}

/// Create a column, use qualifier and field name
impl From<(Option<&TableReference>, &LogicalField)> for Column {
fn from((relation, field): (Option<&TableReference>, &LogicalField)) -> Self {
impl From<(Option<&TableReference>, &LogicalPhysicalField)> for Column {
fn from((relation, field): (Option<&TableReference>, &LogicalPhysicalField)) -> Self {
Self::new(relation.cloned(), field.name())
}
}

/// Create a column, use qualifier and field name
impl From<(Option<&TableReference>, &LogicalFieldRef)> for Column {
fn from((relation, field): (Option<&TableReference>, &LogicalFieldRef)) -> Self {
impl From<(Option<&TableReference>, &LogicalPhysicalFieldRef)> for Column {
fn from((relation, field): (Option<&TableReference>, &LogicalPhysicalFieldRef)) -> Self {
Self::new(relation.cloned(), field.name())
}
}
Expand Down
Loading

0 comments on commit 5be9029

Please sign in to comment.