MCPcopy Create free account
hub / github.com/apache/datafusion / parse_json_access

Method parse_json_access

datafusion/sql/src/expr/mod.rs:664–685  ·  view source on GitHub ↗
(
        &self,
        schema: &DFSchema,
        planner_context: &mut PlannerContext,
        value: Box<SQLExpr>,
        path: &JsonPath,
    )

Source from the content-addressed store, hash-verified

662 }
663
664 fn parse_json_access(
665 &self,
666 schema: &DFSchema,
667 planner_context: &mut PlannerContext,
668 value: Box<SQLExpr>,
669 path: &JsonPath,
670 ) -> Result<Expr> {
671 let json_path = path.to_string();
672 let json_path = if let Some(json_path) = json_path.strip_prefix(":") {
673 // sqlparser's JsonPath display adds an extra `:` at the beginning.
674 json_path.to_owned()
675 } else {
676 json_path
677 };
678 self.build_logical_expr(
679 BinaryOperator::Custom(":".to_owned()),
680 self.sql_to_expr(*value, schema, planner_context)?,
681 // pass json path as a string literal, let the impl parse it when needed.
682 Expr::Literal(ScalarValue::Utf8(Some(json_path)), None),
683 schema,
684 )
685 }
686
687 /// Parses a struct(..) expression and plans it creation
688 fn parse_struct(

Callers 1

Calls 5

strip_prefixMethod · 0.80
build_logical_exprMethod · 0.80
LiteralInterface · 0.50
to_stringMethod · 0.45
sql_to_exprMethod · 0.45

Tested by

no test coverage detected