-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jiayu Liu
committed
May 21, 2021
1 parent
bf5b8a5
commit 1723926
Showing
3 changed files
with
106 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
//! Defines physical expressions that can evaluated at runtime during query execution | ||
use std::any::Any; | ||
use std::convert::TryFrom; | ||
use std::sync::Arc; | ||
|
||
use crate::error::{DataFusionError, Result}; | ||
use crate::physical_plan::{Accumulator, AggregateExpr, PhysicalExpr}; | ||
use crate::scalar::ScalarValue; | ||
use arrow::compute; | ||
use arrow::datatypes::{DataType, TimeUnit}; | ||
use arrow::{ | ||
array::{ | ||
ArrayRef, Float32Array, Float64Array, Int16Array, Int32Array, Int64Array, Int8Array, | ||
LargeStringArray, StringArray, TimestampMicrosecondArray, TimestampMillisecondArray, | ||
TimestampNanosecondArray, TimestampSecondArray, UInt16Array, UInt32Array, | ||
UInt64Array, UInt8Array, | ||
}, | ||
datatypes::Field, | ||
}; | ||
|
||
pub struct RowNumber { | ||
name: String, | ||
expr: Arc<dyn PhysicalSortExpr>, | ||
} | ||
|
||
impl RowNumber { | ||
/// Create a new MAX aggregate function | ||
pub fn new(expr: Arc<dyn PhysicalExpr>, name: String) -> Self { | ||
Self { name, expr } | ||
} | ||
} | ||
|
||
impl BuiltInWindowFunctionExpr for RowNumber { | ||
/// Return a reference to Any that can be used for downcasting | ||
fn as_any(&self) -> &dyn Any { | ||
self | ||
} | ||
|
||
fn field(&self) -> Result<Field> { | ||
let nullable = false; | ||
let data_type = DataType::UInt64; | ||
Ok(Field::new(&self.name, data_type, nullable)) | ||
} | ||
|
||
fn expressions(&self) -> Vec<Arc<dyn PhysicalExpr>> { | ||
vec![self.expr.clone()] | ||
} | ||
|
||
fn name(&self) -> &str { | ||
&self.name | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters