Skip to content

Commit 2b8f908

Browse files
fix(table): enable global index by default (#587)
1 parent f8471ea commit 2b8f908

3 files changed

Lines changed: 40 additions & 2 deletions

File tree

crates/paimon/src/spec/core_options.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ impl<'a> CoreOptions<'a> {
540540
self.options
541541
.get(GLOBAL_INDEX_ENABLED_OPTION)
542542
.map(|value| value.eq_ignore_ascii_case("true"))
543-
.unwrap_or(false)
543+
.unwrap_or(true)
544544
}
545545

546546
pub fn global_index_search_mode(&self) -> crate::Result<GlobalIndexSearchMode> {
@@ -1360,6 +1360,17 @@ mod tests {
13601360
}
13611361
}
13621362

1363+
#[test]
1364+
fn test_global_index_enabled_defaults_and_overrides() {
1365+
assert!(CoreOptions::new(&HashMap::new()).global_index_enabled());
1366+
1367+
for (raw, expected) in [("true", true), ("false", false)] {
1368+
let options =
1369+
HashMap::from([(GLOBAL_INDEX_ENABLED_OPTION.to_string(), raw.to_string())]);
1370+
assert_eq!(CoreOptions::new(&options).global_index_enabled(), expected);
1371+
}
1372+
}
1373+
13631374
#[test]
13641375
fn test_global_index_search_mode_rejects_invalid_value() {
13651376
let options = HashMap::from([(

crates/paimon/src/table/btree_global_index_build_builder.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,6 +1240,33 @@ mod tests {
12401240
.unwrap()
12411241
.unwrap();
12421242
assert_eq!(row_ranges, vec![RowRange::new(0, 0), RowRange::new(2, 2)]);
1243+
1244+
// Reopen the same table without an explicit global-index override and
1245+
// verify that the regular scan path still uses the committed index.
1246+
let mut options = table.schema().options().clone();
1247+
assert_eq!(
1248+
options.remove("global-index.enabled"),
1249+
Some("true".to_string())
1250+
);
1251+
let scan_table = Table::new(
1252+
table.file_io().clone(),
1253+
table.identifier().clone(),
1254+
table.location().to_string(),
1255+
table.schema().copy_with_replaced_options(options),
1256+
None,
1257+
);
1258+
let predicate = PredicateBuilder::new(scan_table.schema().fields())
1259+
.equal("name", crate::spec::Datum::String("alice".to_string()))
1260+
.unwrap();
1261+
let mut read_builder = scan_table.new_read_builder();
1262+
read_builder.with_filter(predicate);
1263+
let plan = read_builder.new_scan().plan().await.unwrap();
1264+
1265+
assert_eq!(plan.splits().len(), 1);
1266+
assert_eq!(
1267+
plan.splits()[0].row_ranges(),
1268+
Some(&[RowRange::new(0, 0), RowRange::new(2, 2)][..])
1269+
);
12431270
}
12441271

12451272
#[tokio::test]

docs/src/sql.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1923,7 +1923,7 @@ deletion vectors enabled.
19231923
|---|---:|---|
19241924
| `row-tracking.enabled` | `false` | Enables stable row ids required by global index files. |
19251925
| `data-evolution.enabled` | `false` | Enables row-id-aware table evolution and partial-column writes. |
1926-
| `global-index.enabled` | `false` | Enables global index metadata and global-index-aware reads. |
1926+
| `global-index.enabled` | `true` | Enables global index metadata and global-index-aware reads. |
19271927
| `global-index.row-count-per-shard` | `100000` | Maximum row count per vector global-index shard. |
19281928
| `sorted-index.records-per-range` | `100000` | Maximum row count per BTree range. |
19291929
| `btree-index.fallback-scan-max-size` | `256mb` | Maximum total size of selected BTree global-index files for fallback scans used by range/between and suffix/contains/complex LIKE predicates; `0` disables BTree fallback index scans. |

0 commit comments

Comments
 (0)