Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
43f5c9a
Initial commit
mustafasrepo Jun 20, 2023
7693076
Add primary key to DFSchema
mustafasrepo Jun 21, 2023
ddde0c4
store primary key in metadata during schema
mustafasrepo Jul 3, 2023
16db70d
all tests pass
mustafasrepo Jul 3, 2023
b401c67
simplifications
mustafasrepo Jul 3, 2023
dd9715f
Move test to the .slt file
mustafasrepo Jul 3, 2023
0e34baf
Merge branch 'main' into feature/primary_key_utilize
mustafasrepo Jul 3, 2023
945029f
simplifications
mustafasrepo Jul 3, 2023
72eba73
Simplifications
mustafasrepo Jul 3, 2023
511353e
primary key with associated expression indices
mustafasrepo Jul 3, 2023
4986bda
boilerplate for primary key propagation between executors
mustafasrepo Jul 4, 2023
8fe9852
Add new tests
mustafasrepo Jul 5, 2023
da1b947
Add Projection primary key handling
mustafasrepo Jul 5, 2023
d6cf418
Keep primary key as vec
mustafasrepo Jul 6, 2023
9242581
Move hash map to struct
mustafasrepo Jul 6, 2023
89719d9
simplifications
mustafasrepo Jul 6, 2023
b3632da
Update comments
mustafasrepo Jul 6, 2023
355daf8
Merge branch 'main' into feature/primary_key_utilize
mustafasrepo Jul 7, 2023
b738c07
Merge branch 'main' into feature/primary_key_utilize
mustafasrepo Jul 7, 2023
67c6efa
Merge branch 'main' into feature/primary_key_utilize
mustafasrepo Jul 14, 2023
d735773
Merge branch 'main' into feature/primary_key_utilize
mustafasrepo Jul 18, 2023
f152b58
Update datafusion/core/src/physical_planner.rs
mustafasrepo Jul 18, 2023
638cc64
Merge branch 'feature/primary_key_utilize' of https://github.com/synn…
mustafasrepo Jul 18, 2023
639c55c
Remove unnecessary code
mustafasrepo Jul 18, 2023
dabf833
Rename, update comments
mustafasrepo Jul 18, 2023
5b60c42
Merge branch 'main' into feature/primary_key_utilize
mustafasrepo Jul 19, 2023
43d47f6
Simplifications
mustafasrepo Jul 19, 2023
170cb87
Minor changes
mustafasrepo Jul 19, 2023
3acef96
minor changes
mustafasrepo Jul 19, 2023
093091b
Merge branch 'main' into feature/primary_key_utilize
mustafasrepo Jul 19, 2023
23e2938
Code style + improved comments
ozankabak Jul 19, 2023
b5cfc90
Add new tests, address TODO, Add comments
mustafasrepo Jul 20, 2023
fd000a0
Final review
ozankabak Jul 20, 2023
ad6714c
Address reviews, change design to encapsulate functional dependency
mustafasrepo Jul 21, 2023
f440adf
Rename variables
mustafasrepo Jul 21, 2023
349910f
Change primary key API
mustafasrepo Jul 24, 2023
9c0f6d0
Fix test
mustafasrepo Jul 24, 2023
6e64b0c
Functional dependency review
ozankabak Jul 25, 2023
ecb6b5b
Address TODO, fix failing tests
mustafasrepo Jul 25, 2023
091126a
Merge with apache main
mustafasrepo Jul 25, 2023
8866b30
Fix TODO.
mustafasrepo Jul 25, 2023
558e7dc
Address reviews
mustafasrepo Jul 27, 2023
c4cd98b
Implement Constraints struct
mustafasrepo Jul 27, 2023
45ce249
Convert some pub functions to private
mustafasrepo Jul 27, 2023
d219bfe
Minor changes
mustafasrepo Jul 27, 2023
d4644ed
Merge branch 'apache_main' into feature/primary_key_utilize
mustafasrepo Jul 27, 2023
c989acd
Minor changes
mustafasrepo Jul 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions datafusion/common/src/dfschema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,17 @@

use std::collections::{HashMap, HashSet};
use std::convert::TryFrom;
use std::fmt::{Display, Formatter};
use std::hash::Hash;
use std::sync::Arc;

use crate::error::{unqualified_field_not_found, DataFusionError, Result, SchemaError};
use crate::{field_not_found, Column, OwnedTableReference, TableReference};
use crate::{
field_not_found, Column, FunctionalDependencies, OwnedTableReference, TableReference,
};

use arrow::compute::can_cast_types;
use arrow::datatypes::{DataType, Field, FieldRef, Fields, Schema, SchemaRef};
use std::fmt::{Display, Formatter};

/// A reference-counted reference to a `DFSchema`.
pub type DFSchemaRef = Arc<DFSchema>;
Expand All @@ -40,6 +42,8 @@ pub struct DFSchema {
fields: Vec<DFField>,
/// Additional metadata in form of key value pairs
metadata: HashMap<String, String>,
/// Stores functional dependencies in the schema.
functional_dependencies: FunctionalDependencies,
}

impl DFSchema {
Expand All @@ -48,6 +52,7 @@ impl DFSchema {
Self {
fields: vec![],
metadata: HashMap::new(),
functional_dependencies: FunctionalDependencies::empty(),
}
}

Expand Down Expand Up @@ -97,7 +102,11 @@ impl DFSchema {
));
}
}
Ok(Self { fields, metadata })
Ok(Self {
fields,
metadata,
functional_dependencies: FunctionalDependencies::empty(),
})
}

/// Create a `DFSchema` from an Arrow schema and a given qualifier
Expand All @@ -116,6 +125,15 @@ impl DFSchema {
)
}

/// Assigns functional dependencies.
pub fn with_functional_dependencies(
mut self,
functional_dependencies: FunctionalDependencies,
) -> Self {
self.functional_dependencies = functional_dependencies;
self
}

/// Create a new schema that contains the fields from this schema followed by the fields
/// from the supplied schema. An error will be returned if there are duplicate field names.
pub fn join(&self, schema: &DFSchema) -> Result<Self> {
Expand Down Expand Up @@ -471,6 +489,11 @@ impl DFSchema {
pub fn metadata(&self) -> &HashMap<String, String> {
&self.metadata
}

/// Get functional dependencies
pub fn functional_dependencies(&self) -> &FunctionalDependencies {
&self.functional_dependencies
}
}

impl From<DFSchema> for Schema {
Expand Down
Loading