Skip to content

Commit

Permalink
fix(query): fix get field with float value (#13041)
Browse files Browse the repository at this point in the history
  • Loading branch information
b41sh authored Sep 27, 2023
1 parent 84b0451 commit 7691b38
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
17 changes: 10 additions & 7 deletions src/query/sql/src/planner/binder/distinct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use crate::plans::ScalarExpr;
use crate::plans::ScalarItem;
use crate::BindContext;
use crate::IndexType;
use crate::WindowChecker;

impl Binder {
pub fn bind_distinct(
Expand All @@ -43,16 +44,18 @@ impl Binder {
let scalar_items: Vec<ScalarItem> = scalar_items
.drain()
.map(|(_, item)| {
let mut scalar = item.scalar;
if bind_context.in_grouping {
let group_checker = GroupingChecker::new(bind_context);
let scalar = group_checker.resolve(&item.scalar, None)?;
Ok(ScalarItem {
scalar,
index: item.index,
})
} else {
Ok(item)
scalar = group_checker.resolve(&scalar, None)?;
} else if !bind_context.windows.window_functions.is_empty() {
let window_checker = WindowChecker::new(bind_context);
scalar = window_checker.resolve(&scalar)?;
}
Ok(ScalarItem {
scalar,
index: item.index,
})
})
.collect::<Result<_>>()?;

Expand Down
11 changes: 10 additions & 1 deletion src/query/sql/src/planner/semantic/type_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1011,7 +1011,16 @@ impl<'a> TypeChecker<'a> {
let path = match accessor {
MapAccessor::Bracket {
key: box Expr::Literal { lit, .. },
} => lit.clone(),
} => {
if !matches!(lit, Literal::UInt64(_) | Literal::String(_)) {
return Err(ErrorCode::SemanticError(format!(
"Unsupported accessor: {:?}",
lit
))
.set_span(*span));
}
lit.clone()
}
MapAccessor::Dot { key } | MapAccessor::Colon { key } => {
Literal::String(key.name.clone())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ SELECT count(distinct number %3) c FROM numbers(1000) where number > 3;
----
3

query I
SELECT DISTINCT row_number() OVER (PARTITION BY number) FROM numbers(100)
----
1
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ select t.1, t.2, t.3, t.4, t.5, t.6 from t1
1 100 12.34 abc 2020-01-01 2020-01-01 00:00:00.000000
0 200 -25.73 xyz 2022-06-01 2022-06-01 12:00:00.000000

statement error 1065
select t[1.1] from t1

statement error 1005
CREATE TABLE IF NOT EXISTS t2(t Tuple(a Bool, Int64)) Engine = Fuse

Expand Down

1 comment on commit 7691b38

@vercel
Copy link

@vercel vercel bot commented on 7691b38 Sep 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.