Skip to content

Commit 6852d50

Browse files
authored
chore: simplify map const (#18440)
## Which issue does this PR close? ## Rationale for this change map const wont be simplified, the comment says "TODO: support the optimization for `Map` type after support impl hash for it", but it seems that hash is already supported for map. ## What changes are included in this PR? remove the todo ## Are these changes tested? UT ## Are there any user-facing changes? No
1 parent 7b5685b commit 6852d50

File tree

2 files changed

+13
-25
lines changed

2 files changed

+13
-25
lines changed

datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -722,35 +722,12 @@ impl<'a> ConstEvaluator<'a> {
722722
} else {
723723
// Non-ListArray
724724
match ScalarValue::try_from_array(&a, 0) {
725-
Ok(s) => {
726-
// TODO: support the optimization for `Map` type after support impl hash for it
727-
if matches!(&s, ScalarValue::Map(_)) {
728-
ConstSimplifyResult::SimplifyRuntimeError(
729-
DataFusionError::NotImplemented("Const evaluate for Map type is still not supported".to_string()),
730-
expr,
731-
)
732-
} else {
733-
ConstSimplifyResult::Simplified(s, metadata)
734-
}
735-
}
725+
Ok(s) => ConstSimplifyResult::Simplified(s, metadata),
736726
Err(err) => ConstSimplifyResult::SimplifyRuntimeError(err, expr),
737727
}
738728
}
739729
}
740-
ColumnarValue::Scalar(s) => {
741-
// TODO: support the optimization for `Map` type after support impl hash for it
742-
if matches!(&s, ScalarValue::Map(_)) {
743-
ConstSimplifyResult::SimplifyRuntimeError(
744-
DataFusionError::NotImplemented(
745-
"Const evaluate for Map type is still not supported"
746-
.to_string(),
747-
),
748-
expr,
749-
)
750-
} else {
751-
ConstSimplifyResult::Simplified(s, metadata)
752-
}
753-
}
730+
ColumnarValue::Scalar(s) => ConstSimplifyResult::Simplified(s, metadata),
754731
}
755732
}
756733
}

datafusion/sqllogictest/test_files/simplify_expr.slt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,14 @@ query B
107107
SELECT a / NULL::DECIMAL(4,3) > 1.2::decimal(2,1) FROM VALUES (1) AS t(a);
108108
----
109109
NULL
110+
111+
query TT
112+
explain SELECT CASE WHEN 1 > 0 THEN MAP {'x': 100} ELSE MAP {'y': 200} END AS a;
113+
----
114+
logical_plan
115+
01)Projection: Map([{"x":"100"}]) AS a
116+
02)--EmptyRelation: rows=1
117+
physical_plan
118+
01)ProjectionExec: expr=[[{x:100}] as a]
119+
02)--PlaceholderRowExec
120+

0 commit comments

Comments
 (0)