Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ serde_derive = "1.0.125"
serde_json = { version = "1.0", features = ["arbitrary_precision"] }
serde_regex = "1.1.0"
serde_yaml = "0.9.21"
sqlparser = "0.46.0"
syn = { version = "2.0.60", features = ["full"] }
tonic = { version = "0.8.3", features = ["tls-roots", "gzip"] }
tonic-build = { version = "0.8.4", features = ["prost"] }
Expand Down
2 changes: 1 addition & 1 deletion graph/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ slog = { version = "2.7.0", features = [
"release_max_level_trace",
"max_level_trace",
] }
sqlparser = { workspace = true }
# TODO: This should be reverted to the latest version once it's published
# stable-hash_legacy = { version = "0.3.3", package = "stable-hash" }
# stable-hash = { version = "0.4.2" }
Expand Down Expand Up @@ -90,7 +91,6 @@ web3 = { git = "https://github.com/graphprotocol/rust-web3", branch = "graph-pat
"arbitrary_precision",
] }
serde_plain = "1.0.2"
sqlparser = "0.45.0"
csv = "1.3.0"
object_store = { version = "0.9.1", features = ["gcp"] }

Expand Down
97 changes: 68 additions & 29 deletions graph/src/schema/input/sqlexpr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,17 @@ impl<'a> VisitExpr<'a> {
Cast {
expr,
data_type: _,
kind,
format: _,
} => self.visit_expr(expr),
} => match kind {
// Cast: `CAST(<expr> as <datatype>)`
// DoubleColon: `<expr>::<datatype>`
p::CastKind::Cast | p::CastKind::DoubleColon => self.visit_expr(expr),
// These two are not Postgres syntax
p::CastKind::TryCast | p::CastKind::SafeCast => {
self.nope(&format!("non-standard cast '{:?}'", kind))
}
},
Nested(expr) | IsFalse(expr) | IsNotFalse(expr) | IsTrue(expr) | IsNotTrue(expr)
| IsNull(expr) | IsNotNull(expr) => self.visit_expr(expr),
IsDistinctFrom(expr1, expr2) | IsNotDistinctFrom(expr1, expr2) => {
Expand All @@ -157,8 +166,6 @@ impl<'a> VisitExpr<'a> {
AnyOp { .. } => self.nope("AnyOp"),
AllOp { .. } => self.nope("AllOp"),
Convert { .. } => self.nope("Convert"),
TryCast { .. } => self.nope("TryCast"),
SafeCast { .. } => self.nope("SafeCast"),
AtTimeZone { .. } => self.nope("AtTimeZone"),
Extract { .. } => self.nope("Extract"),
Ceil { .. } => self.nope("Ceil"),
Expand All @@ -171,12 +178,8 @@ impl<'a> VisitExpr<'a> {
IntroducedString { .. } => self.nope("IntroducedString"),
TypedString { .. } => self.nope("TypedString"),
MapAccess { .. } => self.nope("MapAccess"),
AggregateExpressionWithFilter { .. } => self.nope("AggregateExpressionWithFilter"),
Exists { .. } => self.nope("Exists"),
Subquery(_) => self.nope("Subquery"),
ArraySubquery(_) => self.nope("ArraySubquery"),
ListAgg(_) => self.nope("ListAgg"),
ArrayAgg(_) => self.nope("ArrayAgg"),
GroupingSets(_) => self.nope("GroupingSets"),
Cube(_) => self.nope("Cube"),
Rollup(_) => self.nope("Rollup"),
Expand All @@ -191,6 +194,7 @@ impl<'a> VisitExpr<'a> {
QualifiedWildcard(_) => self.nope("QualifiedWildcard"),
Dictionary(_) => self.nope("Dictionary"),
OuterJoin(_) => self.nope("OuterJoin"),
Prior(_) => self.nope("Prior"),
}
}

Expand All @@ -201,12 +205,14 @@ impl<'a> VisitExpr<'a> {
filter,
null_treatment,
over,
distinct: _,
special: _,
order_by,
within_group,
} = func;

if filter.is_some() || null_treatment.is_some() || over.is_some() || !order_by.is_empty() {
if filter.is_some()
|| null_treatment.is_some()
|| over.is_some()
|| !within_group.is_empty()
{
return self.illegal_function(format!("call to {name} uses an illegal feature"));
}

Expand All @@ -217,22 +223,45 @@ impl<'a> VisitExpr<'a> {
));
}
self.visitor.visit_func_name(&mut idents[0])?;
for arg in pargs {
use p::FunctionArg::*;
match arg {
Named { .. } => {
return self.illegal_function(format!("call to {name} uses a named argument"));
match pargs {
p::FunctionArguments::None => { /* nothing to do */ }
p::FunctionArguments::Subquery(_) => {
return self.illegal_function(format!("call to {name} uses a subquery argument"))
}
p::FunctionArguments::List(pargs) => {
let p::FunctionArgumentList {
duplicate_treatment,
args,
clauses,
} = pargs;
if duplicate_treatment.is_some() {
return self
.illegal_function(format!("call to {name} uses a duplicate treatment"));
}
if !clauses.is_empty() {
return self.illegal_function(format!("call to {name} uses a clause"));
}
Unnamed(arg) => match arg {
p::FunctionArgExpr::Expr(expr) => {
self.visit_expr(expr)?;
}
p::FunctionArgExpr::QualifiedWildcard(_) | p::FunctionArgExpr::Wildcard => {
return self
.illegal_function(format!("call to {name} uses a wildcard argument"));
}
},
};
for arg in args {
use p::FunctionArg::*;
match arg {
Named { .. } => {
return self
.illegal_function(format!("call to {name} uses a named argument"));
}
Unnamed(arg) => match arg {
p::FunctionArgExpr::Expr(expr) => {
self.visit_expr(expr)?;
}
p::FunctionArgExpr::QualifiedWildcard(_)
| p::FunctionArgExpr::Wildcard => {
return self.illegal_function(format!(
"call to {name} uses a wildcard argument"
));
}
},
};
}
}
}
Ok(())
}
Expand Down Expand Up @@ -263,9 +292,19 @@ impl<'a> VisitExpr<'a> {
| PGNotLikeMatch
| PGNotILikeMatch
| PGStartsWith
| PGCustomBinaryOperator(_) => {
self.not_supported(format!("binary operator {op} is not supported"))
}
| PGCustomBinaryOperator(_)
| Arrow
| LongArrow
| HashArrow
| HashLongArrow
| AtAt
| AtArrow
| ArrowAt
| HashMinus
| AtQuestion
| Question
| QuestionAnd
| QuestionPipe => self.not_supported(format!("binary operator {op} is not supported")),
}
}

Expand Down
1 change: 1 addition & 0 deletions runtime/test/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ pub async fn test_module_latest(subgraph_id: &str, wasm_file: &str) -> WasmInsta
pub trait WasmInstanceExt {
fn invoke_export0_void(&mut self, f: &str) -> Result<(), Error>;
fn invoke_export1_val_void<V: wasmtime::WasmTy>(&mut self, f: &str, v: V) -> Result<(), Error>;
#[allow(dead_code)]
fn invoke_export0<R>(&mut self, f: &str) -> AscPtr<R>;
fn invoke_export1<C, T, R>(&mut self, f: &str, arg: &T) -> AscPtr<R>
where
Expand Down
27 changes: 0 additions & 27 deletions store/postgres/src/jsonb.rs

This file was deleted.

1 change: 0 additions & 1 deletion store/postgres/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ mod dynds;
mod fork;
mod functions;
mod jobs;
mod jsonb;
mod notification_listener;
mod primary;
pub mod query_store;
Expand Down
7 changes: 0 additions & 7 deletions store/postgres/src/relational_queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,6 @@ macro_rules! constraint_violation {
/// trait on a given column means "send these values to the database in a form
/// that can later be used for comparisons with that column"
trait ForeignKeyClauses {
/// The type of the column
fn column_type(&self) -> &ColumnType;

/// The name of the column
fn name(&self) -> &str;

Expand Down Expand Up @@ -167,10 +164,6 @@ impl PushBindParam for IdList {
}

impl ForeignKeyClauses for Column {
fn column_type(&self) -> &ColumnType {
&self.column_type
}

fn name(&self) -> &str {
self.name.as_str()
}
Expand Down
18 changes: 0 additions & 18 deletions tests/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,24 +176,6 @@ impl TestCase {
}
}

#[derive(Debug)]
struct Output {
stdout: Option<String>,
stderr: Option<String>,
}

impl std::fmt::Display for Output {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
if let Some(ref stdout) = self.stdout {
write!(f, "{}", stdout)?;
}
if let Some(ref stderr) = self.stderr {
write!(f, "{}", stderr)?
}
Ok(())
}
}

/// Run the given `query` against the `subgraph` and check that the result
/// has no errors and that the `data` portion of the response matches the
/// `exp` value.
Expand Down