Skip to content

Commit cde8d0b

Browse files
committed
fix test
1 parent e5adffc commit cde8d0b

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

quasardb/arrow_batch_push.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,10 @@ void exp_batch_push_arrow_with_options(handle_ptr handle,
162162
std::vector<qdb_ts_range_t> truncate_ranges;
163163
qdb_ts_range_t * range_ptr = nullptr;
164164

165-
166165
if (options.mode == qdb_exp_batch_push_truncate)
167166
[[unlikely]] // Unlikely because truncate isn't used much
168167
{
169-
if (args.contains("range"))
168+
if (args.contains(detail::batch_truncate_ranges::kw_range))
170169
{
171170
truncate_ranges = detail::batch_truncate_ranges::from_kwargs(args);
172171
range_ptr = truncate_ranges.data();
@@ -180,6 +179,9 @@ void exp_batch_push_arrow_with_options(handle_ptr handle,
180179
arrow_batch batch{reader};
181180
auto c_batch = batch.build(table_name, dedup, range_ptr, truncate_ranges.size());
182181

182+
qdb::logger logger("quasardb.batch_push_arrow");
183+
logger.debug("Pushing Arrow stream in %s using %s push mode", table_name,
184+
detail::batch_push_mode::to_string(options.mode));
183185
qdb_error_t err{qdb_e_ok};
184186
{
185187
// Make sure to measure the time it takes to do the actual push.
@@ -190,7 +192,6 @@ void exp_batch_push_arrow_with_options(handle_ptr handle,
190192
err = qdb_exp_batch_push_arrow_with_options(*handle, &options, &c_batch, nullptr, 1u);
191193
}
192194

193-
qdb::logger logger("quasardb.batch_push_arrow");
194195
auto retry_options = detail::retry_options::from_kwargs(args);
195196
if (retry_options.should_retry(err))
196197
[[unlikely]] // Unlikely, because err is most likely to be qdb_e_ok

tests/test_pandas.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,12 +308,26 @@ def test_write_dataframe_push_fast(qdbpd_write_fn, qdbd_connection, df_with_tabl
308308
def test_write_dataframe_push_truncate(qdbpd_write_fn, qdbd_connection, df_with_table):
309309
(_, _, df1, table) = df_with_table
310310

311+
# For Arrow Push we need to have the truncate range
312+
step = df1.index[1] - df1.index[0]
313+
start = np.datetime64(df1.index[0].to_datetime64(), "ns")
314+
end = np.datetime64((df1.index[-1] + step).to_datetime64(), "ns")
315+
ranges = (start, end)
316+
311317
# Ensures that we can do a full-circle write and read of a dataframe
312318
qdbpd_write_fn(
313-
df1, qdbd_connection, table, push_mode=quasardb.WriterPushMode.Truncate
319+
df1,
320+
qdbd_connection,
321+
table,
322+
push_mode=quasardb.WriterPushMode.Truncate,
323+
range=ranges,
314324
)
315325
qdbpd_write_fn(
316-
df1, qdbd_connection, table, push_mode=quasardb.WriterPushMode.Truncate
326+
df1,
327+
qdbd_connection,
328+
table,
329+
push_mode=quasardb.WriterPushMode.Truncate,
330+
range=ranges,
317331
)
318332

319333
df2 = qdbpd.read_dataframe(qdbd_connection, table)
@@ -577,7 +591,11 @@ def test_push_mode(qdbpd_write_fn, df_with_table, push_mode, qdbd_connection, ca
577591
kwargs["_async"] = True
578592

579593
caplog.clear()
580-
caplog.set_level(logging.DEBUG, logger="quasardb.writer")
594+
logger_name = "quasardb.writer"
595+
if qdbpd_write_fn is conftest._write_dataframe_arrow:
596+
logger_name = "quasardb.batch_push_arrow"
597+
598+
caplog.set_level(logging.DEBUG, logger=logger_name)
581599
qdbpd_write_fn(df, qdbd_connection, table, **kwargs)
582600

583601
assert any(expected in x.message for x in caplog.records)

0 commit comments

Comments
 (0)