Skip to content

Commit cbff33b

Browse files
committed
adjust summary field to be a proper array
1 parent 235a839 commit cbff33b

File tree

5 files changed

+39
-26
lines changed

5 files changed

+39
-26
lines changed

Cargo.lock

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

src/database.rs

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use std::fmt;
3434
use std::{any::Any, collections::HashMap, env, sync::Arc};
3535
use tokio::sync::RwLock;
3636
use tokio_util::sync::CancellationToken;
37-
use tracing::{debug, error, info};
37+
use tracing::{debug, error, info, warn};
3838
use url::Url;
3939

4040
// Changed to support multiple tables per project: (project_id, table_name) -> DeltaTable
@@ -349,14 +349,24 @@ impl Database {
349349
config.ttl.as_secs()
350350
);
351351

352-
match SharedFoyerCache::new(config).await {
353-
Ok(cache) => {
354-
info!("Shared Foyer cache initialized successfully for all tables");
355-
Some(Arc::new(cache))
356-
}
357-
Err(e) => {
358-
error!("Failed to initialize shared Foyer cache: {}. Continuing without cache.", e);
359-
None
352+
// Retry cache initialization a few times to handle transient failures
353+
let mut retry_count = 0;
354+
let max_retries = 3;
355+
loop {
356+
match SharedFoyerCache::new(config.clone()).await {
357+
Ok(cache) => {
358+
info!("Shared Foyer cache initialized successfully for all tables");
359+
break Some(Arc::new(cache));
360+
}
361+
Err(e) => {
362+
retry_count += 1;
363+
if retry_count >= max_retries {
364+
error!("Failed to initialize shared Foyer cache after {} retries: {}. Continuing without cache.", max_retries, e);
365+
break None;
366+
}
367+
warn!("Failed to initialize shared Foyer cache (attempt {}/{}): {}. Retrying...", retry_count, max_retries, e);
368+
tokio::time::sleep(tokio::time::Duration::from_millis(100)).await;
369+
}
360370
}
361371
}
362372
};
@@ -891,13 +901,14 @@ impl Database {
891901
// Create the base S3 object store
892902
let base_store = self.create_object_store(&storage_uri, &storage_options).await?;
893903

894-
// Wrap with the shared Foyer cache
904+
// Wrap with the shared Foyer cache if available, otherwise use base store
895905
let cached_store = if let Some(ref shared_cache) = self.object_store_cache {
896906
// Create a new wrapper around the base store using our shared cache
897907
// This allows the same cache to be used across all tables
898-
Arc::new(FoyerObjectStoreCache::new_with_shared_cache(base_store, shared_cache)) as Arc<dyn object_store::ObjectStore>
908+
Arc::new(FoyerObjectStoreCache::new_with_shared_cache(base_store.clone(), shared_cache)) as Arc<dyn object_store::ObjectStore>
899909
} else {
900-
return Err(anyhow::anyhow!("Shared Foyer cache not initialized"));
910+
warn!("Shared Foyer cache not initialized, using uncached object store");
911+
base_store
901912
};
902913

903914
// Try to load or create the table with the cached object store
@@ -1832,7 +1843,7 @@ mod tests {
18321843
project_id, date, timestamp, id, hashes, name, level, status_code, summary
18331844
) VALUES (
18341845
'project2', TIMESTAMP '2023-01-01', TIMESTAMP '2023-01-01T10:00:00Z',
1835-
'sql_id', ARRAY[], 'sql_name', 'INFO', 'OK', 'SQL inserted test span'
1846+
'sql_id', ARRAY[], 'sql_name', 'INFO', 'OK', ARRAY['SQL inserted test span']
18361847
)";
18371848
let result = ctx.sql(sql).await?.collect().await?;
18381849
assert_eq!(result[0].num_rows(), 1);
@@ -1869,9 +1880,9 @@ mod tests {
18691880
let sql = "INSERT INTO otel_logs_and_spans (
18701881
project_id, date, timestamp, id, hashes, name, level, status_code, summary
18711882
) VALUES
1872-
('project1', TIMESTAMP '2023-01-01', TIMESTAMP '2023-01-01T10:00:00Z', 'id1', ARRAY[], 'name1', 'INFO', 'OK', 'Multi-row insert test 1'),
1873-
('project1', TIMESTAMP '2023-01-01', TIMESTAMP '2023-01-01T11:00:00Z', 'id2', ARRAY[], 'name2', 'INFO', 'OK', 'Multi-row insert test 2'),
1874-
('project1', TIMESTAMP '2023-01-01', TIMESTAMP '2023-01-01T12:00:00Z', 'id3', ARRAY[], 'name3', 'ERROR', 'ERROR', 'Multi-row insert test 3 - ERROR')";
1883+
('project1', TIMESTAMP '2023-01-01', TIMESTAMP '2023-01-01T10:00:00Z', 'id1', ARRAY[], 'name1', 'INFO', 'OK', ARRAY['Multi-row insert test 1']),
1884+
('project1', TIMESTAMP '2023-01-01', TIMESTAMP '2023-01-01T11:00:00Z', 'id2', ARRAY[], 'name2', 'INFO', 'OK', ARRAY['Multi-row insert test 2']),
1885+
('project1', TIMESTAMP '2023-01-01', TIMESTAMP '2023-01-01T12:00:00Z', 'id3', ARRAY[], 'name3', 'ERROR', 'ERROR', ARRAY['Multi-row insert test 3 - ERROR'])";
18751886

18761887
// Multi-row INSERT returns a count of rows inserted
18771888
let result = ctx.sql(sql).await?.collect().await?;

tests/slt/function_availability_test.slt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ INSERT INTO otel_logs_and_spans (
119119
) VALUES
120120
('test_funcs', TIMESTAMP '2024-01-16T10:00:00Z', 'json_test_2', ARRAY['hash2']::VARCHAR[], DATE '2024-01-16',
121121
NULL, 'test_json2', 'SERVER', 'test-service',
122-
'OK', '{"simple": "value"}', 'INFO', 1000000, 'Simple JSON test')
122+
'OK', '{"simple": "value"}', 'INFO', 1000000, ARRAY['Simple JSON test'])
123123

124124
# Since json_get fails with Union type error, let's just verify the JSON string is stored
125125
query T

tests/slt/partition_pruning_test.slt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@ statement ok
66
INSERT INTO otel_logs_and_spans (
77
project_id, timestamp, id, hashes, date, name, summary
88
) VALUES (
9-
'prune_test', TIMESTAMP '2024-01-01T10:00:00Z', 'span1', ARRAY[]::VARCHAR[], DATE '2024-01-01', 'operation1', 'Partition pruning test span 1'
9+
'prune_test', TIMESTAMP '2024-01-01T10:00:00Z', 'span1', ARRAY[]::VARCHAR[], DATE '2024-01-01', 'operation1', ARRAY['Partition pruning test span 1']
1010
)
1111

1212
statement ok
1313
INSERT INTO otel_logs_and_spans (
1414
project_id, timestamp, id, hashes, date, name, summary
1515
) VALUES (
16-
'prune_test', TIMESTAMP '2024-01-02T10:00:00Z', 'span2', ARRAY[]::VARCHAR[], DATE '2024-01-02', 'operation2', 'Partition pruning test span 2'
16+
'prune_test', TIMESTAMP '2024-01-02T10:00:00Z', 'span2', ARRAY[]::VARCHAR[], DATE '2024-01-02', 'operation2', ARRAY['Partition pruning test span 2']
1717
)
1818

1919
statement ok
2020
INSERT INTO otel_logs_and_spans (
2121
project_id, timestamp, id, hashes, date, name, summary
2222
) VALUES (
23-
'prune_test', TIMESTAMP '2024-01-03T10:00:00Z', 'span3', ARRAY[]::VARCHAR[], DATE '2024-01-03', 'operation3', 'Partition pruning test span 3'
23+
'prune_test', TIMESTAMP '2024-01-03T10:00:00Z', 'span3', ARRAY[]::VARCHAR[], DATE '2024-01-03', 'operation3', ARRAY['Partition pruning test span 3']
2424
)
2525

2626
# Query with timestamp filter - optimizer should add date filter for partition pruning

tests/slt/percentile_functions.slt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,23 +211,23 @@ LIMIT 1
211211
----
212212
true
213213

214-
# Test 4: array indexing with literal array (0-based indexing)
214+
# Test 4: array indexing with literal array (1-based indexing in SQL)
215215
query R
216-
SELECT ARRAY[10.5, 20.5, 30.5][1] as second_element
216+
SELECT ARRAY[10.5, 20.5, 30.5][1] as first_element
217217
FROM test_spans
218218
WHERE project_id = 'test-project'
219219
LIMIT 1
220220
----
221-
20.5
221+
10.5
222222

223-
# Test 5: array indexing with string array (0-based indexing)
223+
# Test 5: array indexing with string array (1-based indexing in SQL)
224224
query T
225-
SELECT ARRAY['p50', 'p75', 'p90', 'p95'][2] as third_quantile
225+
SELECT ARRAY['p50', 'p75', 'p90', 'p95'][2] as second_quantile
226226
FROM test_spans
227227
WHERE project_id = 'test-project'
228228
LIMIT 1
229229
----
230-
p90
230+
p75
231231

232232
# Test 6: Percentiles grouped by time buckets using time_bucket function
233233
query TBB

0 commit comments

Comments
 (0)