MCPcopy Create free account
hub / github.com/PRQL/prql / translate_query_sstring

Function translate_query_sstring

prqlc/prqlc/src/sql/gen_query.rs:559–585  ·  view source on GitHub ↗
(
    items: Vec<InterpolateItem<Expr>>,
    ctx: &mut Context,
)

Source from the content-addressed store, hash-verified

557}
558
559pub(super) fn translate_query_sstring(
560 items: Vec<InterpolateItem<Expr>>,
561 ctx: &mut Context,
562) -> Result<sql_ast::Query> {
563 let string = translate_sstring(items, ctx)?;
564
565 let re = Regex::new(r"(?i)^SELECT\b").unwrap();
566 let prefix = string.trim().get(0..7).unwrap_or_default();
567
568 if re.is_match(prefix) {
569 if let Some(string) = string.trim().strip_prefix(prefix) {
570 return Ok(default_query(sql_ast::SetExpr::Select(Box::new(
571 sql_ast::Select {
572 projection: vec![sql_ast::SelectItem::UnnamedExpr(sql_ast::Expr::Identifier(
573 sql_ast::Ident::new(string),
574 ))],
575 ..default_select()
576 },
577 ))));
578 }
579 }
580
581 Err(
582 Error::new_simple("s-strings representing a table must start with `SELECT `".to_string())
583 .push_hint("this is a limitation by current compiler implementation"),
584 )
585}
586
587pub(super) fn translate_query_operator(
588 name: String,

Callers 1

translate_relationFunction · 0.85

Calls 5

translate_sstringFunction · 0.85
default_queryFunction · 0.85
default_selectFunction · 0.85
push_hintMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected