Skip to content

Commit 493a47a

Browse files
zhuliquanzhuliquan
zhuliquan
authored andcommitted
minor: regen datafusion protobuf
1 parent 0e939ed commit 493a47a

File tree

4 files changed

+53
-51
lines changed

4 files changed

+53
-51
lines changed

datafusion/physical-expr/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ itertools = { workspace = true, features = ["use_std"] }
5656
log = { workspace = true }
5757
paste = "^1.0"
5858
petgraph = "0.6.2"
59+
regex = { workspace = true }
5960

6061
[dev-dependencies]
6162
arrow = { workspace = true, features = ["test_utils"] }

datafusion/physical-expr/src/expressions/scalar_regex_match.rs

Lines changed: 51 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,16 @@ use arrow_array::{
2222
};
2323
use arrow_buffer::BooleanBufferBuilder;
2424
use arrow_schema::{DataType, Schema};
25-
use datafusion_common::ScalarValue;
25+
use datafusion_common::{Result as DFResult, ScalarValue};
2626
use datafusion_expr::ColumnarValue;
27-
use datafusion_physical_expr_common::physical_expr::{down_cast_any_ref, PhysicalExpr};
27+
use datafusion_physical_expr_common::physical_expr::PhysicalExpr;
2828
use regex::Regex;
29-
use std::{any::Any, hash::Hash, sync::Arc};
29+
use std::{
30+
any::Any,
31+
fmt::{Debug, Display, Formatter, Result as FmtResult},
32+
hash::Hash,
33+
sync::Arc,
34+
};
3035

3136
/// ScalarRegexMatchExpr
3237
/// Only used when evaluating regexp matching with literal pattern.
@@ -133,9 +138,7 @@ impl ScalarRegexMatchExpr {
133138
(true, true) => "NOT IMATCH",
134139
}
135140
}
136-
}
137141

138-
impl ScalarRegexMatchExpr {
139142
/// Evaluate the scalar regex match expression match array value
140143
fn evaluate_array(
141144
&self,
@@ -200,16 +203,9 @@ impl ScalarRegexMatchExpr {
200203
}
201204
}
202205

203-
impl std::hash::Hash for ScalarRegexMatchExpr {
204-
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
205-
self.negated.hash(state);
206-
self.case_insensitive.hash(state);
207-
self.expr.hash(state);
208-
self.pattern.hash(state);
209-
}
210-
}
206+
impl Eq for ScalarRegexMatchExpr {}
211207

212-
impl std::cmp::PartialEq for ScalarRegexMatchExpr {
208+
impl PartialEq for ScalarRegexMatchExpr {
213209
fn eq(&self, other: &Self) -> bool {
214210
self.negated.eq(&other.negated)
215211
&& self.case_insensitive.eq(&self.case_insensitive)
@@ -218,8 +214,17 @@ impl std::cmp::PartialEq for ScalarRegexMatchExpr {
218214
}
219215
}
220216

221-
impl std::fmt::Debug for ScalarRegexMatchExpr {
222-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
217+
impl Hash for ScalarRegexMatchExpr {
218+
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
219+
self.negated.hash(state);
220+
self.case_insensitive.hash(state);
221+
self.expr.hash(state);
222+
self.pattern.hash(state);
223+
}
224+
}
225+
226+
impl Debug for ScalarRegexMatchExpr {
227+
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
223228
f.debug_struct("ScalarRegexMatchExpr")
224229
.field("negated", &self.negated)
225230
.field("case_insensitive", &self.case_insensitive)
@@ -229,35 +234,26 @@ impl std::fmt::Debug for ScalarRegexMatchExpr {
229234
}
230235
}
231236

232-
impl std::fmt::Display for ScalarRegexMatchExpr {
233-
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
237+
impl Display for ScalarRegexMatchExpr {
238+
fn fmt(&self, f: &mut Formatter) -> FmtResult {
234239
write!(f, "{} {} {}", self.expr, self.op_name(), self.pattern)
235240
}
236241
}
237242

238243
impl PhysicalExpr for ScalarRegexMatchExpr {
239-
fn as_any(&self) -> &dyn std::any::Any {
244+
fn as_any(&self) -> &dyn Any {
240245
self
241246
}
242247

243-
fn data_type(
244-
&self,
245-
_: &arrow_schema::Schema,
246-
) -> datafusion_common::Result<arrow_schema::DataType> {
248+
fn data_type(&self, _: &Schema) -> DFResult<DataType> {
247249
Ok(DataType::Boolean)
248250
}
249251

250-
fn nullable(
251-
&self,
252-
input_schema: &arrow_schema::Schema,
253-
) -> datafusion_common::Result<bool> {
252+
fn nullable(&self, input_schema: &Schema) -> DFResult<bool> {
254253
Ok(self.expr.nullable(input_schema)? || self.pattern.nullable(input_schema)?)
255254
}
256255

257-
fn evaluate(
258-
&self,
259-
batch: &arrow_array::RecordBatch,
260-
) -> datafusion_common::Result<ColumnarValue> {
256+
fn evaluate(&self, batch: &arrow_array::RecordBatch) -> DFResult<ColumnarValue> {
261257
self.expr
262258
.evaluate(batch)
263259
.and_then(|lhs| {
@@ -274,14 +270,14 @@ impl PhysicalExpr for ScalarRegexMatchExpr {
274270
.map(ColumnarValue::Array)
275271
}
276272

277-
fn children(&self) -> Vec<&std::sync::Arc<dyn PhysicalExpr>> {
273+
fn children(&self) -> Vec<&Arc<dyn PhysicalExpr>> {
278274
vec![&self.expr, &self.pattern]
279275
}
280276

281277
fn with_new_children(
282-
self: std::sync::Arc<Self>,
283-
children: Vec<std::sync::Arc<dyn PhysicalExpr>>,
284-
) -> datafusion_common::Result<std::sync::Arc<dyn PhysicalExpr>> {
278+
self: Arc<Self>,
279+
children: Vec<Arc<dyn PhysicalExpr>>,
280+
) -> DFResult<Arc<dyn PhysicalExpr>> {
285281
Ok(Arc::new(ScalarRegexMatchExpr::new(
286282
self.negated,
287283
self.case_insensitive,
@@ -290,18 +286,24 @@ impl PhysicalExpr for ScalarRegexMatchExpr {
290286
)))
291287
}
292288

293-
fn dyn_hash(&self, state: &mut dyn std::hash::Hasher) {
294-
let mut s = state;
295-
self.hash(&mut s);
296-
}
297-
}
298-
299-
impl PartialEq<dyn Any> for ScalarRegexMatchExpr {
300-
fn eq(&self, other: &dyn Any) -> bool {
301-
down_cast_any_ref(other)
302-
.downcast_ref::<Self>()
303-
.map(|x| self == x)
304-
.unwrap_or(false)
289+
fn evaluate_selection(
290+
&self,
291+
batch: &arrow_array::RecordBatch,
292+
selection: &BooleanArray,
293+
) -> DFResult<ColumnarValue> {
294+
let tmp_batch = arrow::compute::filter_record_batch(batch, selection)?;
295+
296+
let tmp_result = self.evaluate(&tmp_batch)?;
297+
298+
if batch.num_rows() == tmp_batch.num_rows() {
299+
// All values from the `selection` filter are true.
300+
Ok(tmp_result)
301+
} else if let ColumnarValue::Array(a) = tmp_result {
302+
datafusion_physical_expr_common::utils::scatter(selection, a.as_ref())
303+
.map(ColumnarValue::Array)
304+
} else {
305+
Ok(tmp_result)
306+
}
305307
}
306308
}
307309

@@ -310,7 +312,7 @@ fn array_regexp_match(
310312
array: &dyn ArrayAccessor<Item = &str>,
311313
regex: &Regex,
312314
negated: bool,
313-
) -> datafusion_common::Result<ColumnarValue> {
315+
) -> DFResult<ColumnarValue> {
314316
let null_bit_buffer = array.nulls().map(|x| x.inner().sliced());
315317
let mut buffer_builder = BooleanBufferBuilder::new(array.len());
316318

@@ -359,7 +361,7 @@ pub fn scalar_regex_match(
359361
expr: Arc<dyn PhysicalExpr>,
360362
pattern: Arc<dyn PhysicalExpr>,
361363
input_schema: &Schema,
362-
) -> datafusion_common::Result<Arc<dyn PhysicalExpr>> {
364+
) -> DFResult<Arc<dyn PhysicalExpr>> {
363365
let valid_data_type = |data_type: &DataType| {
364366
if !matches!(
365367
data_type,

datafusion/proto/proto/datafusion.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ message PhysicalExprNode {
841841
PhysicalLikeExprNode like_expr = 18;
842842

843843
PhysicalExtensionExprNode extension = 19;
844-
844+
845845
PhysicalScalarRegexMatchExprNode scalar_regex_match_expr = 20;
846846
}
847847
}

datafusion/proto/src/generated/prost.rs

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)