Uh oh!
There was an error while loading. Please reload this page.
feat: Support Substring(str [from int] [for int]) - #1621
Conversation
| Ok(()) | ||
| } | ||
| #[cfg(feature = "unicode_expressions")] |
There was a problem hiding this comment.
I didnt find any helpers to assert that function return error, should I introduce a new one or did I miss something?
There was a problem hiding this comment.
I did not find one either.
You could potentially use the #[should_panic annotation. For example, something like (untested):
#[tokio::test]#[should_panic(expected = "negative substring length not allowed")]asyncfntest_substring_expr_bad() -> Result<()>{test_expression!("substring('alphabet' from -1 for 1)","l");}A helper would be great
xudong963
commented
Jan 20, 2022
Thanks @ovr ! Lol, I also have just done exactly this for #175 Our idea is same, transfer let sql_expr = SQLExpr::Function(Function{name:ObjectName([Ident{value:"substr".to_string(),quote_style:None,}].to_vec(),),args:[FunctionArg::Unnamed(*expr.clone()),FunctionArg::Unnamed(from_expr),FunctionArg::Unnamed(for_expr),].to_vec(),over:None,distinct:false,});dbg!(schema.clone());self.sql_expr_to_logical_expr(&sql_expr, schema)I'll help to review after getting up |
| Ok(()) | ||
| } | ||
| #[cfg(feature = "unicode_expressions")] |
There was a problem hiding this comment.
I did not find one either.
You could potentially use the #[should_panic annotation. For example, something like (untested):
#[tokio::test]#[should_panic(expected = "negative substring length not allowed")]asyncfntest_substring_expr_bad() -> Result<()>{test_expression!("substring('alphabet' from -1 for 1)","l");}A helper would be great
Hi, @ovr I do some case tests with Postgres in my local. The followings are some differences. BTW, It'll be better to integration testing to compare with postgres |
| #[cfg(feature = "unicode_expressions")] | ||
| #[tokio::test] | ||
| async fn test_substring_expr() -> Result<()> { |
There was a problem hiding this comment.
We can add a test which from k (k <=0)
alamb
commented
Jan 22, 2022
@ovr would you like to address the discrepancies that @xudong963 found with postgres? |
ovr
commented
Jan 24, 2022
Good catch!
@alamb I've created an additional PR to fix that - #1660, it will be better to land it before this PR. Thanks |
alamb
commented
Jan 24, 2022
Thanks @ovr |
Which issue does this PR close?
I didn't create an issue for it.
Rationale for this change
DF supports
substrfunction, but it doesn't support substring expression. In this PR I've implemented support for substring expression in planner.What changes are included in this PR?
Are there any user-facing changes?
Nope.
Thanks