Skip to content

Commit ea904c1

Browse files
committed
feat: Upgrades to sqltk v0.6.0 and sqltk-parser v0.53.0-cipherstash.1, with corresponding adjustments to accommodate the parser upgrade.
1 parent dea0c7f commit ea904c1

10 files changed

Lines changed: 74 additions & 15 deletions

File tree

Cargo.lock

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

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ strip = "none"
3535
debug = true
3636

3737
[workspace.dependencies]
38-
sqltk = { version = "0.5.0" }
39-
sqltk-parser = { version = "0.52.0" }
38+
sqltk = { version = "0.6.0" }
39+
sqltk-parser = { version = "0.53.0-cipherstash.1" }
4040
thiserror = "2.0.9"
4141
tokio = { version = "1.44", features = ["full"] }
4242
tracing = "0.1"

packages/eql-mapper/src/importer.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,18 @@ impl<'ast> Importer<'ast> {
220220
))
221221
}
222222

223+
#[allow(unused_variables)]
224+
TableFactor::OpenJsonTable {
225+
json_expr,
226+
json_path,
227+
columns,
228+
alias,
229+
} => {
230+
return Err(ImportError::UnsupportedTableFactorVariant(
231+
"OpenJsonTable".to_owned(),
232+
))
233+
}
234+
223235
#[allow(unused_variables)]
224236
TableFactor::Pivot {
225237
table,

packages/eql-mapper/src/inference/infer_type_impls/expr.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ impl<'ast> InferType<'ast, Expr> for TypeInferencer<'ast> {
2525
}
2626

2727
#[allow(unused_variables)]
28-
Expr::Wildcard => {
28+
Expr::Wildcard(_) => {
2929
self.unify_node_with_type(this_expr, self.resolve_wildcard()?)?;
3030
}
3131

3232
#[allow(unused_variables)]
33-
Expr::QualifiedWildcard(object_name) => {
33+
Expr::QualifiedWildcard(object_name, _) => {
3434
self.unify_node_with_type(
3535
this_expr,
3636
self.resolve_qualified_wildcard(&object_name.0)?,
@@ -345,6 +345,13 @@ impl<'ast> InferType<'ast, Expr> for TypeInferencer<'ast> {
345345
self.unify_node_with_type(this_expr, self.get_node_type(function))?;
346346
}
347347

348+
// `<arbitrary-expr>.<function-call>.<function-call-expr>...`
349+
Expr::Method(_) => {
350+
return Err(TypeError::UnsupportedSqlFeature(
351+
"MSSQL Expression Method".into(),
352+
))
353+
}
354+
348355
// When operand is Some(operand), all conditions must be of type expr and expr must support equality
349356
// When operand is None, all conditions must be native (they are boolean)
350357
// The elements of `results` and else_result must be the same type

packages/eql-mapper/src/inference/infer_type_impls/function.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl<'ast> InferType<'ast, Function> for TypeInferencer<'ast> {
4444
FunctionArguments::List(args_list) => {
4545
if args_list.args.len() == 1 {
4646
match &args_list.args[0] {
47-
FunctionArg::Named { .. } => {
47+
FunctionArg::Named { .. } | FunctionArg::ExprNamed { .. } => {
4848
return Err(TypeError::FunctionCall(format!(
4949
"{} cannot be called with named arguments",
5050
fn_name.last().unwrap(),
@@ -97,6 +97,22 @@ impl<'ast> InferType<'ast, Function> for TypeInferencer<'ast> {
9797
self.unify_node_with_type(function, Type::any_native())?;
9898
for arg in &args_list.args {
9999
match arg {
100+
FunctionArg::ExprNamed {
101+
name,
102+
arg,
103+
operator: _,
104+
} => {
105+
self.unify_node_with_type(name, Type::any_native())?;
106+
match arg {
107+
FunctionArgExpr::Expr(expr) => {
108+
self.unify_node_with_type(expr, Type::any_native())?;
109+
}
110+
// Aggregate functions like COUNT(table.*)
111+
FunctionArgExpr::QualifiedWildcard(_) => {}
112+
// Aggregate functions like COUNT(*)
113+
FunctionArgExpr::Wildcard => {}
114+
}
115+
}
100116
FunctionArg::Named { arg, .. } | FunctionArg::Unnamed(arg) => match arg
101117
{
102118
FunctionArgExpr::Expr(expr) => {

packages/eql-mapper/src/inference/infer_type_impls/select_items.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ impl<'ast> InferType<'ast, Vec<SelectItem>> for TypeInferencer<'ast> {
3939
#[allow(unused_variables)]
4040
SelectItem::QualifiedWildcard(object_name, options) => {
4141
let WildcardAdditionalOptions {
42+
wildcard_token: _,
4243
opt_ilike: None,
4344
opt_exclude: None,
4445
opt_except: None,
@@ -56,6 +57,7 @@ impl<'ast> InferType<'ast, Vec<SelectItem>> for TypeInferencer<'ast> {
5657

5758
SelectItem::Wildcard(options) => {
5859
let WildcardAdditionalOptions {
60+
wildcard_token: _,
5961
opt_ilike: None,
6062
opt_exclude: None,
6163
opt_except: None,

packages/eql-mapper/src/transformation_rules/group_by_eql_col.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
use std::{collections::HashMap, mem, sync::Arc};
22

33
use sqltk::{NodeKey, NodePath, Visitable};
4-
use sqltk_parser::ast::{Expr, GroupByExpr, Ident, ObjectName};
4+
use sqltk_parser::ast::{
5+
helpers::attached_token::AttachedToken, Expr, GroupByExpr, Ident, ObjectName,
6+
};
7+
use sqltk_parser::tokenizer::{Span, Token, TokenWithSpan};
58

69
use crate::{EqlMapperError, Type, Value};
710

@@ -30,7 +33,10 @@ impl<'ast> TransformationRule<'ast> for GroupByEqlCol<'ast> {
3033
// Nodes are modified starting from the leaf nodes, to target_node *is* what we want to be wrapping.
3134
// So we steal the existing value and replace the original with a cheap placeholder (Expr::Wildcard).
3235
// Stealing the original subtree means we can avoid cloning it.
33-
let transformed_expr = mem::replace(target_node, Expr::Wildcard);
36+
let transformed_expr = mem::replace(
37+
target_node,
38+
Expr::Wildcard(AttachedToken(TokenWithSpan::new(Token::EOF, Span::empty()))),
39+
);
3440

3541
*target_node = helpers::wrap_in_1_arg_function(
3642
transformed_expr,

packages/eql-mapper/src/transformation_rules/helpers.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ pub(crate) fn wrap_in_1_arg_function(expr: Expr, name: ObjectName) -> Expr {
4444
null_treatment: None,
4545
over: None,
4646
within_group: vec![],
47+
uses_odbc_syntax: false,
4748
})
4849
}
4950

packages/eql-mapper/src/transformation_rules/preserve_effective_aliases.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
use std::mem;
22

33
use sqltk::{NodePath, Visitable};
4-
use sqltk_parser::ast::{Expr, Function, Ident, Select, SelectItem};
4+
use sqltk_parser::ast::{
5+
helpers::attached_token::AttachedToken, Expr, Function, Ident, Select, SelectItem,
6+
};
7+
use sqltk_parser::tokenizer::{Span, Token, TokenWithSpan};
58

69
use crate::EqlMapperError;
710

@@ -105,7 +108,13 @@ impl PreserveEffectiveAliases {
105108
{
106109
if effective_target_alias != effective_source_alias {
107110
*target_node = SelectItem::ExprWithAlias {
108-
expr: mem::replace(expr, Expr::Wildcard),
111+
expr: mem::replace(
112+
expr,
113+
Expr::Wildcard(AttachedToken(TokenWithSpan::new(
114+
Token::EOF,
115+
Span::empty(),
116+
))),
117+
),
109118
alias: effective_source_alias,
110119
};
111120

packages/eql-mapper/src/transformation_rules/wrap_eql_cols_in_order_by_with_ore_fn.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
use std::{collections::HashMap, mem, sync::Arc};
22

33
use sqltk::{NodeKey, NodePath, Visitable};
4-
use sqltk_parser::ast::{Expr, Ident, ObjectName, OrderByExpr};
4+
use sqltk_parser::ast::{
5+
helpers::attached_token::AttachedToken, Expr, Ident, ObjectName, OrderByExpr,
6+
};
7+
use sqltk_parser::tokenizer::{Span, Token, TokenWithSpan};
58

69
use crate::{EqlMapperError, Type, Value};
710

@@ -44,7 +47,10 @@ impl<'ast> TransformationRule<'ast> for WrapEqlColsInOrderByWithOreFn<'ast> {
4447
if let Some((_order_by_expr,)) = node_path.last_1_as::<OrderByExpr>() {
4548
let target_node = target_node.downcast_mut::<OrderByExpr>().unwrap();
4649

47-
let expr_to_wrap = mem::replace(&mut target_node.expr, Expr::Wildcard);
50+
let expr_to_wrap = mem::replace(
51+
&mut target_node.expr,
52+
Expr::Wildcard(AttachedToken(TokenWithSpan::new(Token::EOF, Span::empty()))),
53+
);
4854

4955
target_node.expr = wrap_in_1_arg_function(
5056
expr_to_wrap,

0 commit comments

Comments
 (0)