Skip to content

Commit

Permalink
Merge branch 'apache:main' into feature/11320_session_state_builder
Browse files Browse the repository at this point in the history
  • Loading branch information
Omega359 authored Jul 10, 2024
2 parents 490214d + cc7484e commit 93a3a7d
Show file tree
Hide file tree
Showing 16 changed files with 396 additions and 165 deletions.
2 changes: 2 additions & 0 deletions datafusion/common-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
// Make cheap clones clear: https://github.com/apache/datafusion/issues/11143
#![deny(clippy::clone_on_ref_ptr)]

pub mod common;

Expand Down
12 changes: 6 additions & 6 deletions datafusion/common/src/dfschema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ impl DFSchema {
schema: &SchemaRef,
) -> Result<Self> {
let dfschema = Self {
inner: schema.clone(),
inner: Arc::clone(schema),
field_qualifiers: qualifiers,
functional_dependencies: FunctionalDependencies::empty(),
};
Expand Down Expand Up @@ -311,7 +311,7 @@ impl DFSchema {
};
if !duplicated_field {
// self.inner.fields.push(field.clone());
schema_builder.push(field.clone());
schema_builder.push(Arc::clone(field));
qualifiers.push(qualifier.cloned());
}
}
Expand Down Expand Up @@ -1276,23 +1276,23 @@ mod tests {
let arrow_schema_ref = Arc::new(arrow_schema.clone());

let df_schema = DFSchema {
inner: arrow_schema_ref.clone(),
inner: Arc::clone(&arrow_schema_ref),
field_qualifiers: vec![None; arrow_schema_ref.fields.len()],
functional_dependencies: FunctionalDependencies::empty(),
};
let df_schema_ref = Arc::new(df_schema.clone());

{
let arrow_schema = arrow_schema.clone();
let arrow_schema_ref = arrow_schema_ref.clone();
let arrow_schema_ref = Arc::clone(&arrow_schema_ref);

assert_eq!(df_schema, arrow_schema.to_dfschema().unwrap());
assert_eq!(df_schema, arrow_schema_ref.to_dfschema().unwrap());
}

{
let arrow_schema = arrow_schema.clone();
let arrow_schema_ref = arrow_schema_ref.clone();
let arrow_schema_ref = Arc::clone(&arrow_schema_ref);

assert_eq!(df_schema_ref, arrow_schema.to_dfschema_ref().unwrap());
assert_eq!(df_schema_ref, arrow_schema_ref.to_dfschema_ref().unwrap());
Expand Down Expand Up @@ -1322,7 +1322,7 @@ mod tests {
let schema = Arc::new(Schema::new(vec![a_field, b_field]));

let df_schema = DFSchema {
inner: schema.clone(),
inner: Arc::clone(&schema),
field_qualifiers: vec![None; schema.fields.len()],
functional_dependencies: FunctionalDependencies::empty(),
};
Expand Down
3 changes: 3 additions & 0 deletions datafusion/common/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,9 @@ make_error!(config_err, config_datafusion_err, Configuration);
// Exposes a macro to create `DataFusionError::Substrait` with optional backtrace
make_error!(substrait_err, substrait_datafusion_err, Substrait);

// Exposes a macro to create `DataFusionError::ResourcesExhausted` with optional backtrace
make_error!(resources_err, resources_datafusion_err, ResourcesExhausted);

// Exposes a macro to create `DataFusionError::SQL` with optional backtrace
#[macro_export]
macro_rules! sql_datafusion_err {
Expand Down
19 changes: 12 additions & 7 deletions datafusion/common/src/hash_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ fn hash_list_array<OffsetSize>(
where
OffsetSize: OffsetSizeTrait,
{
let values = array.values().clone();
let values = Arc::clone(array.values());
let offsets = array.value_offsets();
let nulls = array.nulls();
let mut values_hashes = vec![0u64; values.len()];
Expand Down Expand Up @@ -274,7 +274,7 @@ fn hash_fixed_list_array(
random_state: &RandomState,
hashes_buffer: &mut [u64],
) -> Result<()> {
let values = array.values().clone();
let values = Arc::clone(array.values());
let value_len = array.value_length();
let offset_size = value_len as usize / array.len();
let nulls = array.nulls();
Expand Down Expand Up @@ -622,19 +622,19 @@ mod tests {
vec![
(
Arc::new(Field::new("bool", DataType::Boolean, false)),
boolarr.clone() as ArrayRef,
Arc::clone(&boolarr) as ArrayRef,
),
(
Arc::new(Field::new("i32", DataType::Int32, false)),
i32arr.clone() as ArrayRef,
Arc::clone(&i32arr) as ArrayRef,
),
(
Arc::new(Field::new("i32", DataType::Int32, false)),
i32arr.clone() as ArrayRef,
Arc::clone(&i32arr) as ArrayRef,
),
(
Arc::new(Field::new("bool", DataType::Boolean, false)),
boolarr.clone() as ArrayRef,
Arc::clone(&boolarr) as ArrayRef,
),
],
Buffer::from(&[0b001011]),
Expand Down Expand Up @@ -710,7 +710,12 @@ mod tests {
let random_state = RandomState::with_seeds(0, 0, 0, 0);

let mut one_col_hashes = vec![0; strings1.len()];
create_hashes(&[dict_array.clone()], &random_state, &mut one_col_hashes).unwrap();
create_hashes(
&[Arc::clone(&dict_array) as ArrayRef],
&random_state,
&mut one_col_hashes,
)
.unwrap();

let mut two_col_hashes = vec![0; strings1.len()];
create_hashes(
Expand Down
2 changes: 2 additions & 0 deletions datafusion/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
// Make cheap clones clear: https://github.com/apache/datafusion/issues/11143
#![deny(clippy::clone_on_ref_ptr)]

mod column;
mod dfschema;
Expand Down
Loading

0 comments on commit 93a3a7d

Please sign in to comment.