Skip to content

Commit 185db54

Browse files
authored
fix(cubesql): Fix adding missing columns for ORDER BY clause (#9764)
1 parent 08f21b6 commit 185db54

File tree

51 files changed

+1533
-1468
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1533
-1468
lines changed

packages/cubejs-backend-native/Cargo.lock

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

rust/cubenativeutils/Cargo.lock

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

rust/cubesql/Cargo.lock

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

rust/cubesql/cubesql/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ homepage = "https://cube.dev"
1010

1111
[dependencies]
1212
arc-swap = "1"
13-
datafusion = { git = 'https://github.com/cube-js/arrow-datafusion.git', rev = "637003a448a98bbc5e1585d0f01cc19ba9d50668", default-features = false, features = [
13+
datafusion = { git = 'https://github.com/cube-js/arrow-datafusion.git', rev = "7803f7e1cb8fa3d7b25451de35b8765e1ce4a3f6", default-features = false, features = [
1414
"regex_expressions",
1515
"unicode_expressions",
1616
] }

rust/cubesql/cubesql/src/compile/mod.rs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,7 @@ mod tests {
626626
.request
627627
.dimensions,
628628
Some(vec![
629+
"KibanaSampleDataEcommerce.id".to_string(),
629630
"KibanaSampleDataEcommerce.order_date".to_string(),
630631
"KibanaSampleDataEcommerce.last_mod".to_string(),
631632
"KibanaSampleDataEcommerce.customer_gender".to_string(),
@@ -651,6 +652,7 @@ mod tests {
651652
.request
652653
.dimensions,
653654
Some(vec![
655+
"KibanaSampleDataEcommerce.id".to_string(),
654656
"KibanaSampleDataEcommerce.order_date".to_string(),
655657
"KibanaSampleDataEcommerce.last_mod".to_string(),
656658
"KibanaSampleDataEcommerce.customer_gender".to_string(),
@@ -756,6 +758,7 @@ mod tests {
756758
]),
757759
segments: Some(vec![]),
758760
dimensions: Some(vec![
761+
"KibanaSampleDataEcommerce.id".to_string(),
759762
"KibanaSampleDataEcommerce.order_date".to_string(),
760763
"KibanaSampleDataEcommerce.last_mod".to_string(),
761764
"KibanaSampleDataEcommerce.customer_gender".to_string(),
@@ -8217,6 +8220,7 @@ ORDER BY "source"."str0" ASC
82178220
"Logs.agentCountApprox".to_string(),
82188221
]),
82198222
dimensions: Some(vec![
8223+
"KibanaSampleDataEcommerce.id".to_string(),
82208224
"KibanaSampleDataEcommerce.order_date".to_string(),
82218225
"KibanaSampleDataEcommerce.last_mod".to_string(),
82228226
"KibanaSampleDataEcommerce.customer_gender".to_string(),
@@ -8402,6 +8406,7 @@ ORDER BY "source"."str0" ASC
84028406
"KibanaSampleDataEcommerce.countDistinct".to_string(),
84038407
]),
84048408
dimensions: Some(vec![
8409+
"KibanaSampleDataEcommerce.id".to_string(),
84058410
"KibanaSampleDataEcommerce.order_date".to_string(),
84068411
"KibanaSampleDataEcommerce.last_mod".to_string(),
84078412
"KibanaSampleDataEcommerce.customer_gender".to_string(),
@@ -17110,4 +17115,43 @@ LIMIT {{ limit }}{% endif %}"#.to_string(),
1711017115
displayable(physical_plan.as_ref()).indent()
1711117116
);
1711217117
}
17118+
17119+
#[tokio::test]
17120+
async fn test_sort_normalize() {
17121+
init_testing_logger();
17122+
17123+
let logical_plan = convert_select_to_query_plan(
17124+
r#"
17125+
SELECT
17126+
q2.id,
17127+
q3.id
17128+
FROM KibanaSampleDataEcommerce q1
17129+
LEFT JOIN Logs q2 ON q1.__cubeJoinField = q2.__cubeJoinField
17130+
LEFT JOIN Logs q3 ON q1.__cubeJoinField = q3.__cubeJoinField
17131+
ORDER BY
17132+
q2.id,
17133+
q3.id
17134+
;"#
17135+
.to_string(),
17136+
DatabaseProtocol::PostgreSQL,
17137+
)
17138+
.await
17139+
.as_logical_plan();
17140+
17141+
assert_eq!(
17142+
logical_plan.find_cube_scan().request,
17143+
V1LoadRequestQuery {
17144+
measures: Some(vec![]),
17145+
dimensions: Some(vec!["Logs.id".to_string(),]),
17146+
segments: Some(vec![]),
17147+
order: Some(vec![]),
17148+
ungrouped: Some(true),
17149+
join_hints: Some(vec![
17150+
vec!["KibanaSampleDataEcommerce".to_string(), "Logs".to_string()],
17151+
vec!["KibanaSampleDataEcommerce".to_string(), "Logs".to_string()],
17152+
]),
17153+
..Default::default()
17154+
}
17155+
)
17156+
}
1711317157
}

rust/cubesql/cubesql/src/compile/snapshots/cubesql__compile__tests__information_schema_columns_mysql.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
source: cubesql/src/compile/mod.rs
3-
assertion_line: 6584
4-
expression: "execute_query(\"SELECT * FROM information_schema.columns WHERE TABLE_SCHEMA = 'db'\".to_string(),\n DatabaseProtocol::MySQL).await?"
3+
expression: "execute_query(\"SELECT * FROM information_schema.columns WHERE TABLE_SCHEMA = 'db'\".to_string(),\nDatabaseProtocol::MySQL).await?"
54
---
65
+---------------+--------------+---------------------------+--------------------+------------------+----------------+-------------+------------+--------------------------+------------------------+--------------+-------------------+---------------+--------------------+------------+-------+----------------+-----------------------+--------+
76
| TABLE_CATALOG | TABLE_SCHEMA | TABLE_NAME | COLUMN_NAME | ORDINAL_POSITION | COLUMN_DEFAULT | IS_NULLABLE | DATA_TYPE | CHARACTER_MAXIMUM_LENGTH | CHARACTER_OCTET_LENGTH | COLUMN_TYPE | NUMERIC_PRECISION | NUMERIC_SCALE | DATETIME_PRECISION | COLUMN_KEY | EXTRA | COLUMN_COMMENT | GENERATION_EXPRESSION | SRS_ID |
@@ -12,6 +11,7 @@ expression: "execute_query(\"SELECT * FROM information_schema.columns WHERE TABL
1211
| def | db | KibanaSampleDataEcommerce | minPrice | 0 | | NO | numeric | NULL | NULL | numeric | NULL | NULL | NULL | | | | | |
1312
| def | db | KibanaSampleDataEcommerce | avgPrice | 0 | | NO | numeric | NULL | NULL | numeric | NULL | NULL | NULL | | | | | |
1413
| def | db | KibanaSampleDataEcommerce | countDistinct | 0 | | NO | int | NULL | NULL | int | NULL | NULL | NULL | | | | | |
14+
| def | db | KibanaSampleDataEcommerce | id | 0 | | YES | numeric | NULL | NULL | numeric | NULL | NULL | NULL | | | | | |
1515
| def | db | KibanaSampleDataEcommerce | order_date | 0 | | YES | datetime | NULL | NULL | datetime | NULL | NULL | NULL | | | | | |
1616
| def | db | KibanaSampleDataEcommerce | last_mod | 0 | | YES | datetime | NULL | NULL | datetime | NULL | NULL | NULL | | | | | |
1717
| def | db | KibanaSampleDataEcommerce | customer_gender | 0 | | YES | varchar | NULL | NULL | varchar(255) | NULL | NULL | NULL | | | | | |

0 commit comments

Comments
 (0)