You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"First value of column 'a' should be either 'Apache' or 'Iceberg'"
1967
+
);
1968
+
}
1969
+
1970
+
#[test]
1971
+
fntest_invalid_incremental_scan_configurations(){
1972
+
let table = TableTestFixture::new().table;
1973
+
1974
+
// Test case 1: to_snapshot_id is required for incremental scan
1975
+
let result = table
1976
+
.scan()
1977
+
.from_snapshot_id(1234)// Only providing from_snapshot_id
1978
+
.build();
1979
+
1980
+
assert!(
1981
+
result.is_err(),
1982
+
"Should fail when to_snapshot_id is not set"
1983
+
);
1984
+
assert_eq!(
1985
+
result.unwrap_err().to_string(),
1986
+
"DataInvalid => Incremental scan requires to_snapshot_id to be set. Use from_snapshot_id (exclusive) and to_snapshot_id (inclusive) to specify the range.",
1987
+
"Should have correct error message for missing to_snapshot_id"
1988
+
);
1989
+
1990
+
// Test case 2: snapshot_id should not be set with incremental scan
1991
+
let result = table
1992
+
.scan()
1993
+
.snapshot_id(1234)
1994
+
.from_snapshot_id(1234)
1995
+
.to_snapshot_id(5678)
1996
+
.build();
1997
+
1998
+
assert!(
1999
+
result.is_err(),
2000
+
"Should fail when snapshot_id is set with incremental scan"
2001
+
);
2002
+
assert_eq!(
2003
+
result.unwrap_err().to_string(),
2004
+
"DataInvalid => snapshot_id should not be set for incremental scan. Use from_snapshot_id and to_snapshot_id instead.",
2005
+
"Should have correct error message for setting both snapshot_id and incremental scan parameters"
2006
+
);
2007
+
}
2008
+
2009
+
#[test]
2010
+
fntest_incremental_scan_edge_cases(){
2011
+
let fixture = TableTestFixture::new();
2012
+
let table = &fixture.table;
2013
+
2014
+
// Test case 1: Non-existent to_snapshot_id
2015
+
let result = table
2016
+
.scan()
2017
+
.to_snapshot_id(999999)// Non-existent snapshot ID
2018
+
.build();
2019
+
2020
+
assert!(
2021
+
result.is_err(),
2022
+
"Should fail when to_snapshot_id does not exist"
2023
+
);
2024
+
assert_eq!(
2025
+
result.unwrap_err().to_string(),
2026
+
"DataInvalid => to_snapshot_id 999999 not found",
2027
+
"Should have correct error message for non-existent to_snapshot_id"
2028
+
);
2029
+
2030
+
// Test case 2: Non-existent from_snapshot_id
2031
+
let result = table
2032
+
.scan()
2033
+
.from_snapshot_id(999998)// Non-existent snapshot ID
2034
+
.to_snapshot_id(999999)// Non-existent snapshot ID
2035
+
.build();
2036
+
2037
+
assert!(
2038
+
result.is_err(),
2039
+
"Should fail when to_snapshot_id does not exist"
2040
+
);
2041
+
// This should fail on to_snapshot_id first since that's checked first
2042
+
assert_eq!(
2043
+
result.unwrap_err().to_string(),
2044
+
"DataInvalid => to_snapshot_id 999999 not found",
2045
+
"Should fail on to_snapshot_id check first"
2046
+
);
2047
+
2048
+
// We need to set up snapshots for the remaining tests
2049
+
let snapshots = table.metadata().snapshots().collect::<Vec<_>>();
2050
+
if snapshots.len() >= 2{
2051
+
let first_snapshot_id = snapshots[0].snapshot_id();
2052
+
let second_snapshot_id = snapshots[1].snapshot_id();
2053
+
2054
+
// Test case 3: from_snapshot_id doesn't exist but to_snapshot_id does
2055
+
let result = table
2056
+
.scan()
2057
+
.from_snapshot_id(999998)// Non-existent
2058
+
.to_snapshot_id(second_snapshot_id)// Existent
2059
+
.build();
2060
+
2061
+
assert!(
2062
+
result.is_err(),
2063
+
"Should fail when from_snapshot_id does not exist"
2064
+
);
2065
+
assert_eq!(
2066
+
result.unwrap_err().to_string(),
2067
+
"DataInvalid => from_snapshot_id 999998 not found",
2068
+
"Should have correct error message for non-existent from_snapshot_id"
2069
+
);
2070
+
2071
+
// Determine which snapshot is newer based on snapshot IDs
2072
+
let(older_snapshot_id, newer_snapshot_id) = if first_snapshot_id < second_snapshot_id {
2073
+
(first_snapshot_id, second_snapshot_id)
2074
+
}else{
2075
+
(second_snapshot_id, first_snapshot_id)
2076
+
};
2077
+
2078
+
// Test case 4: Reversed snapshot order (to_snapshot_id <= from_snapshot_id)
2079
+
let result = table
2080
+
.scan()
2081
+
.from_snapshot_id(newer_snapshot_id)// Later snapshot
0 commit comments