Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

select 'abc' cause the server stuck #230

Open
frank-king opened this issue Aug 3, 2021 · 3 comments
Open

select 'abc' cause the server stuck #230

frank-king opened this issue Aug 3, 2021 · 3 comments
Labels

Comments

@frank-king
Copy link
Contributor

In the current version, doing queries like select 'abc' returns no result:

TensorBase :) select 'abc'

SELECT 'abc'

Ok.

0 rows in set. Elapsed: 0.008 sec. 

And I commented out this three lines in engine::datafusions:

if qs.copasss.len() == 0 {
let res: Vec<RecordBatch> = Vec::new();
return Ok(res);
}

The server will get stuck on this query

TensorBase :) select 'abc'

SELECT 'abc'

^C

However, integral literals can work:

TensorBase :) select 1

SELECT 1

┌─Int64(1)─┐
│        1 │
└──────────┘

1 rows in set. Elapsed: 0.005 sec. 
@frank-king frank-king mentioned this issue Aug 3, 2021
6 tasks
@jinmingjian jinmingjian added the type/bug bug label Aug 3, 2021
@jinmingjian
Copy link
Contributor

@whjpji thanks, this seems string literal handling problem. Let's fix!

@frank-king
Copy link
Contributor Author

frank-king commented Aug 7, 2021

This is caused by fee911c#diff-7e3045dfedcbf998dd7fe82a9c43989c11678cd970c88b571f82a92284aaac16 (see below). It works if I revert the patch.

@jinmingjian Could you please tell me the reason why this change is undid after introduced by 8657b53#diff-d39e44a629780cf9d813c70da62a65754b9e39c69cba1cb454c6a84a6849faa4?

If it was not a mistake during refactoring, I guess it breaks the original logics dealing with strings in A-DF. Should we have a discussion of how to deal with the strings which differ in encoding between CH and A-DF?

diff --git a/arrow-datafusion/datafusion/src/logical_plan/expr.rs b/crates/datafusion/src/logical_plan/expr.rs
rename from arrow-datafusion/datafusion/src/logical_plan/expr.rs
rename to crates/datafusion/src/logical_plan/expr.rs
--- a/arrow-datafusion/datafusion/src/logical_plan/expr.rs	(revision ca023f93d64d13ba36df89301faaa4c79fffeec6)
+++ b/crates/datafusion/src/logical_plan/expr.rs	(revision fee911c0b97ea1f75b1ca1bc50e58eee93c911b1)
@@ -1061,23 +1061,13 @@
 
 impl Literal for &str {
     fn lit(&self) -> Expr {
-        //FIXME debug_assert!(self.len()<128);
-        let mut s = String::new();
-        debug_assert!(self.len()<128);
-        s.push(self.len() as u8 as char);
-        s.push_str(self);
-        Expr::Literal(ScalarValue::LargeUtf8(Some(s)))
+        Expr::Literal(ScalarValue::LargeUtf8(Some((*self).to_owned())))
     }
 }
 
 impl Literal for String {
     fn lit(&self) -> Expr {
-        //FIXME debug_assert!(self.len()<128);
-        let mut s = String::new();
-        debug_assert!(self.len()<128);
-        s.push(self.len() as u8 as char);
-        s.push_str(self);
-        Expr::Literal(ScalarValue::LargeUtf8(Some(s)))
+        Expr::Literal(ScalarValue::LargeUtf8(Some((*self).to_owned())))
     }
 }

@jinmingjian
Copy link
Contributor

@whjpji sorry, this addition is the first hack-in. But for the latter, I remove these addition. That's we should not modify the string in this place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants